0
votes

My current script to create vm in ARM or classic mode does not work; I get an error: New-AzureVM : ResourceNotFound: The hosted service does not exist.

can someone please share the powershell script to create new VM in AzureGovernment subscription? my script:

Set-AzureEnvironment "AzureGovernment"

New-AzureVMConfig -Name "test1" -InstanceSize "Standard_D14" `
                  -ImageName "myimage" | 
                   Add-AzureProvisioningConfig –Linux `
                  –LinuxUser "myuser" -Password "mypwd" | 
                   New-AzureVM –ServiceName "myservice"

I am able to create a new VM using Azure portal, but fail with powershell

1
Did you run Add-AzureEnvironment before Set? as this would set up the endpoints for youMichael B
yes:add-AzureEnvironment -name "AzureGovernment" -PublishSettingsFileUrl "manage.windowsazure.us/publishsettings/index?client=xplat" -serviceendpoint "management.core.usgovcloudapi.net" -managementportalurl "manage.windowsazure.us" -StorageEndpoint “core.usgovcloudapi.net”SBC
I noticed that, when I do get-AzureVM, I get services associated with other subscription; how do I reset it? select-AzureSubscription doesn't workSBC

1 Answers

0
votes

You can use the following to connect to Azure Government with PowerShell:

https://docs.microsoft.com/en-us/azure/azure-government/documentation-government-get-started-connect-with-ps

From there, the VM creation. One other caveat is that the region names are different. Make sure that you are using one of the region/locations in the document.