You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: articles/azure-resource-manager/bicep/decompile.md
+4-1Lines changed: 4 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,7 +2,8 @@
2
2
title: Decompile ARM template JSON to Bicep
3
3
description: Describes commands for decompiling Azure Resource Manager templates to Bicep files.
4
4
ms.topic: conceptual
5
-
ms.date: 11/11/2022
5
+
ms.date: 03/03/2023
6
+
ms.custom: devx-track-azurepowershell
6
7
---
7
8
8
9
# Decompiling ARM template JSON to Bicep
@@ -11,6 +12,8 @@ This article describes how to decompile Azure Resource Manager templates (ARM te
11
12
12
13
> [!NOTE]
13
14
> From Visual Studio Code, you can directly create resource declarations by importing from existing resources. For more information, see [Bicep commands](./visual-studio-code.md#bicep-commands).
15
+
>
16
+
> Visual Studio Code enables you to paste JSON as Bicep. It automatically runs the decompile command. For more information, see [Paste JSON as Bicep](./visual-studio-code.md#paste-as-bicep-preview).
14
17
15
18
Decompiling an ARM template helps you get started with Bicep development. If you have a library of ARM templates and want to use Bicep for future development, you can decompile them to Bicep. However, the Bicep file might need revisions to implement best practices for Bicep.
Copy file name to clipboardExpand all lines: articles/azure-resource-manager/bicep/migrate.md
+7-5Lines changed: 7 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,7 +4,7 @@ description: Describes the recommended workflow when migrating Azure resources a
4
4
author: joshuawaddell
5
5
ms.author: jowaddel
6
6
ms.topic: conceptual
7
-
ms.date: 11/11/2022
7
+
ms.date: 03/03/2023
8
8
---
9
9
# Migrate to Bicep
10
10
@@ -32,6 +32,8 @@ The convert phase consists of two steps, which you complete in sequence:
32
32
33
33
> [!NOTE]
34
34
> You can import a resource by opening the Visual Studio Code command palette. Use <kbd>Ctrl+Shift+P</kbd> on Windows and Linux and <kbd>⌘+Shift+P</kbd> on macOS.
35
+
>
36
+
> Visual Studio Code enables you to paste JSON as Bicep. For more information, see [Paste JSON as Bicep](./visual-studio-code.md#paste-as-bicep-preview).
35
37
36
38
## Phase 2: Migrate
37
39
@@ -43,7 +45,7 @@ The migrate phase consists of three steps, which you complete in sequence:
43
45
44
46
1.**Copy each resource from your decompiled template.** Copy each resource individually from the converted Bicep file to the new Bicep file. This process helps you resolve any issues on a per-resource basis and to avoid any confusion as your template grows in size.
45
47
46
-
1.**Identify and recreate any missing resources.** Not all Azure resource types can be exported through the Azure portal, Azure CLI, or Azure PowerShell. For example, virtual machine extensions such as the DependencyAgentWindows and MMAExtension (Microsoft Monitoring Agent) aren't supported resource types for export. For any resource that wasn't exported, such as virtual machine extensions, you'll need to recreate those resources in your new Bicep file. You can recreate resources using a variety of tools and approaches, including [Azure Resource Explorer](../templates/export-template-portal.md?azure-portal=true), the [Bicep and ARM template reference documentation](/azure/templates/?azure-portal=true), and the [Azure Quickstart Templates](https://azure.microsoft.com/resources/templates?azure-portal=true) site.
48
+
1.**Identify and recreate any missing resources.** Not all Azure resource types can be exported through the Azure portal, Azure CLI, or Azure PowerShell. For example, virtual machine extensions such as the DependencyAgentWindows and MMAExtension (Microsoft Monitoring Agent) aren't supported resource types for export. For any resource that wasn't exported, such as virtual machine extensions, you need to recreate those resources in your new Bicep file. You can recreate resources using various tools and approaches, including [Azure Resource Explorer](../templates/export-template-portal.md?azure-portal=true), the [Bicep and ARM template reference documentation](/azure/templates/?azure-portal=true), and the [Azure Quickstart Templates](https://azure.microsoft.com/resources/templates?azure-portal=true) site.
47
49
48
50
## Phase 3: Refactor
49
51
@@ -55,7 +57,7 @@ The deploy phase consists of eight steps, which you complete in any order:
55
57
56
58
1.**Review the linter suggestions in your new Bicep file.** When you use the [Bicep extension for Visual Studio Code](https://marketplace.visualstudio.com/items?itemName=ms-azuretools.vscode-bicep&azure-portal=true) to create Bicep files, the [Bicep linter](linter.md) runs automatically and highlights suggestions and errors in your code. Many of the suggestions and errors include an option to apply a quick fix of the issue. Review these recommendations and adjust your Bicep file.
57
59
58
-
1.**Revise parameters, variables, and symbolic names.** It's possible the names of parameters, variables, and symbolic names generated by the decompiler won't match your standard naming convention. Review the generated names and make adjustments as necessary.
60
+
1.**Revise parameters, variables, and symbolic names.** It's possible the names of parameters, variables, and symbolic names generated by the decompiler don't match your standard naming convention. Review the generated names and make adjustments as necessary.
59
61
60
62
1.**Simplify expressions.** The decompile process may not always take advantage of some of Bicep's features. Review any expressions generated in the conversion and simplify them. For example, the decompiled template may include a `concat()` or `format()` function that could be simplified by using [string interpolation](bicep-functions-string.md#concat). Review any suggestions from the linter and make adjustments as necessary.
61
63
@@ -86,13 +88,13 @@ In the _deploy_ phase of migrating your resources to Bicep, the goal is to deplo
86
88
87
89
The deploy phase consists of four steps, which you complete in sequence:
88
90
89
-
1.**Prepare a rollback plan.** The ability to recover from a failed deployment is crucial. Create a rollback strategy in the event that any breaking changes are introduced into your environments. Take inventory of the types of resources that are deployed, such as virtual machines, web apps, and databases. Each resource's data plane should be considered as well. Do you have a way to recover a virtual machine and its data? Do you have a way to recover a database after deletion? A well-developed rollback plan will help to keep your downtime to a minimum if any issues arise from a deployment.
91
+
1.**Prepare a rollback plan.** The ability to recover from a failed deployment is crucial. Create a rollback strategy if any breaking changes are introduced into your environments. Take inventory of the types of resources that are deployed, such as virtual machines, web apps, and databases. Each resource's data plane should be considered as well. Do you have a way to recover a virtual machine and its data? Do you have a way to recover a database after deletion? A well-developed rollback plan helps to keep your downtime to a minimum if any issues arise from a deployment.
90
92
91
93
1.**Run the what-if operation against production.** Before deploying your final Bicep file to production, run the what-if operation against your production environment, making sure to use production parameter values, and consider documenting the results.
92
94
93
95
1.**Deploy manually.** If you're going to use the converted template in a pipeline, such as [Azure DevOps](add-template-to-azure-pipelines.md) or [GitHub Actions](deploy-github-actions.md), consider running the deployment from your local machine first. It's preferable to test the template's functionality before incorporating it into your production pipeline. That way, you can respond quickly if there's a problem.
94
96
95
-
1.**Run smoke tests.** After your deployment is complete, you should run a series of *smoke tests* to ensure that your application or workload is working properly. For example, test to see if your web app is accessible through normal access channels, such as the public Internet or across a corporate VPN. For databases, attempt to make a database connection and execute a series of queries. With virtual machines, log in to the virtual machine and make sure that all services are up and running.
97
+
1.**Run smoke tests.** After your deployment is complete, you should run a series of *smoke tests* to ensure that your application or workload is working properly. For example, test to see if your web app is accessible through normal access channels, such as the public Internet or across a corporate VPN. For databases, attempt to make a database connection and execute a series of queries. With virtual machines, sign in to the virtual machine and make sure that all services are up and running.
Copy file name to clipboardExpand all lines: articles/azure-resource-manager/bicep/visual-studio-code.md
+77-3Lines changed: 77 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,7 +2,7 @@
2
2
title: Create Bicep files by using Visual Studio Code
3
3
description: Describes how to create Bicep files by using Visual Studio Code
4
4
ms.topic: conceptual
5
-
ms.date: 02/21/2023
5
+
ms.date: 03/03/2023
6
6
---
7
7
8
8
# Create Bicep files by using Visual Studio Code
@@ -17,7 +17,7 @@ To set up your environment for Bicep development, see [Install Bicep tools](inst
17
17
18
18
Visual Studio Code comes with several Bicep commands.
19
19
20
-
Open or create a Bicep file in VS Code, select the **View** menu and then select **Command Palette**. You can also use the key combination **[CTRL]+[SHIFT]+P** to bring up the command palette. Type **Bicep** to list the Bicep commands.
20
+
Open or create a Bicep file in VS Code, select the **View** menu and then select **Command Palette**. You can also use **F1** or the key combination <kbd>Ctrl+Shift+P</kbd> to bring up the command palette. Type **Bicep** to list the Bicep commands.
21
21
22
22
:::image type="content" source="./media/visual-studio-code/visual-studio-code-bicep-commands.png" alt-text="Screenshot of Visual Studio Code Bicep commands in the command palette.":::
23
23
@@ -53,7 +53,7 @@ The [Bicep configuration file (bicepconfig.json)](./bicep-config.md) can be used
53
53
To create a Bicep configuration file:
54
54
55
55
1. Open Visual Studio Code.
56
-
1. From the **View** menu, select **Command Palette** (or press **[CTRL/CMD]**+**[SHIFT]**+**P**), and then select **Bicep: Create Bicep Configuration File**.
56
+
1. From the **View** menu, select **Command Palette** (or press <kbd>Ctrl/Cmd+Shift+P</kbd>), and then select **Bicep: Create Bicep Configuration File**.
57
57
1. Select the file directory where you want to place the file.
58
58
1. Save the configuration file when you're done.
59
59
@@ -124,6 +124,80 @@ From Visual Studio Code, you can easily open the template reference for the reso
124
124
125
125
:::image type="content" source="./media/visual-studio-code/visual-studio-code-bicep-view-type-document.png" alt-text="Screenshot of Visual Studio Code Bicep view type document.":::
126
126
127
+
## Paste as Bicep (Preview)
128
+
129
+
You can paste a JSON snippet from an ARM template to Bicep file. Visual Studio Code automatically decompiles the JSON to Bicep. This feature is only available with the Bicep extension version 0.14.0 or newer.
130
+
131
+
To enable the feature:
132
+
133
+
1. In Visual Studio Code, select **Manage** (gear icon) in the side menu. Select **Settings**. You can also use <kbd>Ctrl+,</kbd> to open settings.
134
+
1. Expand **Extensions** and then select **Bicep**.
135
+
1. Select **Decompile on Paste**.
136
+
137
+
:::image type="content" source="./media/visual-studio-code/enable-paste-json.png" alt-text="Screenshot of Visual Studio Code Paste as Bicep.":::
138
+
139
+
By using this feature, you can paste:
140
+
141
+
- Full ARM JSON templates.
142
+
- Single resource or multiple resources.
143
+
- JSON values, such as objects, arrays, and strings. A string with double-quotes is converted to single-quotes.
144
+
145
+
For example, you can start with the following Bicep file:
146
+
147
+
```bicep
148
+
@description('Storage Account type')
149
+
@allowed([
150
+
'Standard_LRS'
151
+
'Standard_GRS'
152
+
'Standard_ZRS'
153
+
'Premium_LRS'
154
+
])
155
+
param storageAccountsku string = 'Standard_LRS'
156
+
157
+
@description('Location for all resources.')
158
+
param location string = resourceGroup().location
159
+
160
+
var storageAccountName = '${uniqueString(resourceGroup().id)}storage'
0 commit comments