{"id":3551,"date":"2017-09-07T00:00:00","date_gmt":"2017-09-07T00:00:00","guid":{"rendered":"https:\/\/azure.microsoft.com\/blog\/create-flexible-arm-templates-using-conditions-and-logical-functions"},"modified":"2025-06-24T05:40:07","modified_gmt":"2025-06-24T12:40:07","slug":"create-flexible-arm-templates-using-conditions-and-logical-functions","status":"publish","type":"post","link":"https:\/\/azure.microsoft.com\/en-us\/blog\/create-flexible-arm-templates-using-conditions-and-logical-functions\/","title":{"rendered":"Create flexible ARM templates using conditions and logical functions"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">In this blog post, I will walk you through some of the new capabilities we have in our template language expressions for Azure Resource Manager templates.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"background\">Background<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">A common ask from customers is, \u201chow can we use conditions in our ARM templates, so if a user selects parameter A, then resource A is created. If not, resource B should be created?\u201d.&nbsp; The only way you could achieve this, would be by using nested templates and have a mainTemplate to manipulate the deployment graph.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">A common pattern can be seen below, where the user will select either&nbsp;<em>new<\/em>&nbsp;or&nbsp;<em>existing<\/em>.<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; auto-links: false; gutter: false; title: ; quick-code: false; notranslate\" title=\"\">\n{\n    \"$schema\": \"https:\/\/schema.management.azure.com\/schemas\/2015-01-01\/deploymentTemplate.json#\",\n    \"contentVersion\": \"1.0.0.0\",\n    \"parameters\": {\n        \"newOrExisting\": {\n            \"type\": \"String\",\n            \"allowedValues\": [\n                \"new\",\n                \"existing\"\n            ]\n        }\n    },\n    \"variables\": {\n        \"templatelink\": \"[concat('https:\/\/raw.githubusercontent.com\/krnese\/ARM\/master\/', concat(parameters('newOrExisting'),'StorageAccount.json'))]\"\n    },\n    \"resources\": [\n        {\n            \"apiVersion\": \"2017-05-10\",\n            \"name\": \"nestedTemplate\",\n            \"type\": \"Microsoft.Resources\/deployments\",\n            \"properties\": {\n                \"mode\": \"incremental\",\n                \"templateLink\": {\n                    \"uri\": \"[variables('templatelink')]\",\n                    \"contentVersion\": \"1.0.0.0\"\n                },\n                ...\n<\/pre><\/div>\n\n\n<p class=\"wp-block-paragraph\">In the variables declaration, the link to the template is constructed based on the parameter input.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The example shows that the URI to the template will either be<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; auto-links: false; gutter: false; title: ; quick-code: false; notranslate\" title=\"\">\nhttps:\/\/raw.githubusercontent.com\/krnese\/ARM\/master\/newStorageAccount.json\n<\/pre><\/div>\n\n\n<p class=\"wp-block-paragraph\">or <\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; auto-links: false; gutter: false; title: ; quick-code: false; notranslate\" title=\"\">\nhttps:\/\/raw.githubusercontent.com\/krnese\/ARM\/master\/existingStorageAccount.json\n<\/pre><\/div>\n\n\n<p class=\"wp-block-paragraph\">This approach does work and you&nbsp;will have a successful deployment of the template, regardless whether the user selected&nbsp;<em>new<\/em>&nbsp;or&nbsp;<em>existing<\/em>&nbsp;in the parameter selection. However, the approach of having nested templates could indeed lead to many templates over time. Where some of the templates&nbsp;ended up being completely empty just to avoid having a failure in the deployment graph. Further, the complexity would grow as you would normally use other resource types \u2013 besides a storage account, and potentially have multiple conditions involved.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Another technique that also was frequently used, was to manipulate complex variables based on input parameters to determine certain properties for a resource. The example below shows how ARM could navigate within the complex variables to either create Linux or Windows virtual machines, based on the parameter platform, which allowed&nbsp;<em>Windows<\/em>&nbsp;or&nbsp;<em>Linux<\/em>&nbsp;as input.<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; auto-links: false; gutter: false; title: ; quick-code: false; notranslate\" title=\"\">\n\"osType\": \"[variables(concat('osType',parameters('platform')))]\",        \n        \"osTypeWindows\": {\n            \"imageOffer\": \"WindowsServer\",\n            \"imageSku\": \"2016-Datacenter\",\n            \"imagepublisher\": \"MicrosoftWindowsServer\"\n        },\n        \"osTypeLinux\": {\n            \"imageOffer\": \"UbuntuServer\",\n            \"imageSku\": \"12.04.5-LTS\",\n            \"imagepublisher\": \"Canonical\"\n        },\n\n<\/pre><\/div>\n\n\n<p class=\"wp-block-paragraph\">Needless to say, we have heard from customers that this should be simplified, so that the template language should support and handle conditions more easily.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"introducing-support-for-conditions\">Introducing support for conditions<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">As we always appreciate the feedback from our customers, we are glad to remind you (announced at \/\/BUILD this year) we have added support for conditions on resources, as well as many more capabilities.&nbsp;These include&nbsp;<a href=\"https:\/\/docs.microsoft.com\/en-us\/azure\/azure-resource-manager\/resource-group-template-functions-logical\">logical<\/a>&nbsp;and&nbsp;<a href=\"https:\/\/docs.microsoft.com\/en-us\/azure\/azure-resource-manager\/resource-group-template-functions-comparison\">comparison<\/a>&nbsp;functions that can be used in the template language when handling conditions.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">I will show a practical example of how the new capabilities can be leveraged in ARM templates. A typical example today, where you want your users to select whether a virtual machine should be Windows or Linux based, would require a complex variable being manipulated as demonstrated earlier in this blog post. In addition, if your user needs to decide if the virtual machine should go into production or not, by having an availability set as an optional resource would require nested templates that either deployed the resource or&nbsp;are empty.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">In total, this would require at least 3 templates (remember that 2 of them would be nested templates).<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">By using conditions and functions, we can now accomplish this with a single template! Not to mention a lot less JSON. Let\u2019s start by walking through some of the parameters we are using in the sample template, and explain the steps we have taken.<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; auto-links: false; gutter: false; title: ; quick-code: false; notranslate\" title=\"\">\n\"parameters\": {\n        \"vmNamePrefix\": {\n            \"type\": \"string\",\n            \"defaultValue\": \"VM\",\n            \"metadata\": {\n                \"description\": \"Assign a prefix for the VM you will create.\"\n            }\n        },\n        \"production\": {\n            \"type\": \"string\",\n            \"allowedValues\": [\n                \"Yes\",\n                \"No\"\n            ],\n            \"metadata\": {\n                \"description\": \"Select whether the VM should be in production or not.\"\n            }\n        },\n        \"platform\": {\n            \"type\": \"string\",\n            \"allowedValues\": [\n                \"WinSrv\",\n                \"Linux\"\n            ],\n            \"metadata\": {\n                \"description\": \"Select the OS type to deploy.\"\n            }\n        },\n        \"pwdOrssh\": {\n            \"type\": \"securestring\",\n            \"metadata\": {\n                \"description\": \"If Windows, specify the password for the OS username. If Linux, provide the SSH.\"\n            }\n        },\n<\/pre><\/div>\n\n\n<p class=\"wp-block-paragraph\">Besides assigning the virtual machine a prefix, we also have parameters for&nbsp;<em>production<\/em>&nbsp;and&nbsp;<em>platform<\/em>.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">For production, the user can simply select&nbsp;<em>yes<\/em>&nbsp;or&nbsp;<em>no<\/em>. For&nbsp;<em>yes,&nbsp;<\/em>we want to ensure that the virtual machine being created gets associated with an availability set, since this resource needs to be in place prior to the virtual machine creation process. To support this, we have added the following resource to the template:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; auto-links: false; gutter: false; title: ; quick-code: false; notranslate\" title=\"\">\n{\n            \"condition\": \"[equals(parameters('production'), 'Yes')]\",\n            \"type\": \"Microsoft.Compute\/availabilitySets\",\n            \"apiVersion\": \"2017-03-30\",\n            \"name\": \"[variables('availabilitySetName')]\",\n            \"location\": \"[resourceGroup().location]\",\n            \"properties\": {\n                \"platformFaultDomainCount\": 2,\n                \"platformUpdateDomainCount\": 3\n            },\n            \"sku\": {\n                \"name\": \"Aligned\"\n            }\n        },\n<\/pre><\/div>\n\n\n<p class=\"wp-block-paragraph\">Note the&nbsp;<em>condition<\/em>&nbsp;property. We are using a comparison function, equals(arg1, arg2), which will check whether two values equal each other. In this case, if the parameter&nbsp;<em>production<\/em>&nbsp;equals&nbsp;<em>yes<\/em>, ARM will process this resource during runtime. If not true (<em>No&nbsp;<\/em>being selected), it will not be provisioned.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">For the virtual machine resource in our template, we have declared the reference to the availability set based on the condition we introduced.<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; auto-links: false; gutter: false; title: ; quick-code: false; notranslate\" title=\"\">\n\"properties\": {\n                \"availabilitySet\": \"[if(equals(parameters('production'), 'Yes'), variables('availabilitySetId'), json('null'))]\",\n\n<\/pre><\/div>\n\n\n<p class=\"wp-block-paragraph\">We\u2019re using if() which is one of our logical functions. This function takes three arguments. The first is the condition (Boolean), which is the value to check whether it is true or false. The second argument will be the true value, followed by the third argument which is false. The net result of this, would be to associate the virtual machine. When the user selects&nbsp;<em>yes<\/em>&nbsp;for the&nbsp;<em>production<\/em>&nbsp;parameter, then the virtual machine will get associated with the availability set declared in our template, which has already been created due to the condition. If the user selects&nbsp;<em>no<\/em>, the availability set won\u2019t be created, hence there won\u2019t be any association from the virtual machine resource.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">We also have a parameter platform which decides if we are creating a Windows or Linux virtual machine. To simplify the language expression throughout the template, we added the values for Linux and Windows into our variables section.<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; auto-links: false; gutter: false; title: ; quick-code: false; notranslate\" title=\"\">\n\"windowsOffer\": \"WindowsServer\",\n        \"windowsSku\": \"2016-Datacenter\",\n        \"windowsPublisher\": \"MicrosoftWindowsServer\",\n        \"linuxOffer\": \"UbuntuServer\",\n        \"linuxSku\": \"12.04.5-LTS\",\n        \"linuxPublisher\": \"Canonical\",\n\n<\/pre><\/div>\n\n\n<p class=\"wp-block-paragraph\">On the virtual machine resource, more specifically within the storageProfile section where we distinguish between the image being used, we are referring to our variables for Windows or Linux.<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; auto-links: false; gutter: false; title: ; quick-code: false; notranslate\" title=\"\">\n\"storageProfile\": {\n                    \"imageReference\": {\n                        \"publisher\": \"[if(equals(parameters('platform'), 'WinSrv'), variables('windowsPublisher'), variables('linuxPublisher'))]\",\n                        \"offer\": \"[if(equals(parameters('platform'), 'WinSrv'), variables('windowsOffer'), variables('linuxOffer'))]\",\n                        \"version\": \"latest\",\n                        \"sku\": \"[if(equals(parameters('platform'), 'WinSrv'), variables('windowsSku'), variables('linuxSku'))]\"\n                    },\n\n<\/pre><\/div>\n\n\n<p class=\"wp-block-paragraph\">If a user selects&nbsp;<em>WinSrv&nbsp;<\/em>for the&nbsp;<em>platform<\/em>&nbsp;parameter, we will grab the values for the variables pointing to the Windows image. If not and&nbsp;<em>Linux<\/em>&nbsp;is selected, we refer to those variables instead. The result would either be a virtual machine using Windows Server 2016 or Ubuntu.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Last but not least, we also have our output section in the template, which will provide the user with some instructions based on their selection.<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; auto-links: false; gutter: false; title: ; quick-code: false; notranslate\" title=\"\">\n\"outputs\": {\n        \"vmEndpoint\": {\n            \"type\": \"string\",\n            \"value\": \"[reference(concat(variables('pNicName'))).dnsSettings.fqdn]\"\n        },\n        \"platform\": {\n            \"type\": \"string\",\n            \"value\": \"[parameters('platform')]\"\n        },\n        \"connectionInfo\": {\n            \"type\": \"string\",\n            \"value\": \"[if(equals(parameters('platform'), 'WinSrv'), 'Use RDP to connect to the VM', 'Use SSH to connect to the VM')]\"\n        }\n    }\n<\/pre><\/div>\n\n\n<p class=\"wp-block-paragraph\">If the user deploys a Windows Server, they will see the following output:<\/p>\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" src=\"https:\/\/azure.microsoft.com\/en-us\/blog\/wp-content\/uploads\/2017\/09\/2fa884b2-e033-4ca8-b2e3-ae245af2e2fc.webp\" alt=\"text\" class=\"wp-image-10968 webp-format\" data-orig-src=\"https:\/\/azure.microsoft.com\/en-us\/blog\/wp-content\/uploads\/2017\/09\/2fa884b2-e033-4ca8-b2e3-ae245af2e2fc.webp\"><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">If the user deploys Linux, they will see this:<\/p>\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" src=\"https:\/\/azure.microsoft.com\/en-us\/blog\/wp-content\/uploads\/2017\/09\/8e44fd52-fc9d-44ee-b7e1-63d92748e3c4.webp\" alt=\"text\" class=\"wp-image-10970 webp-format\" data-orig-src=\"https:\/\/azure.microsoft.com\/en-us\/blog\/wp-content\/uploads\/2017\/09\/8e44fd52-fc9d-44ee-b7e1-63d92748e3c4.webp\"><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"summary\">Summary<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">We believe, by introducing support for conditions on the resources you declare in your templates and enhancements to the template language itself with logical and comparison functions, we have set the scene for much simpler templates. You can now move away from the workarounds you previously had when implementing conditions, and should hopefully achieve much more flexibility while deploying complex apps, resources, and topologies in Azure.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><a href=\"https:\/\/gist.github.com\/krnese\/59f3f2668ecd9b02402bf31bbc6bf253\">The full template is available here<\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In this blog post, I will walk you through some of the new capabilities we have in our template language expressions for Azure Resource Manager templates.<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"ms_queue_id":[],"ep_exclude_from_search":false,"_classifai_error":"","_classifai_text_to_speech_error":"","_alt_title":"","footnotes":"","msx_community_cta_settings":[]},"categories":[1482],"tags":[],"audience":[3054,3053],"content-type":[],"product":[1534],"tech-community":[],"topic":[],"coauthors":[1038],"class_list":["post-3551","post","type-post","status-publish","format-standard","hentry","category-management-and-governance","audience-business-decision-makers","audience-it-decision-makers","product-azure-resource-manager","review-flag-1680286581-295","review-flag-1680286584-658","review-flag-1-1680286581-825","review-flag-2-1680286581-601","review-flag-3-1680286581-173","review-flag-5-1680286581-950","review-flag-alway-1680286580-106","review-flag-new-1680286579-546","review-flag-vm-1680286585-143"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.2 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Create flexible ARM templates using conditions and logical functions | Microsoft Azure Blog<\/title>\n<meta name=\"description\" content=\"In this blog post, I will walk you through some of the new capabilities we have in our template language expressions for Azure Resource Manager templates.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/azure.microsoft.com\/en-us\/blog\/create-flexible-arm-templates-using-conditions-and-logical-functions\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Create flexible ARM templates using conditions and logical functions | Microsoft Azure Blog\" \/>\n<meta property=\"og:description\" content=\"In this blog post, I will walk you through some of the new capabilities we have in our template language expressions for Azure Resource Manager templates.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/azure.microsoft.com\/en-us\/blog\/create-flexible-arm-templates-using-conditions-and-logical-functions\/\" \/>\n<meta property=\"og:site_name\" content=\"Microsoft Azure Blog\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/microsoftazure\" \/>\n<meta property=\"article:published_time\" content=\"2017-09-07T00:00:00+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2025-06-24T12:40:07+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/azure.microsoft.com\/en-us\/blog\/wp-content\/uploads\/2017\/09\/2fa884b2-e033-4ca8-b2e3-ae245af2e2fc.png\" \/>\n<meta name=\"author\" content=\"Kristian Nese\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@azure\" \/>\n<meta name=\"twitter:site\" content=\"@azure\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Kristian Nese\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"5 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/azure.microsoft.com\/en-us\/blog\/create-flexible-arm-templates-using-conditions-and-logical-functions\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/azure.microsoft.com\/en-us\/blog\/create-flexible-arm-templates-using-conditions-and-logical-functions\/\"},\"author\":[{\"@id\":\"https:\/\/azure.microsoft.com\/en-us\/blog\/author\/kristian-nese\/\",\"@type\":\"Person\",\"@name\":\"Kristian Nese\"}],\"headline\":\"Create flexible ARM templates using conditions and logical functions\",\"datePublished\":\"2017-09-07T00:00:00+00:00\",\"dateModified\":\"2025-06-24T12:40:07+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/azure.microsoft.com\/en-us\/blog\/create-flexible-arm-templates-using-conditions-and-logical-functions\/\"},\"wordCount\":1048,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/azure.microsoft.com\/en-us\/blog\/#organization\"},\"image\":{\"@id\":\"https:\/\/azure.microsoft.com\/en-us\/blog\/create-flexible-arm-templates-using-conditions-and-logical-functions\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/azure.microsoft.com\/en-us\/blog\/wp-content\/uploads\/2017\/09\/2fa884b2-e033-4ca8-b2e3-ae245af2e2fc.png\",\"articleSection\":[\"Management and governance\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/azure.microsoft.com\/en-us\/blog\/create-flexible-arm-templates-using-conditions-and-logical-functions\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/azure.microsoft.com\/en-us\/blog\/create-flexible-arm-templates-using-conditions-and-logical-functions\/\",\"url\":\"https:\/\/azure.microsoft.com\/en-us\/blog\/create-flexible-arm-templates-using-conditions-and-logical-functions\/\",\"name\":\"Create flexible ARM templates using conditions and logical functions | Microsoft Azure Blog\",\"isPartOf\":{\"@id\":\"https:\/\/azure.microsoft.com\/en-us\/blog\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/azure.microsoft.com\/en-us\/blog\/create-flexible-arm-templates-using-conditions-and-logical-functions\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/azure.microsoft.com\/en-us\/blog\/create-flexible-arm-templates-using-conditions-and-logical-functions\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/azure.microsoft.com\/en-us\/blog\/wp-content\/uploads\/2017\/09\/2fa884b2-e033-4ca8-b2e3-ae245af2e2fc.png\",\"datePublished\":\"2017-09-07T00:00:00+00:00\",\"dateModified\":\"2025-06-24T12:40:07+00:00\",\"description\":\"In this blog post, I will walk you through some of the new capabilities we have in our template language expressions for Azure Resource Manager templates.\",\"breadcrumb\":{\"@id\":\"https:\/\/azure.microsoft.com\/en-us\/blog\/create-flexible-arm-templates-using-conditions-and-logical-functions\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/azure.microsoft.com\/en-us\/blog\/create-flexible-arm-templates-using-conditions-and-logical-functions\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/azure.microsoft.com\/en-us\/blog\/create-flexible-arm-templates-using-conditions-and-logical-functions\/#primaryimage\",\"url\":\"https:\/\/azure.microsoft.com\/en-us\/blog\/wp-content\/uploads\/2017\/09\/2fa884b2-e033-4ca8-b2e3-ae245af2e2fc.webp\",\"contentUrl\":\"https:\/\/azure.microsoft.com\/en-us\/blog\/wp-content\/uploads\/2017\/09\/2fa884b2-e033-4ca8-b2e3-ae245af2e2fc.webp\",\"width\":605,\"height\":110,\"caption\":\"text\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/azure.microsoft.com\/en-us\/blog\/create-flexible-arm-templates-using-conditions-and-logical-functions\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Blog home\",\"item\":\"https:\/\/azure.microsoft.com\/en-us\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Management and governance\",\"item\":\"https:\/\/azure.microsoft.com\/en-us\/blog\/category\/management-and-governance\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Create flexible ARM templates using conditions and logical functions\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/azure.microsoft.com\/en-us\/blog\/#website\",\"url\":\"https:\/\/azure.microsoft.com\/en-us\/blog\/\",\"name\":\"Microsoft Azure Blog\",\"description\":\"Get the latest Azure news, updates, and announcements from the Azure blog. From product updates to hot topics, hear from the Azure experts.\",\"publisher\":{\"@id\":\"https:\/\/azure.microsoft.com\/en-us\/blog\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/azure.microsoft.com\/en-us\/blog\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/azure.microsoft.com\/en-us\/blog\/#organization\",\"name\":\"Microsoft Azure Blog\",\"url\":\"https:\/\/azure.microsoft.com\/en-us\/blog\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/azure.microsoft.com\/en-us\/blog\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/azure.microsoft.com\/en-us\/blog\/wp-content\/uploads\/2024\/06\/microsoft_logo.webp\",\"contentUrl\":\"https:\/\/azure.microsoft.com\/en-us\/blog\/wp-content\/uploads\/2024\/06\/microsoft_logo.webp\",\"width\":512,\"height\":512,\"caption\":\"Microsoft Azure Blog\"},\"image\":{\"@id\":\"https:\/\/azure.microsoft.com\/en-us\/blog\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/microsoftazure\",\"https:\/\/x.com\/azure\",\"https:\/\/www.instagram.com\/microsoftdeveloper\/\",\"https:\/\/www.linkedin.com\/company\/16188386\",\"https:\/\/www.youtube.com\/user\/windowsazure\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/azure.microsoft.com\/en-us\/blog\/#\/schema\/person\/c702e5edd662b328b49b7e1180cab117\",\"name\":\"shakir\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/secure.gravatar.com\/avatar\/9342c7c05bb16548741bc5cd3a3e3b7ee0c8e746844ad2cc582db5beb5514c6f?s=96&d=mm&r=g7664e653ea371ce16eaf75e9fa8952c4\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/9342c7c05bb16548741bc5cd3a3e3b7ee0c8e746844ad2cc582db5beb5514c6f?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/9342c7c05bb16548741bc5cd3a3e3b7ee0c8e746844ad2cc582db5beb5514c6f?s=96&d=mm&r=g\",\"caption\":\"shakir\"},\"sameAs\":[\"https:\/\/azure.microsoft.com\"],\"url\":\"https:\/\/azure.microsoft.com\/en-us\/blog\/author\/shakir\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Create flexible ARM templates using conditions and logical functions | Microsoft Azure Blog","description":"In this blog post, I will walk you through some of the new capabilities we have in our template language expressions for Azure Resource Manager templates.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/azure.microsoft.com\/en-us\/blog\/create-flexible-arm-templates-using-conditions-and-logical-functions\/","og_locale":"en_US","og_type":"article","og_title":"Create flexible ARM templates using conditions and logical functions | Microsoft Azure Blog","og_description":"In this blog post, I will walk you through some of the new capabilities we have in our template language expressions for Azure Resource Manager templates.","og_url":"https:\/\/azure.microsoft.com\/en-us\/blog\/create-flexible-arm-templates-using-conditions-and-logical-functions\/","og_site_name":"Microsoft Azure Blog","article_publisher":"https:\/\/www.facebook.com\/microsoftazure","article_published_time":"2017-09-07T00:00:00+00:00","article_modified_time":"2025-06-24T12:40:07+00:00","og_image":[{"url":"https:\/\/azure.microsoft.com\/en-us\/blog\/wp-content\/uploads\/2017\/09\/2fa884b2-e033-4ca8-b2e3-ae245af2e2fc.png","type":"","width":"","height":""}],"author":"Kristian Nese","twitter_card":"summary_large_image","twitter_creator":"@azure","twitter_site":"@azure","twitter_misc":{"Written by":"Kristian Nese","Est. reading time":"5 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/azure.microsoft.com\/en-us\/blog\/create-flexible-arm-templates-using-conditions-and-logical-functions\/#article","isPartOf":{"@id":"https:\/\/azure.microsoft.com\/en-us\/blog\/create-flexible-arm-templates-using-conditions-and-logical-functions\/"},"author":[{"@id":"https:\/\/azure.microsoft.com\/en-us\/blog\/author\/kristian-nese\/","@type":"Person","@name":"Kristian Nese"}],"headline":"Create flexible ARM templates using conditions and logical functions","datePublished":"2017-09-07T00:00:00+00:00","dateModified":"2025-06-24T12:40:07+00:00","mainEntityOfPage":{"@id":"https:\/\/azure.microsoft.com\/en-us\/blog\/create-flexible-arm-templates-using-conditions-and-logical-functions\/"},"wordCount":1048,"commentCount":0,"publisher":{"@id":"https:\/\/azure.microsoft.com\/en-us\/blog\/#organization"},"image":{"@id":"https:\/\/azure.microsoft.com\/en-us\/blog\/create-flexible-arm-templates-using-conditions-and-logical-functions\/#primaryimage"},"thumbnailUrl":"https:\/\/azure.microsoft.com\/en-us\/blog\/wp-content\/uploads\/2017\/09\/2fa884b2-e033-4ca8-b2e3-ae245af2e2fc.png","articleSection":["Management and governance"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/azure.microsoft.com\/en-us\/blog\/create-flexible-arm-templates-using-conditions-and-logical-functions\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/azure.microsoft.com\/en-us\/blog\/create-flexible-arm-templates-using-conditions-and-logical-functions\/","url":"https:\/\/azure.microsoft.com\/en-us\/blog\/create-flexible-arm-templates-using-conditions-and-logical-functions\/","name":"Create flexible ARM templates using conditions and logical functions | Microsoft Azure Blog","isPartOf":{"@id":"https:\/\/azure.microsoft.com\/en-us\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/azure.microsoft.com\/en-us\/blog\/create-flexible-arm-templates-using-conditions-and-logical-functions\/#primaryimage"},"image":{"@id":"https:\/\/azure.microsoft.com\/en-us\/blog\/create-flexible-arm-templates-using-conditions-and-logical-functions\/#primaryimage"},"thumbnailUrl":"https:\/\/azure.microsoft.com\/en-us\/blog\/wp-content\/uploads\/2017\/09\/2fa884b2-e033-4ca8-b2e3-ae245af2e2fc.png","datePublished":"2017-09-07T00:00:00+00:00","dateModified":"2025-06-24T12:40:07+00:00","description":"In this blog post, I will walk you through some of the new capabilities we have in our template language expressions for Azure Resource Manager templates.","breadcrumb":{"@id":"https:\/\/azure.microsoft.com\/en-us\/blog\/create-flexible-arm-templates-using-conditions-and-logical-functions\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/azure.microsoft.com\/en-us\/blog\/create-flexible-arm-templates-using-conditions-and-logical-functions\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/azure.microsoft.com\/en-us\/blog\/create-flexible-arm-templates-using-conditions-and-logical-functions\/#primaryimage","url":"https:\/\/azure.microsoft.com\/en-us\/blog\/wp-content\/uploads\/2017\/09\/2fa884b2-e033-4ca8-b2e3-ae245af2e2fc.webp","contentUrl":"https:\/\/azure.microsoft.com\/en-us\/blog\/wp-content\/uploads\/2017\/09\/2fa884b2-e033-4ca8-b2e3-ae245af2e2fc.webp","width":605,"height":110,"caption":"text"},{"@type":"BreadcrumbList","@id":"https:\/\/azure.microsoft.com\/en-us\/blog\/create-flexible-arm-templates-using-conditions-and-logical-functions\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Blog home","item":"https:\/\/azure.microsoft.com\/en-us\/blog\/"},{"@type":"ListItem","position":2,"name":"Management and governance","item":"https:\/\/azure.microsoft.com\/en-us\/blog\/category\/management-and-governance\/"},{"@type":"ListItem","position":3,"name":"Create flexible ARM templates using conditions and logical functions"}]},{"@type":"WebSite","@id":"https:\/\/azure.microsoft.com\/en-us\/blog\/#website","url":"https:\/\/azure.microsoft.com\/en-us\/blog\/","name":"Microsoft Azure Blog","description":"Get the latest Azure news, updates, and announcements from the Azure blog. From product updates to hot topics, hear from the Azure experts.","publisher":{"@id":"https:\/\/azure.microsoft.com\/en-us\/blog\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/azure.microsoft.com\/en-us\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/azure.microsoft.com\/en-us\/blog\/#organization","name":"Microsoft Azure Blog","url":"https:\/\/azure.microsoft.com\/en-us\/blog\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/azure.microsoft.com\/en-us\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/azure.microsoft.com\/en-us\/blog\/wp-content\/uploads\/2024\/06\/microsoft_logo.webp","contentUrl":"https:\/\/azure.microsoft.com\/en-us\/blog\/wp-content\/uploads\/2024\/06\/microsoft_logo.webp","width":512,"height":512,"caption":"Microsoft Azure Blog"},"image":{"@id":"https:\/\/azure.microsoft.com\/en-us\/blog\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/microsoftazure","https:\/\/x.com\/azure","https:\/\/www.instagram.com\/microsoftdeveloper\/","https:\/\/www.linkedin.com\/company\/16188386","https:\/\/www.youtube.com\/user\/windowsazure"]},{"@type":"Person","@id":"https:\/\/azure.microsoft.com\/en-us\/blog\/#\/schema\/person\/c702e5edd662b328b49b7e1180cab117","name":"shakir","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/9342c7c05bb16548741bc5cd3a3e3b7ee0c8e746844ad2cc582db5beb5514c6f?s=96&d=mm&r=g7664e653ea371ce16eaf75e9fa8952c4","url":"https:\/\/secure.gravatar.com\/avatar\/9342c7c05bb16548741bc5cd3a3e3b7ee0c8e746844ad2cc582db5beb5514c6f?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/9342c7c05bb16548741bc5cd3a3e3b7ee0c8e746844ad2cc582db5beb5514c6f?s=96&d=mm&r=g","caption":"shakir"},"sameAs":["https:\/\/azure.microsoft.com"],"url":"https:\/\/azure.microsoft.com\/en-us\/blog\/author\/shakir\/"}]}},"msxcm_display_generated_audio":false,"msxcm_animated_featured_image":null,"distributor_meta":false,"distributor_terms":false,"distributor_media":false,"distributor_original_site_name":"Microsoft Azure Blog","distributor_original_site_url":"https:\/\/azure.microsoft.com\/en-us\/blog","push-errors":false,"_links":{"self":[{"href":"https:\/\/azure.microsoft.com\/en-us\/blog\/wp-json\/wp\/v2\/posts\/3551","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/azure.microsoft.com\/en-us\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/azure.microsoft.com\/en-us\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/azure.microsoft.com\/en-us\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/azure.microsoft.com\/en-us\/blog\/wp-json\/wp\/v2\/comments?post=3551"}],"version-history":[{"count":1,"href":"https:\/\/azure.microsoft.com\/en-us\/blog\/wp-json\/wp\/v2\/posts\/3551\/revisions"}],"predecessor-version":[{"id":43009,"href":"https:\/\/azure.microsoft.com\/en-us\/blog\/wp-json\/wp\/v2\/posts\/3551\/revisions\/43009"}],"wp:attachment":[{"href":"https:\/\/azure.microsoft.com\/en-us\/blog\/wp-json\/wp\/v2\/media?parent=3551"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/azure.microsoft.com\/en-us\/blog\/wp-json\/wp\/v2\/categories?post=3551"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/azure.microsoft.com\/en-us\/blog\/wp-json\/wp\/v2\/tags?post=3551"},{"taxonomy":"audience","embeddable":true,"href":"https:\/\/azure.microsoft.com\/en-us\/blog\/wp-json\/wp\/v2\/audience?post=3551"},{"taxonomy":"content-type","embeddable":true,"href":"https:\/\/azure.microsoft.com\/en-us\/blog\/wp-json\/wp\/v2\/content-type?post=3551"},{"taxonomy":"product","embeddable":true,"href":"https:\/\/azure.microsoft.com\/en-us\/blog\/wp-json\/wp\/v2\/product?post=3551"},{"taxonomy":"tech-community","embeddable":true,"href":"https:\/\/azure.microsoft.com\/en-us\/blog\/wp-json\/wp\/v2\/tech-community?post=3551"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/azure.microsoft.com\/en-us\/blog\/wp-json\/wp\/v2\/topic?post=3551"},{"taxonomy":"author","embeddable":true,"href":"https:\/\/azure.microsoft.com\/en-us\/blog\/wp-json\/wp\/v2\/coauthors?post=3551"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}