Does anyone know a way, and/or have sample code, to retrieve the following information from an Azure IaaS Virtual Machine implementation?
For additional context to the question, we're attempting to generate XML for DR purposes which will allow us to rebuild our IaaS implementation on a secondary data centre in the event of primary failure. We've managed to retrieve most, if not all, the information we require, but can't find a way to get the VNet(s) from the VM (or vice-versa) or the storage account(s)/container(s) for the VM's disks.
I will answer the second part of your question. That's pretty easy using powershell. suppose vm name as "testvm" and service name as "testservice". Powershell to get the storage account name-
$disk = Get-AzureVM -ServiceName "testservice" –Name "testvm" | Get-AzureOSDisk
$mediaLink = $disk.MediaLink
$storageAccountName = $mediaLink.Host.Split('.')[0]
$storageAccountName
Hope this answers your question.