admin管理员组

文章数量:1296903

gives you nice linked badges like this in your README.md:

I want to provide an additional argument to the template, like a URL to a JSON file (or a JSON file base64'd).

I understand there are variables and I can provide default values to these in the template. But really I need these to be filled out at the badge link level so I don't need to create thousands of templates on Azure.

How do I add a parameter to the Deploy to Azure button?

https://learn.microsoft/en-us/azure/azure-resource-manager/templates/deploy-to-azure-button gives you nice linked badges like this in your README.md:

I want to provide an additional argument to the template, like a URL to a JSON file (or a JSON file base64'd).

I understand there are variables and I can provide default values to these in the template. But really I need these to be filled out at the badge link level so I don't need to create thousands of templates on Azure.

How do I add a parameter to the Deploy to Azure button?

Share Improve this question edited Feb 12 at 2:09 Molly 995 bronze badges asked Feb 11 at 19:09 Samuel MarksSamuel Marks 1,8922 gold badges21 silver badges30 bronze badges 2
  • Can you be a bit more specific about why using parameters would not meet your requirements? If you have them defined, your button would take your users to a screen where they can, in your use case, enter or select the JSON URL your deployment (seemingly) relies on. – esqew Commented Feb 11 at 20:14
  • I am creating a system similar to Ansible/Chef/Puppet and generating docs for each port/recipe. On the doc page I want a "Deploy to Azure" button. All that is different between each port is the port name and its configuration variables. How do I do this with the "Deploy to Azure" button or similar equivalent one-click solution? – Samuel Marks Commented Feb 11 at 22:34
Add a comment  | 

2 Answers 2

Reset to default 0

can't find a direct way to pass parameters to the ARM template via link. however, you could use Linked template to reduce the number of azuredeploy.json files for each of your deployment.

for example, create azuredeploy-case1.json like below, that use templateLink and parametersLink to reference template and params. see parametersLink which is: newStorageAccount-case1.parameters.json

{
  "$schema": "https://schema.management.azure/schemas/2019-04-01/deploymentTemplate.json#",
  "contentVersion": "1.0.0.0",
  "parameters": {},
  "variables": {},
  "resources": [
    {
      "type": "Microsoft.Resources/deployments",
      "apiVersion": "2022-09-01",
      "name": "linkedTemplate",
      "properties": {
        "mode": "Incremental",
        "templateLink": {
          "uri":"https://mystorageaccount.blob.core.windows/AzureTemplates/newStorageAccount.json",
          "contentVersion":"1.0.0.0"
        }
        "parametersLink": {
          "uri": "https://mystorageaccount.blob.core.windows/AzureTemplates/newStorageAccount-case1.parameters.json",
          "contentVersion": "1.0.0.0"
        }
      }
    }
  ],
  "outputs": {
  }
}

then you can have a second one azuredeploy-case2.json for case2. refer to parametersLink which is now: newStorageAccount-case2.parameters.json

{
  "$schema": "https://schema.management.azure/schemas/2019-04-01/deploymentTemplate.json#",
  "contentVersion": "1.0.0.0",
  "parameters": {},
  "variables": {},
  "resources": [
    {
      "type": "Microsoft.Resources/deployments",
      "apiVersion": "2022-09-01",
      "name": "linkedTemplate",
      "properties": {
        "mode": "Incremental",
        "templateLink": {
          "uri":"https://mystorageaccount.blob.core.windows/AzureTemplates/newStorageAccount.json",
          "contentVersion":"1.0.0.0"
        }
        "parametersLink": {
          "uri": "https://mystorageaccount.blob.core.windows/AzureTemplates/newStorageAccount-case2.parameters.json",
          "contentVersion": "1.0.0.0"
        }
      }
    }
  ],
  "outputs": {
  }
}

this way, at least your don't need to duplicate newStorageAccount.json template multiple times, only create a param file for each scenario.

you could use conditions as in the tutorials on the parameter use and leave it empty for the default value.

  "parameters": {
    "storageAccountName": {
      "type": "string",
      "metadata": {
         ...

"variables": {
    "effectiveStorageAccountName": " 
   [if(empty(parameters('storageAccountName')), concat('default', uniqueString(resourceGroup().id)), parameters('storageAccountName'))]"
  },

that should always ask for a parameter added

本文标签: Provide a parameter to quotDeploy to Azurequot buttonStack Overflow