New-AzVm fails with 'The subscription is not authorized' error

A.M. Sabuncu 31 Reputation points
2024-05-10T07:00:01.3066667+00:00

I have the following command:

New-AzVm -ResourceGroupName 'vs2022rg'
-Name 'vs2022vm'
-Location 'swedencentral'
-Image 'MicrosoftVisualStudio:visualstudio2022:vs-2022-comm-latest-win11-n-gen2:2024.04.15'
-VirtualNetworkName 'vs2022vnet'
-SubnetName 'vs2022subnet'
-SecurityGroupName 'vs2022sg'
-PublicIpAddressName 'vs2022pip'
-OpenPorts 80,3389

When I run it, I get 'New-AzVm : The subscription is not authorized.' error:

2024-05-10 094920 - powershell

I am pretty sure the image URN is correct, as I put it together by querying each of its components. That is, I did not copy/paste a random URN.

I also made sure that the image does not have a purchase plan:

> az vm image terms show --urn 'MicrosoftVisualStudio:visualstudio2022:vs-2022-comm-latest-win11-n-gen2:2024.04.15'

Image 'MicrosoftVisualStudio:visualstudio2022:vs-2022-comm-latest-win11-n-gen2:2024.04.15' has no terms to accept.

I am able to successfully create VMs from my own custom images that reside in my resource groups, so I don't think there's any problem with my subscription.

Note: I have had problems deploying Visual Studio images from the portal as well, so I can't export a successfully deployed VM from the portal to look into its template and see how it's been created.

2024-05-09 114042 - firefox

Azure Virtual Machines
Azure Virtual Machines
An Azure service that is used to provision Windows and Linux virtual machines.
7,252 questions
{count} votes