azurepowershellazure-storageazure-managed-identityazure-vm

Accessing Azure Storage from VM using Managed Identity


I am trying to access an Azure Storage resource from an Azure Windows VM using a Managed Identity.

I have followed the instructions here https://learn.microsoft.com/en-us/azure/active-directory/managed-identities-azure-resources/tutorial-vm-windows-access-storage but the Access section in the tutorial is done using .NET, which I'm unfamiliar with.

Instead, I would like to list the content of the blob using a combination of Powershell and Managed Identity from the VM, as this fits my use case. Is this possible, because I can't seem to find any example online? If it is, does anyone have a working example please?

Thanks in advance.


Solution

  • I believe you have fulfilled all the prerequisites

    To access the content of the blob using Powershell you can use following commands:

    Connect-AzAccount -Identity
    #Get blobs in a container by using the pipeline
    Get-AzStorageContainer -Name container* | Get-AzStorageBlob -IncludeDeleted
    

    https://learn.microsoft.com/en-us/powershell/module/az.accounts/connect-azaccount?view=azps-7.4.0 https://learn.microsoft.com/en-us/powershell/module/az.storage/get-azstorageblob?view=azps-7.4.0