Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

Version 1 Current »

Azure PowerShell

Azure PowerShell can be used to create and configure new virtual machines and networks in Azure. Azure PowerShell can be used from within both Windows Powershell , and from Azure Cloud Shell

Note that Azure Cloud Shell is preferable, since it is entirely cloud-based, requiring only a browser to run scripts. However, Azure Cloud Shell requires an Azure storage account in one of a specific set of regions, none of which are hosted within Canada.

Windows PowerShell

To use Azure PowerShell locally within Windows PowerShell, you must install and configure it. Refer to the instructions here on installing Azure PowerShell to run locally from Windows PowerShell.

Alternatively, you may wish to run Azure PowerShell within a Docker environment. Refer to the instructions here to run Azure PowerShell in a Docker environment.

Once Azure PowerShell is configured in your chosen environment, you can use it to automate creating Azure VMs and other resources. Refer to the Azure RM PowerShell documentation for API documentation, samples, and tutorials on automating Azure resources with Azure PowerShell.

The following console session shows an example of creating an Azure VM using Azure PowerShell.

PS C:\WINDOWS\system32> Install-Module -Name AzureRM -AllowClobber

PS C:\WINDOWS\system32> Get-Module -ListAvailable AzureRM


    Directory: C:\Program Files\WindowsPowerShell\Modules


ModuleType Version    Name                                ExportedCommands                                                                                                                    
---------- -------    ----                                ----------------                                                                                                                    
Script     6.9.0      AzureRM                                                                                                                                                                 


PS C:\WINDOWS\system32> Set-ExecutionPolicy AllSigned -Scope Process

PS C:\WINDOWS\system32> Import-Module AzureRM

PS C:\WINDOWS\system32> Connect-AzureRmAccount


Account          : jonathan.bailey@034gc.onmicrosoft.com
SubscriptionName : TC-DevTest-UC
SubscriptionId   : fde9cf97-7bf0-4373-9fbd-eba18c6e0dfc
TenantId         : 2008ffa9-c9b2-4d97-9ad9-4ace25386be7
Environment      : AzureCloud


PS C:\WINDOWS\system32> New-AzureRmVm `
    -ResourceGroupName "TC-DevTest-ArcGIS-RG" `
    -Name "TC-EGIS-DSC-3" `
    -Location "Canada Central" `
    -VirtualNetworkName "TCDevTestArcGISRGvnet776" `
    -SubnetName "default" `
    -SecurityGroupName "TC-EGIS-DSC-3" `
    -PublicIpAddressName "tc-egis-dsc-3" `
    -OpenPorts 3389
cmdlet New-AzureRmVM at command pipeline position 1
Supply values for the following parameters:


ResourceGroupName        : TC-DevTest-ArcGIS-RG
Id                       : /subscriptions/fde9cf97-7bf0-4373-9fbd-eba18c6e0dfc/resourceGroups/TC-DevTest-ArcGIS-RG/providers/Microsoft.Compute/virtualMachines/TC-EGIS-DSC-3
VmId                     : 3a2de909-8d66-4d26-8df6-ac809f41fdb0
Name                     : TC-EGIS-DSC-3
Type                     : Microsoft.Compute/virtualMachines
Location                 : canadacentral
Tags                     : {}
HardwareProfile          : {VmSize}
NetworkProfile           : {NetworkInterfaces}
OSProfile                : {ComputerName, AdminUsername, WindowsConfiguration, Secrets, AllowExtensionOperations}
ProvisioningState        : Succeeded
StorageProfile           : {ImageReference, OsDisk, DataDisks}
FullyQualifiedDomainName : tc-egis-dsc-3-f29f98.Canada Central.cloudapp.azure.com


PS C:\WINDOWS\system32> 

PowerShell DSC

PowerShell DSC (Desired State Configuration) can be used to configure Windows VMs once they are created. Esri provides documentation and sample configurations for installing and configuring ArcGIS Entperprise using PowerShell DSC.

The following steps were used to create a single-machine deployment of ArcGIS Enterprise on an Azure VM:

  1. Install 7-Zip on the machine that will run the script.

  2. Download the ArcGIS Enterprise software installation files to a local folder (in this case, D:\ was used). The required installation files include ArcGIS Server, Portal for ArcGIS, ArcGIS Data Store, and ArcGIS Web Adaptor for IIS.

  3. Download authorization files for ArcGIS Server and Portal for ArcGIS to a local folder (in this case, D:\Authorization Files was used.

  4. Start PowerShell and run the following command to install the ArcGIS module:

        Install-Module arcgis
  1. Download the SampleConfigs from GitHub to a local folder (in this case, c:\arcgis-powershell-dsc was used).

  2. Edit the SampleConfigs\Base Deployment\BaseDeployment-SingleMachine.json file and specify the parameters for the desired configuration state (note that only the values that were modified are shown here for brevity):

        {
            "AllNodes":  [
                             {
                                 "NodeName":  "TC-EGIS-DSC",
                             }
                         ],
            "ConfigData":  {
                               "Credentials":  {
                                                   "PrimarySiteAdmin":  {
                                                                            "UserName":  "EGIS",
                                                                            "Email":  "jonathan.bailey@tc.gis.ca",
                                                                            "Password":  "<password>"
                                                                        },
                                                   "ServiceAccount":  {
                                                                          "UserName":  "arcgis",
                                                                          "Password":  "<password>",
                                                                      }
                                               },
                               "Server":  {
                                              "LicenseFilePath":   "D:\\Authorization_Files\\ArcGIS Server keycodes.ecp",
                                              "Installer":  {
                                                                "Path":  "D:\\ArcGIS_Server_Windows_1061_163968.exe",
                                                                "InstallDir":  "C:\\ArcGIS\\Server",
                                                                "InstallDirPython":  "C:\\Python27",
                                                                "PatchesDir": "D:\\"
                                                            },
                                          },
                               "Portal":  {
                                              "LicenseFilePath": "D:\\Authorization_Files\\Portal for ArcGIS keycodes.ecp",
                                              "Installer":  {
                                                                "Path":  "D:\\Portal_for_ArcGIS_Windows_1061_163979.exe",
                                                                "InstallDir": "C:\\ArcGIS\\Portal",
                                                                "ContentDir": "C:\\portalforarcgis\\content",
                                                                "PatchesDir": "D:\\"
                                                            },
                                          },
                               "DataStore":  {
                                                 "ContentDirectoryLocation":  "C:\\arcgisdatastore",
                                                 "Installer":  {
                                                                   "Path":  "D:\\ArcGIS_DataStore_Windows_1061_163980.exe",
                                                                   "InstallDir":  "C:\\ArcGIS\\DataStore",
                                                                   "PatchesDir": "D:\\"
                                                               }
                                             },
                               "WebAdaptor":  {
                                                  "Installer":  {
                                                                    "Path":  "D:\\Web_Adaptor_for_Microsoft_IIS_1061_163981.exe"
                                                                }
                                              }
                           }
        }
  1. Install the deployment by running the following command in PowerShell:

    Configure-ArcGIS -ConfigurationParametersFile 'C:\arcgis-powershell-dsc\SampleConfigs\Base Deployment\BaseDeployment-SingleMachine.json'


  • No labels