Azure drive (AzurePSDrive) is a custom PowerShell provider written with the Simple Hierarchy in PowerShell (SHiPS) module, mountable with the New-PSDrive cmdlet. The SHiPS module has the capability to convert any information store or system into a hierarchy tree accessible like a file system. It converts Azure Resource Manager (AzureRM) resource items to a SHiPS-based drive for easy navigation and discovery through your cloud shell.

When you log on to the Azure Portal, you'll see an Azure Cloud Shell icon in the top-right corner. If you click that, it will launch a browser-based shell also known as Azure Cloud Shell. One peculiar thing you'll notice is that it automatically mounts you to an Azure drive.

Launching Azure Cloud Shell

Launching Azure Cloud Shell


Mounting an Azure drive ^

Azure drive is not only limited to Azure Cloud Shell. You can mount it on any PowerShell console on any local machine independent of the platform. This enables you to access your AzureRM items from the comfort of a local PowerShell session.

To mount your Azure subscription and resources as a local file system, you first have to install the AzurePSDrive module from the PowerShell gallery by running the below command from a PowerShell console launched as an administrator:

Import-Module AzurePSDrive, SHiPS –Force

This will also install all dependent modules such as SHiPS, AzureRM.Profile, and AzureRM.Compute on your local machine. Once the installation is complete, you need to log in to AzureRM:

Login-AzureRmAccount

This will launch a form where you have to provide the credentials of your Azure subscription.

Log in to Azure Resource Manager

Log in to Azure Resource Manager

This will authenticate your current PowerShell session with AzureRM credentials and output your subscription details to the console.

Successful Azure login

Successful Azure login

After authentication, import AzurePSDrive into the current session and use the following commands to mount it as a SHiPS-based PowerShell drive:

$param = @{
    Name = 'Azure'
    PSProvider = 'SHiPS'
    Root = 'AzurePSDrive#Azure'
    Scope = 'Global'
}
New-PSDrive @Param
Creating a new AzurePSDrive

Creating a new AzurePSDrive

Navigating AzureRM resources ^

Once you've created a new PowerShell drive using the AzurePSDrive module, you can access it by changing you current working directory. You can then start navigating your AzureRM resources just like you do from your Azure Cloud Shell but this time from a local PowerShell console.

Subscribe to 4sysops newsletter!

# Access the Azure PSDrive
Set-Location -Path Azure:
# List AzureRM subscriptions
Get-ChildItem
# Change directory to your subscription
cd .\Pay-As-You-Go\
# List AzureRM resources
Get-ChildItem .\WebApps\
Get-ChildItem .\VirtualMachines\
Access and navigate the Azure drive

Access and navigate the Azure drive

Conclusion ^

Mounting an Azure drive on your local machine allows you to browse Azure resources such as Compute, Network, WebApps, and Storage, and seamlessly discover useful Azure data. Because Azure PSDrive is based on AzureRM cmdlets, you can also perform operations on your Azure resources you discover while navigating the Azure drive from the ease of your local PowerShell console.

avatar
0 Comments

Leave a reply

Please enclose code in pre tags

Your email address will not be published. Required fields are marked *

*

© 4sysops 2006 - 2021

CONTACT US

Please ask IT administration questions in the forums. Any other messages are welcome.

Sending

Log in with your credentials

or    

Forgot your details?

Create Account