Just a quickie. It’s been a long week, and I’ve been trying to get my head around using PowerShell to automate deployments in Azure.
However, I did come across a little glitch in the way that this is supposed to work.
Here’s the syntax I was using:
New-AzureVMConfig -Name $myVMName -InstanceSize $myInstanceSize -ImageName $image.ImageName ` |Add-AzureProvisioningConfig -AdminUserName $myAdminName -Password $myAdminPassword -WindowsDomain -JoinDomain $myDomainFQDN -Domain $myDomainAdminUserDomain -DomainUserName$myDomainAdminUserName -DomainPassword $myDomainAdminPassword -MachineObjectOU $myDomainMachineOU ` |Set-AzureSubnet -SubnetNames $myVLAN ` |Set-AzureStaticVNetIP -IPAddress $myVMIPAddress ` |New-AzureVM -ServiceName $myVMName -Location $myLocation -WaitForBoot -VNetName$myVirtualNetwork
When I got the error message:
VERBOSE: 09:42:11 - Begin Operation: New-AzureVM - Create Deployment with VM TRTestSQLAuto
New-AzureVM : BadRequest: The virtual network SSDevPortal does not exist.
At line:6 char:10
+ |New-AzureVM -ServiceName $myVMName -Location $myLocation -WaitForBoot - ...
+ CategoryInfo : CloseError: (:) [New-AzureVM], CloudException
+ FullyQualifiedErrorId : Microsoft.WindowsAzure.Commands.ServiceManagement.IaaS.PersistentVMs.NewAzureVMCommand
Now, the problem here is that when I look at the virtual network in the Admin Preview Portal, I see that it is there with the right name.
So, what to do? Just to check that I’d managed to get the spelling right, and there wasn’t a space or something, I exported the network config and looked at the XML:
Get-AzureVNetConfig -ExportToFile "C:\Users\TRushton\Desktop\VNetConfig.xml"
And there it is, buried in the
NetworkConfiguration\VirtualNetworkConfiguration\VirtualNetworkSites area, the
VirtualNetworkSite in question:
So, the name in the configuration is not the name that's showing in the Virtual Network window. No wonder it's not working...
Correct the code, and away we go. Job done. But no idea why there's a discrepancy.