简体   繁体   中英

Conditional deployment of a resource in ARM templates

I want to use the same ARM template for Pre-Production and Production environments however, Production needs few additional resources to be deployed. I understand the 'conditional' template deployment like the example below works for 'either resource A or B' but not 'A or nothing'. If that's the case, is there a workaround for deploying / not deploying a resource in ARM?

"vnetHash": {
  "new": "[concat(parameters('templateBaseUrl'),'partials/vnet-new.json')]",
  "existing": "[concat(parameters('templateBaseUrl'),'partials/vnet-existing.json')]"
}

No, you cannot do that explicitly, but you can just use 2 different templates, like in the example above, so if you want to deploy a resource or nothing, you can use template A for deploying something meaningful and template B to deploy nothing.

Example of a template doing nothing:

{
    "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
    "contentVersion": "1.0.0.0",
    "parameters": {},
    "variables": {},
    "resources": []
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM