Skip to content

Commit 5f9a69f

Browse files
authored
Merge pull request #206531 from edburns/edburns-msft-96155-jsonc-mention
Increase discoverability of jsonc feature in ARM
2 parents 2356929 + 54dd77c commit 5f9a69f

File tree

2 files changed

+40
-2
lines changed

2 files changed

+40
-2
lines changed

articles/azure-resource-manager/templates/best-practices.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,23 @@ The following information can be helpful when you work with [resources](./syntax
189189
]
190190
```
191191

192+
If your ARM template is stored in a `.jsonc` file, comments using the `//` syntax are supported, as shown here.
193+
194+
```javascript
195+
"resources": [
196+
{
197+
// This storage account is used to store the VM disks.
198+
"name": "[variables('storageAccountName')]",
199+
"type": "Microsoft.Storage/storageAccounts",
200+
"apiVersion": "2019-06-01",
201+
"location": "[resourceGroup().location]",
202+
...
203+
}
204+
]
205+
```
206+
207+
For more details about comments and metadata see [Understand the structure and syntax of ARM templates](/azure/azure-resource-manager/templates/syntax#comments-and-metadata).
208+
192209
* If you use a *public endpoint* in your template (such as an Azure Blob storage public endpoint), *don't hard-code* the namespace. Use the `reference` function to dynamically retrieve the namespace. You can use this approach to deploy the template to different public namespace environments without manually changing the endpoint in the template. Set the API version to the same version that you're using for the storage account in your template.
193210

194211
```json
@@ -272,6 +289,14 @@ The following information can be helpful when you work with [resources](./syntax
272289

273290
* Specify explicit values for properties that have default values that could change over time. For example, if you're deploying an AKS cluster, you can either specify or omit the `kubernetesVersion` property. If you don't specify it, then [the cluster is defaulted to the N-1 minor version and latest patch](../../aks/supported-kubernetes-versions.md#azure-portal-and-cli-versions). When you deploy the cluster using an ARM template, this default behavior might not be what you expect. Redeploying your template may result in the cluster being upgraded to a new Kubernetes version unexpectedly. Instead, consider specifying an explicit version number and then manually changing it when you're ready to upgrade your cluster.
274291

292+
## Comments
293+
294+
In addition to the `comments` property, comments using the `//` syntax are supported. For more details about comments and metadata see [Understand the structure and syntax of ARM templates](/azure/azure-resource-manager/templates/syntax#comments-and-metadata). You may choose to save JSON files that contain `//` comments using the `.jsonc` file extension, to indicate the JSON file contains comments. The ARM service will also accept comments in any JSON file including parameters files.
295+
296+
## Visual Studio Code ARM Tools
297+
298+
Working with ARM templates is much easier with the Azure Resource Manager (ARM) Tools for Visual Studio Code. This extension provides language support, resource snippets, and resource auto-completion to help you create and validate Azure Resource Manager templates. To learn more and install the extension, see [Azure Resource Manager (ARM) Tools](https://marketplace.visualstudio.com/items?itemName=msazurermtools.azurerm-vscode-tools).
299+
275300
## Use test toolkit
276301

277302
The ARM template test toolkit is a script that checks whether your template uses recommended practices. When your template isn't compliant with recommended practices, it returns a list of warnings with suggested changes. The test toolkit can help you learn how to implement best practices in your template.

articles/azure-resource-manager/templates/deploy-cli.md

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,8 @@ az deployment group create \
7979
--parameters storageAccountType=Standard_GRS
8080
```
8181

82+
The value of the `--template-file` parameter must be a Bicep file or a `.json` or `.jsonc` file. The `.jsonc` file extension indicates the file can contain `//` style comments. The ARM system accepts `//` comments in `.json` files. It does not care about the file extension. For more details about comments and metadata see [Understand the structure and syntax of ARM templates](/azure/azure-resource-manager/templates/syntax#comments-and-metadata).
83+
8284
The Azure deployment template can take a few minutes to complete. When it finishes, you see a message that includes the result:
8385

8486
```output
@@ -268,9 +270,20 @@ az deployment group create \
268270
--parameters '@storage.parameters.json'
269271
```
270272

271-
## Handle extended JSON format
273+
## Comments and the extended JSON format
274+
275+
You can include `//` style comments in your parameter file, but you must name the file with a `.jsonc` extension.
276+
277+
```azurecli-interactive
278+
az deployment group create \
279+
--name ExampleDeployment \
280+
--resource-group ExampleGroup \
281+
--template-file storage.json \
282+
--parameters '@storage.parameters.jsonc'
283+
```
284+
For more details about comments and metadata see [Understand the structure and syntax of ARM templates](/azure/azure-resource-manager/templates/syntax#comments-and-metadata).
272285

273-
To deploy a template with multi-line strings or comments using Azure CLI with version 2.3.0 or older, you must use the `--handle-extended-json-format` switch. For example:
286+
If you are using Azure CLI with version 2.3.0 or older, you can deploy a template with multi-line strings or comments using the `--handle-extended-json-format` switch. For example:
274287

275288
```json
276289
{

0 commit comments

Comments
 (0)