Azure RM Templates. How to upload assets automatically with VS instead of fetching them from GitHub Azure RM Templates. How to upload assets automatically with VS instead of fetching them from GitHub azure azure

Azure RM Templates. How to upload assets automatically with VS instead of fetching them from GitHub


Do the following in your 'Azure Resource Group' project in Visual Studio:

  1. Copy the files to your project in Visual Studio using the samedirectory structure. So a DSC directory and a nestedtemplates directory withthe files that belong there.
  2. Set the files in the directories as content (azuredeploy.json is not needed, only the files you are referring to). This way the powershell script to deploy the templates will upload it to a storage account in azure.
  3. Make it possible to use files uploaded to the storage account. In this case the template that you are referring to is not using the commonnamingconvention. So you need to change it a bit:

    Change azuredeploy.json: Change the name of parameterassetLocation to _artifactsLocation.

    Second: Add a parameter_artifactsLocationSasToken as securestring. These 2 parameters will be filled automatically by the powershell script in Visual Studio.

part of the azuredeploy.json:

"parameters": {    "_artifactsLocation": {      "type": "string",      "metadata": {        "description": "The base URI where artifacts required by this template are located. When the template is deployed using the accompanying scripts, a private location in the subscription will be used and this value will be automatically generated."      }    },    "_artifactsLocationSasToken": {      "type": "securestring",      "metadata": {        "description": "The SAS token to access the storage account"      }    },
  1. Because the original azuredeploy.json is not using the _artifactsLocationSasToken parameter. You need to change all variables where the assetlocation is used. Change all variables so it uses the _artifactsLocation and add a part to use the _artifactsLocationSasToken.

one sample:

"vnetTemplateUri": "[concat(parameters('_artifactsLocation'),'/nestedtemplates/vnet.json', parameters('_artifactsLocationSasToken'))]",

After you changed all variables. You can deploy the template from Visual Studio using the resources in your project instead of from github.