Azure offers two deployment models for cloud components: Resource Manager (RM) and Classic deployment model. Newer and more easier to manage, Microsoft recommends to use the Resource Manager.
Even if these two models can exist at the same time in Azure, they are different and managed differently: in PowerShell cmdlets are specific to RM.
In order to be able to communicate with Azure from On-Premises in PowerShell, you need to download and install the Azure PowerShell from WebPI. For more details, please refer to this Microsoft Azure post “How to install and configure Azure PowerShell“.
 
 
Azure PowerShell installs many modules located in C:Program Files (x86)Microsoft SDKsAzurePowerShell:
Get-module -ListAvailable -Name *AzureRm*
ModuleType Version    Name                                ExportedCommands
---------- -------    ----                                ----------------
Manifest   1.1.3      AzureRM.ApiManagement               {Add-AzureRmApiManagementRegion, Get-AzureRmApiManagementSsoToken, New-AzureRmApiManagementHostnam...
Manifest   1.0.11     AzureRM.Automation                  {Get-AzureRMAutomationHybridWorkerGroup, Get-AzureRmAutomationJobOutputRecord, Import-AzureRmAutom...
Binary     0.9.8      AzureRM.AzureStackAdmin             {Get-AzureRMManagedLocation, New-AzureRMManagedLocation, Remove-AzureRMManagedLocation, Set-AzureR...
Manifest   0.9.9      AzureRM.AzureStackStorage           {Add-ACSFarm, Get-ACSEvent, Get-ACSEventQuery, Get-ACSFarm...}
Manifest   1.0.11     AzureRM.Backup                      {Backup-AzureRmBackupItem, Enable-AzureRmBackupContainerReregistration, Get-AzureRmBackupContainer...
Manifest   1.1.3      AzureRM.Batch                       {Remove-AzureRmBatchAccount, Get-AzureRmBatchAccount, Get-AzureRmBatchAccountKeys, New-AzureRmBatc...
Manifest   1.0.5      AzureRM.Cdn                         {Get-AzureRmCdnCustomDomain, New-AzureRmCdnCustomDomain, Remove-AzureRmCdnCustomDomain, Get-AzureR...
Manifest   0.1.2      AzureRM.CognitiveServices           {Get-AzureRmCognitiveServicesAccount, Get-AzureRmCognitiveServicesAccountKey, Get-AzureRmCognitive...
Manifest   1.3.3      AzureRM.Compute                     {Remove-AzureRmAvailabilitySet, Get-AzureRmAvailabilitySet, New-AzureRmAvailabilitySet, Get-AzureR...
Manifest   1.0.11     AzureRM.DataFactories               {Remove-AzureRmDataFactory, Get-AzureRmDataFactoryRun, Get-AzureRmDataFactorySlice, Save-AzureRmDa...
Manifest   1.1.3      AzureRM.DataLakeAnalytics           {Get-AzureRmDataLakeAnalyticsDataSource, Remove-AzureRmDataLakeAnalyticsCatalogSecret, Set-AzureRm...
Manifest   1.0.11     AzureRM.DataLakeStore               {Add-AzureRmDataLakeStoreItemContent, Export-AzureRmDataLakeStoreItem, Get-AzureRmDataLakeStoreChi...
Manifest   1.0.2      AzureRM.DevTestLabs                 {Get-AzureRmDtlAllowedVMSizesPolicy, Get-AzureRmDtlAutoShutdownPolicy, Get-AzureRmDtlAutoStartPoli...
Manifest   1.0.11     AzureRM.Dns                         {Get-AzureRmDnsRecordSet, New-AzureRmDnsRecordConfig, Remove-AzureRmDnsRecordSet, Set-AzureRmDnsRe...
Manifest   1.1.3      AzureRM.HDInsight                   {Get-AzureRmHDInsightJob, New-AzureRmHDInsightSqoopJobDefinition, Wait-AzureRmHDInsightJob, New-Az...
Manifest   1.0.11     AzureRM.Insights                    {Add-AzureRmMetricAlertRule, Add-AzureRmLogAlertRule, Add-AzureRmWebtestAlertRule, Get-AzureRmAler...
Manifest   1.1.10     AzureRM.KeyVault                    {Get-AzureRmKeyVault, New-AzureRmKeyVault, Remove-AzureRmKeyVault, Remove-AzureRmKeyVaultAccessPol...
Manifest   1.0.7      AzureRM.LogicApp                    {Get-AzureRmIntegrationAccountAgreement, Get-AzureRmIntegrationAccountCallbackUrl, Get-AzureRmInte...
Manifest   0.9.2      AzureRM.MachineLearning             {Export-AzureRmMlWebService, Get-AzureRmMlWebServiceKeys, Import-AzureRmMlWebService, Remove-Azure...
Manifest   1.0.12     AzureRM.Network                     {Add-AzureRmApplicationGatewayBackendAddressPool, Get-AzureRmApplicationGatewayBackendAddressPool,...
Manifest   1.0.11     AzureRM.NotificationHubs            {Get-AzureRmNotificationHubsNamespaceAuthorizationRules, Get-AzureRmNotificationHubsNamespaceListK...
Manifest   1.0.11     AzureRM.OperationalInsights         {Get-AzureRmOperationalInsightsSavedSearch, Get-AzureRmOperationalInsightsSavedSearchResults, Get-...
Manifest   1.0.0      AzureRM.PowerBIEmbedded             {Remove-AzureRmPowerBIWorkspaceCollection, Get-AzureRmPowerBIWorkspaceCollection, Get-AzureRmPower...
Manifest   1.0.11     AzureRM.Profile                     {Enable-AzureRmDataCollection, Disable-AzureRmDataCollection, Remove-AzureRmEnvironment, Get-Azure...
Manifest   1.1.3      AzureRM.RecoveryServices            {Get-AzureRmRecoveryServicesBackupProperties, Get-AzureRmRecoveryServicesVault, Get-AzureRmRecover...
Manifest   1.0.3      AzureRM.RecoveryServices.Backup     {Backup-AzureRmRecoveryServicesBackupItem, Get-AzureRmRecoveryServicesBackupManagementServer, Get-...
Manifest   1.1.9      AzureRM.RedisCache                  {Reset-AzureRmRedisCache, Export-AzureRmRedisCache, Import-AzureRmRedisCache, Remove-AzureRmRedisC...
Manifest   2.0.2      AzureRM.Resources                   {Get-AzureRmADApplication, Get-AzureRmADGroupMember, Get-AzureRmADGroup, Get-AzureRmADServicePrinc...
Manifest   1.0.2      AzureRM.ServerManagement            {Install-AzureRmServerManagementGatewayProfile, Reset-AzureRmServerManagementGatewayProfile, Save-...
Manifest   1.1.10     AzureRM.SiteRecovery                {Stop-AzureRmSiteRecoveryJob, Get-AzureRmSiteRecoveryNetwork, Get-AzureRmSiteRecoveryNetworkMappin...
Manifest   1.0.11     AzureRM.Sql                         {Get-AzureRmSqlDatabaseImportExportStatus, New-AzureRmSqlDatabaseExport, New-AzureRmSqlDatabaseImp...
Manifest   1.1.3      AzureRM.Storage                     {Get-AzureRmStorageAccount, Get-AzureRmStorageAccountKey, Get-AzureRmStorageAccountNameAvailabilit...
Manifest   1.0.11     AzureRM.StreamAnalytics             {Get-AzureRmStreamAnalyticsFunction, Get-AzureRmStreamAnalyticsDefaultFunctionDefinition, New-Azur...
Manifest   1.0.11     AzureRM.Tags                        {Remove-AzureRmTag, Get-AzureRmTag, New-AzureRmTag}
Manifest   1.0.11     AzureRM.TrafficManager              {Disable-AzureRmTrafficManagerEndpoint, Enable-AzureRmTrafficManagerEndpoint, Set-AzureRmTrafficMa...
Manifest   1.0.11     AzureRM.UsageAggregates             Get-UsageAggregates
Manifest   1.1.3      AzureRM.Websites                    {Get-AzureRmAppServicePlanMetrics, New-AzureRmWebAppDatabaseBackupSetting, Restore-AzureRmWebAppBa...
 
The basic cmdlets to connect and navigate between your different Accounts or Subscriptions are located in “AzureRM.Profile” module:
PS C:> Get-Command -Module AzureRM.Profile
CommandType     Name                                               Version    Source
-----------     ----                                               -------    ------
Alias           Login-AzureRmAccount                               1.0.11     AzureRM.Profile
Alias           Select-AzureRmSubscription                         1.0.11     AzureRM.Profile
Cmdlet          Add-AzureRmAccount                                 1.0.11     AzureRM.Profile
Cmdlet          Add-AzureRmEnvironment                             1.0.11     AzureRM.Profile
Cmdlet          Disable-AzureRmDataCollection                      1.0.11     AzureRM.Profile
Cmdlet          Enable-AzureRmDataCollection                       1.0.11     AzureRM.Profile
Cmdlet          Get-AzureRmContext                                 1.0.11     AzureRM.Profile
Cmdlet          Get-AzureRmEnvironment                             1.0.11     AzureRM.Profile
Cmdlet          Get-AzureRmSubscription                            1.0.11     AzureRM.Profile
Cmdlet          Get-AzureRmTenant                                  1.0.11     AzureRM.Profile
Cmdlet          Remove-AzureRmEnvironment                          1.0.11     AzureRM.Profile
Cmdlet          Save-AzureRmProfile                                1.0.11     AzureRM.Profile
Cmdlet          Select-AzureRmProfile                              1.0.11     AzureRM.Profile
Cmdlet          Set-AzureRmContext                                 1.0.11     AzureRM.Profile
Cmdlet          Set-AzureRmEnvironment                             1.0.11     AzureRM.Profile
According to the cmdlets present in “AzureRM.Profile” module, you will be able to connect to your Azure Account(enter your credentials):
PS C:> Login-AzureRmAccount
Environment           : AzureCloud
Account               : [email protected]
TenantId              : a123456b-789b-123c-4de5-67890fg123h4
SubscriptionId        : z123456y-789x-123w-4vu5-67890ts123r4
SubscriptionName      : ** Subscription Name **
CurrentStorageAccount :
 
You can list your associated Azure Subscriptions:
Get-AzureRmSubscription
SubscriptionName      : ** Subscription Name **
SubscriptionId        : z123456y-789x-123w-4vu5-67890ts123r4
TenantId              : a123456b-789b-123c-4de5-67890fg123h4 
 
To switch your Subscription, do as follows:
Select-AzureRmSubscription -SubscriptionId z123456y-789x-123w-4vu5-67890ts123r4
Environment           : AzureCloud
Account               : [email protected]
TenantId              : a123456b-789b-123c-4de5-67890fg123h4
SubscriptionId        : z123456y-789x-123w-4vu5-67890ts123r4
SubscriptionName      : ** Subscription Name **
CurrentStorageAccount :
 
Or you can take a specific “snapshot” of your current location in Azure. It will help you to easily return to a specific context at the moment you ran the command:
PS C:> $context = Get-AzureRmContext
Environment           : AzureCloud
Account               : [email protected]
TenantId              : a123456b-789b-123c-4de5-67890fg123h4
SubscriptionId        : z123456y-789x-123w-4vu5-67890ts123r4
SubscriptionName      : ** Subscription Name **
CurrentStorageAccount :
...
PS C:> Set-AzureRmContext -Context $context
Environment           : AzureCloud
Account               : [email protected]
TenantId              : a123456b-789b-123c-4de5-67890fg123h4
SubscriptionId        : z123456y-789x-123w-4vu5-67890ts123r4
SubscriptionName      : ** Subscription Name **
CurrentStorageAccount :
 
It is also possible to list all the available Storage Account associated to your current subscriptions:
PS C:> Get-AzureRmStorageAccount | Select StorageAccountName, Location
StorageAccountName    Location
------------------    --------
semicroustillants259  westeurope
semicroustillants4007 westeurope
semicroustillants8802 westeurope
 
To see the existing blob container in each Storage Account:
PS C:> Get-AzureRmStorageAccount | Select StorageAccountName, ResourceGroupName, Location
   Blob End Point: https://dbimssql.blob.core.windows.net/
Name                 Uri                                                          LastModified
----                 ---                                                          ------------
bootdiagnostics-t... https://dbimssql.blob.core.windows.net/bootdiagnostics-ta... 30.09.2016 12:36:12 +00:00
demo                 https://dbimssql.blob.core.windows.net/demo                  05.10.2016 14:16:01 +00:00
vhds                 https://dbimssql.blob.core.windows.net/vhds                  30.09.2016 12:36:12 +00:00
   Blob End Point: https://semicroustillants259.blob.core.windows.net/
Name                 Uri                                                          LastModified
----                 ---                                                          ------------
mastervhds           https://semicroustillants259.blob.core.windows.net/master... 28.09.2016 13:41:19 +00:00
uploads              https://semicroustillants259.blob.core.windows.net/uploads   28.09.2016 13:41:19 +00:00
vhds                 https://semicroustillants259.blob.core.windows.net/vhds      28.09.2016 13:55:57 +00:00
   Blob End Point: https://semicroustillants4007.blob.core.windows.net/
Name                 Uri                                                          LastModified
----                 ---                                                          ------------
artifacts            https://semicroustillants4007.blob.core.windows.net/artif... 28.09.2016 13:59:47 +00:00
Azure infrastructure can be easily managed from On-Premises in PowerShell. In a previous post, I explained how to deploy a Virtual Machine from an Image in Azure PowerShell.
If you have remarks or advises, do not hesitate to share 😉