Static-web-apps: Azure Devops pipeline with private artifact feed

Created on 25 Mar 2021  路  3Comments  路  Source: Azure/static-web-apps

Building static web apps from devops is looking good and easy to use. However we have run into a problem where we have some npm packages from our private feed, this is defined in our .npmrc file, however it appears to have problems installing packages.

.npmrc

registry=https://pkgs.dev.azure.com/xxx/_packaging/yyy/npm/registry/
always-auth=true; 

For a normal pipeline build (using npm) we can define the feed in npm parameters:

      - task: Npm@1
        name: NpmInstall
        inputs:
          command: 'install'
          workingDir: 'Clients/React'
          customRegistry: 'useFeed'
          customFeed: 'xxx'

Is it possible to specify a customFeed in the same way using the SPA pipeline task?

The pipeline output is:

Running 'npm install --unsafe-perm --production'...

npm ERR! code E401
npm ERR! Unable to authenticate, need: Bearer authorization_uri=https://login.windows.net/xxxx, Basic realm="https://pkgsprodcus1.pkgs.visualstudio.com/", TFS-Federated

npm ERR! A complete log of this run can be found in:
npm ERR!     /root/.npm/_logs/2021-03-24T18_55_50_798Z-debug.log

azure-devops github-action

Most helpful comment

@krisnuttall To get around this for now, build your app in separate steps and use the AzureStaticWebApp task to publish only. To do this, set the app_location to the build output location from the previous step (build, dist, etc). Leave output_location empty.

All 3 comments

@krisnuttall To get around this for now, build your app in separate steps and use the AzureStaticWebApp task to publish only. To do this, set the app_location to the build output location from the previous step (build, dist, etc). Leave output_location empty.

Thanks @anthonychu the workaround works well:

      - task: npmBuild
        .....

      - task: AzureStaticWebApp@0
        inputs:
          app_location: 'Clients/React/build'
        env:
          azure_static_web_apps_api_token: xxx

We have a similar or same issue for a Blazor WebAssembly that uses a private Azure DevOps artifact.

- task: AzureStaticWebApp@0
  inputs:
    app_location: "scream4meV2.AdminTool"
    api_location: "" 
    output_location: "wwwroot"

  env:
      azure_static_web_apps_api_token: $(deployment_token)

gives the following error when run:

2021-04-04T20:36:17.8011340Z   Determining projects to restore...
2021-04-04T20:36:18.5354965Z /tmp/oryx/platforms/dotnet/5.0.103/sdk/5.0.103/NuGet.targets(131,5): error : Unable to load the service index for source https://pkgs.dev.azure.com/scream4me/_packaging/scream4meV2.Shared/nuget/v3/index.json. [/working_dir/scream4meV2.AdminTool/scream4meV2.AdminTool.csproj]
2021-04-04T20:36:18.5356631Z /tmp/oryx/platforms/dotnet/5.0.103/sdk/5.0.103/NuGet.targets(131,5): error :   Response status code does not indicate success: 401 (Unauthorized). [/working_dir/scream4meV2.AdminTool/scream4meV2.AdminTool.csproj]
2021-04-04T20:36:20.3764297Z 
2021-04-04T20:36:20.3764743Z 
2021-04-04T20:36:20.3765151Z ---End of Oryx build logs---
2021-04-04T20:36:20.3775107Z Oryx has failed to build the solution.
2021-04-04T20:36:20.4140308Z 
Was this page helpful?
0 / 5 - 0 ratings