0

I have a couple of storage accounts in my Azure subscription. I know my VMs are using them because when I look at the Boot diagnostics blade for those VMs in the portal, I can see a diagnostic screenshot and a serial log (apparently the storage account is where this information is held). However, I’ve looked high and low and can’t find the setting that specifies which storage account is being used by which VM.

I also tried the Powershell script mentioned in Powershell to List Azure VMs with storage account name. However, any field in the output that relates to a storage account is empty.

Can someone please point me in the right direction?

Thanks

2 Answers2

0

If you mean the storage account for the VM diagnostic, then you can get the storage account URL with the command Get-AzVM like this:

$vm = Get-AzVM -Name vmName
$vm.DiagnosticsProfile.BootDiagnostics

enter image description here

Here it shows you the URL of the storage account that stored the VM diagnostic logs, but this is the only thing you can find in the VM. If you want to get more details about the storage account, just run the command Get-AzStorageAccount.

Charles Xu
  • 29,862
  • 2
  • 22
  • 39
  • @DavidPayne The URL of the storage account already tells you which storage account the VM use. I think that's what you want. Isn't it? – Charles Xu Mar 04 '21 at 06:46
  • Hi Charles. Just to clarify my last post. The Az command did show a URL. However, it is just a bunch of random characters that don't correspond to anything that I can find when I look at the storage accounts in the Azure portal. – David Payne Mar 04 '21 at 07:08
  • @DavidPayne Of course, only when you use your custom storage account, it will show you the storage account URL, if you use the Azure managed storage account, it just shows null for the storage URL. – Charles Xu Mar 04 '21 at 07:24
  • Ahh, sounds like that's what's happening. Both of my storage accounts are managed. It seems like an odd decision on Microsoft's part to do that. I know that the storage accounts are managed but I can't think of a reason why that information shouldn't be made available. Anyway, thanks for your help. – David Payne Mar 04 '21 at 09:44
  • @DavidPayne What do you mean by saying "I can't think of a reason why that information shouldn't be made available"? What else do you want? – Charles Xu Mar 04 '21 at 09:50
  • I want to know how all of my resources are connected together. Not only is that best practice for a number of reasons, but I also want to check that I'm actually using the storage that I'm being charged for. – David Payne Mar 06 '21 at 10:44
  • @DavidPayne Read all my responses carefully. Only when you enable the boot diagnostic and use the custom storage account, then the command I provided you will show the storage account URL that your VM used. And if you want to get more details of the storage account, you need to use another command in my answer. – Charles Xu Mar 08 '21 at 01:57
  • I do understand what you're saying. That is, you can only get the associated storage account name from the properties of your VM if you use a custom storage account. If you use a managed storage account then you can't. My point is that I feel that you should be able to get this information no matter what type of storage account you create. Hence my statement "I can't think of a reason..." – David Payne Mar 09 '21 at 04:57
  • @DavidPayne It was designed. On my point, I also want to all the information about the storage account. But it's easy to understand. If you put messages other than the VM itself, then there is too much info in the VM. And the storage account is an independent resource and there are other commands to get the whole info for the storage account. Every command has their own function. – Charles Xu Mar 09 '21 at 05:28
  • @DavidPayne Any updates on this question? – Charles Xu Mar 12 '21 at 07:52
0

I actually want to know which storage account the VMs are using.

I ran the Powershell that you suggested both at my workstation and in the Azure shell console. However, even though the Enabled property returned True, nothing was returned for the StorageUri property (hopefully the image that I pasted into this reply will show this).

As per the pasted image, I also ran an Az command that did return a couple of URIs (one for the boot image and one for the serial log).

However, I don't believe that this information will lead me to discover which storage account is being used. Any other suggestion you can offer will be appreciated.

enter image description here