Skip to content

Commit 9db3e7a

Browse files
authored
Merge pull request #95647 from mumian/1112-alex
revise the comments section
2 parents cc15112 + caeae18 commit 9db3e7a

File tree

3 files changed

+26
-26
lines changed

3 files changed

+26
-26
lines changed
Loading

articles/azure-resource-manager/resource-group-authoring-templates.md

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ description: Describes the structure and properties of Azure Resource Manager te
44
author: tfitzmac
55
ms.service: azure-resource-manager
66
ms.topic: conceptual
7-
ms.date: 10/09/2019
7+
ms.date: 11/12/2019
88
ms.author: tomfitz
99
---
1010

@@ -281,6 +281,31 @@ For examples of how to use outputs, see [Outputs in Azure Resource Manager templ
281281

282282
You have a few options for adding comments and metadata to your template.
283283

284+
### Comments
285+
286+
For inline comments, you can use either `//` or `/* ... */` but this syntax doesn't work with all tools. You can't use the portal template editor to work on templates with inline comments. If you add this style of comment, be sure the tools you use support inline JSON comments.
287+
288+
> [!NOTE]
289+
> To deploy templates with comments by using Azure CLI, you must use the `--handle-extended-json-format` switch.
290+
291+
```json
292+
{
293+
"type": "Microsoft.Compute/virtualMachines",
294+
"name": "[variables('vmName')]", // to customize name, change it in variables
295+
"location": "[parameters('location')]", //defaults to resource group location
296+
"apiVersion": "2018-10-01",
297+
"dependsOn": [ /* storage account and network interface must be deployed first */
298+
"[resourceId('Microsoft.Storage/storageAccounts/', variables('storageAccountName'))]",
299+
"[resourceId('Microsoft.Network/networkInterfaces/', variables('nicName'))]"
300+
],
301+
```
302+
303+
In Visual Studio Code, the [Azure Resource Manager Tools extension](./resource-manager-tools-vs-code.md#install-resource-manager-tools-extension) can automatically detect Resource Manager template and change the language mode accordingly. If you see **Azure Resource Manager Template** at the bottom right corner of VS Code, you can use the inline comments. The inline comments are no longer marked as invalid.
304+
305+
![Visual Studio Code Azure Resource Manager template mode](./media/resource-group-authoring-templates/resource-manager-template-editor-mode.png)
306+
307+
### Metadata
308+
284309
You can add a `metadata` object almost anywhere in your template. Resource Manager ignores the object, but your JSON editor may warn you that the property isn't valid. In the object, define the properties you need.
285310

286311
```json
@@ -350,31 +375,6 @@ For **outputs**, add a metadata object to the output value.
350375

351376
You can't add a metadata object to user-defined functions.
352377

353-
For inline comments, you can use either `//` or `/* ... */` but this syntax doesn't work with all tools. You can't use the portal template editor to work on templates with inline comments. If you add this style of comment, be sure the tools you use support inline JSON comments.
354-
355-
> [!NOTE]
356-
> To deploy templates with comments by using Azure CLI, you must use the `--handle-extended-json-format` switch.
357-
358-
```json
359-
{
360-
"type": "Microsoft.Compute/virtualMachines",
361-
"name": "[variables('vmName')]", // to customize name, change it in variables
362-
"location": "[parameters('location')]", //defaults to resource group location
363-
"apiVersion": "2018-10-01",
364-
"dependsOn": [ /* storage account and network interface must be deployed first */
365-
"[resourceId('Microsoft.Storage/storageAccounts/', variables('storageAccountName'))]",
366-
"[resourceId('Microsoft.Network/networkInterfaces/', variables('nicName'))]"
367-
],
368-
```
369-
370-
In VS Code, you can set the language mode to JSON with comments. The inline comments are no longer marked as invalid. To change the mode:
371-
372-
1. Open language mode selection (Ctrl+K M)
373-
374-
1. Select **JSON with Comments**.
375-
376-
![Select language mode](./media/resource-group-authoring-templates/select-json-comments.png)
377-
378378
## Multi-line strings
379379

380380
You can break a string into multiple lines. For example the location property and one of the comments in the following JSON example.

0 commit comments

Comments
 (0)