The AzureRm module allows you to create, test, deploy and manage Azure resources from the command line, and for building automation scripts that work against the Azure Resource Manager.
You can use it from cloud shell or you can install in your local machine.
It is pre-loaded with cloud shell and you can manage your resources without any installation.
Launch cloud shell and execute below command to get the available resource groups.
PS Azure:> Get-AzureRmResourceGroup ResourceGroupName : cloud-shell-storage-centralindia Location : centralindia ProvisioningState : Succeeded Tags : ResourceId : /subscriptions/xxxxxxxx-xxxxx-xxxx-xxxx-xxxxxxxxx/resourceGroups/cloud-shell-storage-centralindia
To create a new resource group, execute the following command
PS Azure:> New-AzureRmResourceGroup -Name GetStartResources -Location centralindia ResourceGroupName : GetStartResources Location : centralindia ProvisioningState : Succeeded Tags : ResourceId : /subscriptions/xxxxxxxx-xxxxx-xxxx-xxxx-xxxxxxxxxx/resourceGroups/GetStartResources
Install in Local Machine
Installing modules from the Power Shell requires elevated privileges. Open Power Shell with elevated privileges (Run as Administrator) and run the following command.
PS Azure:> Install-Module -Name AzureRM -AllowClobber
The first time you use the PSGallery you see the following prompt:
Untrusted repository You are installing the modules from an untrusted repository. If you trust this repository, change its InstallationPolicy value by running the Set-PSRepository cmdlet. Are you sure you want to install the modules from 'PSGallery'? [Y] Yes [A] Yes to All [N] No [L] No to All [S] Suspend [?] Help (default is "N"):
Answer ‘Y’ or ‘A’ and hit enter to continue with the installation.
Once the installation completed, You can check the version and path with the following command.
PS C:> Get-Module AzureRM -ListAvailable | Select-Object -Property Name,Version,Path Name Version Path ---- ------- ---- AzureRM 6.13.1 C:Program FilesWindowsPowerShellModulesAzureRM6.13.1AzureRM.psd1
To connect remotely, execute below command with elevated privileges. It will prompt like above for confirmation, answer ‘Y’ or ‘A’ and hit Enter.
PS C:> Set-ExecutionPolicy RemoteSigned
The simplest way to get started is to sign in interactively at the command line.
To sign in interactively, use the Connect-AzureRmAccount cmdlet. It will open a new window to enter your login credentials to the Azure cloud.
Once successfully authenticated, you will see the above output in the command window.
PS C:> Connect-AzureRmAccount Account SubscriptionName TenantId Environment ------- ---------------- -------- ----------- firstname.lastname@example.org Pay-As-You-Go xxxxxxxx-xxxxx-xxxx-xxxx-xxxxxxxxxxxx AzureCloud
Azure cloud service offers environments compliant with regional data-handling regulations. To get the list of available environments, execute the following command.
PS C:> Get-AzureRmEnvironment | Select-Object Name Name ---- AzureChinaCloud AzureCloud AzureGermanCloud AzureUSGovernment
If your account is in the China cloud, use below command.
PS C:> Connect-AzureRmAccount -Environment AzureChinaCloud
- AzureRM Resources Cmdlets
- AzureRM Storage Account Cmdlets
- AzureRm Blob Storage Cmdlets
- AzureRM File Storage Cmdlets
- AzureRm Queue Storage Cmdlets
- AzureRm Table Storage Cmdlets
- AzureRm Virtual Disks Cmdlets
- AzureRm Virtual Network Cmdlets
- AzureRm Virtual Machine Cmdlets