Cannot create VM


Not able to cannot create VM using PowerShell commands. Getting an error:

ERROR: New-AzVM : Subscription db9d3b30-6d46-4e22-9170-87b069eeaf08 was not found.


Below are the required details and script commands used to create the VM:

Subscription: db9d3b30-6d46-4e22-9170-87b069eeaf08 [PROD-SUB]

Region: East US 2

Commands used to create the Windows VM in PowerShell:

$PIP = New-AzPublicIpAddress -Name windows-jumpbox-pip -Location eastus2 -AllocationMethod Dynamic -ResourceGroupName mgmt-nodes-eastus2
$NIC = New-AzNetworkInterface -Name windows-jumpbox-nic -ResourceGroupName mgmt-nodes-eastus2 -Location eastus2 -SubnetId "/subscriptions/db9d3b30-6d46-4e22-9170-87b069eeaf08/resourceGroups/mgmt-nodes-eastus2/providers/Microsoft.Network/virtualNetworks/idrac-nodes-eastus2/subnets/idrac-vm-subnet" -PublicIpAddressId $PIP.Id
$securePassword = ConvertTo-SecureString '***************' -AsPlainText -Force
$Credential = New-Object System.Management.Automation.PSCredential ("azureuser", $securePassword);
$VirtualMachine = New-AzVMConfig -VMName windows-jumpbox -VMSize Standard_D2s_v3
$VirtualMachine = Set-AzVMOperatingSystem -VM $VirtualMachine -Windows -ComputerName "windows-jumpbox" -Credential $Credential -ProvisionVMAgent True
$VirtualMachine = Set-AzVMSourceImage -VM $VirtualMachine -PublisherName 'MicrosoftWindowsDesktop' -Offer "Windows-10" -Sku "win10-21h2-ent-g2" -Version "latest"
$VirtualMachine = Add-AzVMNetworkInterface -VM $VirtualMachine -Id $NIC.Id

New-AzVM -ResourceGroupName "mgmt-nodes-eastus2" -Location eastus2 -VM $VirtualMachine

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

2 answers

Sort by: Most helpful
  1. Mohammed Altamash Khan 2,076 Reputation points


    Kindly review your subscription ID in your azure portal .

    Also refer this :

    ------------If you find this helpful , Please accept the answer --------------

    0 comments No comments

  2. srbhatta-MSFT 8,546 Reputation points Microsoft Employee

    Hello @alex ,
    Thanks for reaching out.
    Please check which subscription you have access to by using the below command.


    The, using the below command, set your active subscription for this session using the below command.

    Set-AzContext -SubscriptionId "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX"  

    Hope this helps. Feel free to revert back if you have any questions,


    If you find the above information helpful, kindly accept as answer or upvote to increase the relevancy of this post.

    0 comments No comments