Search code examples
powershellazureazure-resource-manager

Azure ARM Template and PowerShell Module


I have a module published on PowerShell Gallery and I want to deploy this module with Azure ARM Template. And I did not find how!

Here is my template:

   "resources": [
  {
     "name": "[variables('automationAccountName')]",
     "type": "Microsoft.Automation/automationAccounts",
     "apiVersion": "2015-10-31",
     "location": "[parameters('AutomationLocation')]",
     "tags": {
        "displayName": "Compte Automation"
     },
     "properties": {
        "sku": {
           "name": "Basic",
           "family": "B"
        }
     },
     "resources": [
        {
           "name": "[variables('powerShellGalleryModuleName')]",
           "type": "modules",
           "apiVersion": "2015-10-31",
           "location": "[parameters('AutomationLocation')]",
           "properties": {
              "isGlobal": false,
              "sizeInBytes": 0,
              "contentLink": {
                    "uri": "[variables('powerShellGalleryModule')]"
              }
           }
        }
     ]
  }
]

What should be provided for the variable powerShellGalleryModule?


Solution

  • I found a way to do via the PowerShellGallery

    This way :

                {
               "name": "[variables('powerShellGalleryModule')]",
               "type": "modules",
               "apiVersion": "2015-10-31",
               "location": "[parameters('AutomationLocation')]",
               "properties": {
                  "isGlobal": false,
                  "sizeInBytes": 0,
                  "contentLink": {
                     "uri": "[concat('https://www.powershellgallery.com/api/v2/package/', variables('powerShellGalleryModule'))]"
                  }
               },
               "dependsOn": [
                  "[resourceId('Microsoft.Automation/automationAccounts', variables('automationAccountName'))]"
               ]