== Why is this an issue? include::../description.adoc[] === Exceptions include::exceptions-arm.adoc[] == How to fix it in JSON templates include::howtofix-arm.adoc[] === Code examples ==== Noncompliant code example With the default threshold of 5: [source,json,diff-id=1,diff-type=noncompliant] ---- { "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#", "contentVersion": "1.0.0.0", "variables": {}, "resources": [ { "type": "Microsoft.Storage/storageAccounts", "apiVersion": "2021-01-01", "name": "appSuperStorage", "tags": { "displayName": "appSuperStorage", "shortName" : "appSuperStorage", "someName": "appSuperStorage", "yetAnotherName": "appSuperStorage" } } ] } ---- ==== Compliant solution [source,json,diff-id=1,diff-type=compliant] ---- { "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#", "contentVersion": "1.0.0.0", "variables": { "storageAccountName": "appSuperStorage" }, "resources": [ { "type": "Microsoft.Storage/storageAccounts", "apiVersion": "2021-01-01", "name": "[variables('storageAccountName')]", "tags": { "displayName": "[variables('storageAccountName')]", "shortName" : "[variables('storageAccountName')]", "someName": "[variables('storageAccountName')]", "yetAnotherName": "[variables('storageAccountName')]" } } ] } ---- == How to fix it in Bicep include::howtofix-arm.adoc[] === Code examples ==== Noncompliant code example With the default threshold of 5: [source,bicep,diff-id=2,diff-type=noncompliant] ---- resource storageAccount 'Microsoft.Storage/storageAccounts@2021-01-01' = { name: 'appSuperStorage' // Noncompliant tags: { displayName: 'appSuperStorage' // Noncompliant shortName: 'appSuperStorage' // Noncompliant someName: 'appSuperStorage' // Noncompliant yetAnotherName: 'appSuperStorage' // Noncompliant } } ---- ==== Compliant solution [source,bicep,diff-id=2,diff-type=compliant] ---- var storageAccountName = 'appSuperStorage' resource storageAccount 'Microsoft.Storage/storageAccounts@2021-01-01' = { name: storageAccountName tags: { displayName: storageAccountName shortName: storageAccountName someName: storageAccountName yetAnotherName: storageAccountName } } ---- == Resources == Documentation * Microsoft - https://learn.microsoft.com/en-us/azure/azure-resource-manager/templates/best-practices#variables[ARM template best practices] * Microsoft - https://learn.microsoft.com/en-us/azure/azure-resource-manager/bicep/best-practices[Best practices for Bicep] === Related rules * S6893 - Use a hard-coded value for the apiVersion ifdef::env-github,rspecator-view[] ''' == Implementation Specification (visible only on this page) include::../message.adoc[] include::../parameters.adoc[] include::../highlighting.adoc[] ''' endif::env-github,rspecator-view[]