Registering PS Repositories gives misleading error message when your account does not have authorisation

TL;DR When using Register-PSRepository ‘Location’ is an invalid Web Uri may instead mean you are not authorised to use the valid Web Uri

The specified Uri ‘https://pkgs.dev.azure.com/MyAzureDevOps/MyProject/_packaging/MyRepository/nuget/v2' for parameter ‘Location’ is an invalid Web Uri. Please ensure that it meets the Web Uri requirements.

This one threw us for several hours. We were getting it in an Azure DEVOps Pipeline.

The URI was valid, we could open it up in a browser and it showed a correct feed.

In the end it turns out to be a very loose error message in that the Uri is valid but the process calling it is not authorised to use it.

We proved this by using the Register-PSRepository PowerShell command with and without credentials.

However we were doing this in a pipeline, see below, using the SYSTEM_ACCESSTOKEN. It was working in two projects, including the one the Azure Artifact Feed was defined in, but not in any others.

So what was the difference?

It all comes down to the “Limit job authorization scope to current project for non-release pipelines” Azure DEVOps project’s setting for the project that is using the feed.

With this set, which is the default, then SYSTEM_ACCESSTOKEN is blank, hence the credentials are invalid and you get the error message.

The specified Uri ‘https://pkgs.dev.azure.com/MyAzureDevOps/MyProject/_packaging/MyRepository/nuget/v2' for parameter ‘Location’ is an invalid Web Uri. Please ensure that it meets the Web Uri requirements.

With it unset then SYSTEM_ACCESSTOKEN is populated and the credentials are properly created.

For reference here is the example code for using SYSTEM_ACCESSTOKEN to authenticate.

TL;DR When using Register-PSRepository ‘Location’ is an invalid Web Uri may instead mean you are not authorised to use the valid Web Uri

--

--

--

Technical Director for Simple Innovations Ltd. First paid for code in 1980, but still has all his own hair.

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

How to find the maximum number of bugs in software?

Learn a new programming language faster than usual!

SMPL Foundation has been listed at Catex Exchange

READ/DOWNLOAD%# Objects First with Java: A Practic

Result trade nature build once.

12 Arduino Projects for Beginners — With Code

How to Play Sound Effects in Unity!

File based Import/Export Data in Ax2012

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Sebastian Rogers

Sebastian Rogers

Technical Director for Simple Innovations Ltd. First paid for code in 1980, but still has all his own hair.

More from Medium

Resolving the dpkg lock contention problem in Azure DevOps self-hosted Agents

Loading KeyVault secrets and AppSettings in to application configuration in Azure Function Apps

Azure Disk Encryption Cheatsheet

How to simulate API latency during development using Hoverfly