Azure / Azure/static-web-apps

AzureStaticWebApp@0 unable to access Azure Artifacts Nuget

Open
#1,718 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
No language data
Stars
346
Forks
67
PR merge metrics
No merged PRs in 30d

Description

Taking the yml file to build a static web app in Azure pipeline:

```
name: website (dev)
trigger:
- dev
pool:
vmImage: ubuntu-latest
steps:
- checkout: self
submodules: true
# - task: UseDotNet@2
# displayName: 'Install .NET Core SDK'
# inputs:
# version: 9.x
# performMultiLevelLookup: true
# includePreviewVersions: true
# - task: NuGetAuthenticate@1
# - task: UseDotNet@2
# inputs:
# packageType: 'sdk'
# version: '9.0.x'
# - script: |
# dotnet restore api/api.csproj
# dotnet build api/api.csproj
- task: AzureStaticWebApp@0
inputs:
deployment_environment: "dev"
app_location: 'Client/src'
# skip_api_build: true
api_location: 'api'
output_location: '/output'
azure_static_web_apps_api_token: $(deployment_token)
verbose: true
```

This as-is fails as:
/working_dir/api/api.csproj : error NU1301: Unable to load the service index for source https://pkgs.dev.azure.com/xxxxxxx/_packaging/xxxxx_nuget/nuget/v3/index.json.
/working_dir/api/api.csproj : error NU1301: Response status code does not indicate success: 401 (Unauthorized).

Alternative approach is to uncomment lines above to pre-build the function. These also access the same Artifacts and do so successfully, so I know it's not a permission issue. However I've tried about 100 combinations of configurations this way too and nothing works. I have a swa-cli.config.json that looks like this:

```
{
"$schema": "https://aka.ms/azure/static-web-apps-cli/schema",
"configurations": {
"client": {
"appLocation": "Client/src",
"outputLocation": ".",
"appName": "xxxxx",
"resourceGroup": "xxxxx-rg",
"apiPort": 7032
},
"api": {
"appLocation": "api",
"outputLocation": "",
"language": "dotnet-isolated",
"version": "9.0"
}
}
}
```

Returns:
Cannot deploy to the function app because Function language info isn't provided.

I've put the language/version in a bunch of places and formatted it a number of ways, like "dotnet-isolated:9.0" but it doesn't seem to matter. Same with having a redundant version of this file in other places as well as changing paths.

I've tried about 100 different combinations of trial and error to get around this for the last few days and no documentation online works. I'm kinda running out of ideas at this point.

The only thing that works is to pull the sources from the Artifacts and add them to the solution file and the same repo. This does work but it's a bit of a maintenance nightmare.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.