Skip to content

Commit 76e9f6d

Browse files
authored
Merge pull request #291738 from mumian/1121-vscode-extract
VSCode extract variables, parameters, types
2 parents 7fb331c + 5c40c4b commit 76e9f6d

7 files changed

+39
-1
lines changed
Loading
Loading
Loading
Loading
Loading
Loading

articles/azure-resource-manager/bicep/visual-studio-code.md

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ title: Create Bicep files by using Visual Studio Code
33
description: Learn how to use Visual Studio Code to create Bicep files.
44
ms.topic: how-to
55
ms.custom: devx-track-bicep
6-
ms.date: 12/06/2024
6+
ms.date: 01/08/2025
77
---
88

99
# Create Bicep files by using Visual Studio Code
@@ -199,6 +199,44 @@ The Bicep Deployment Pane is an experimental feature. For more information, see
199199

200200
You can also open the deployment pane side-by-side with the Bicep file.
201201

202+
## Use quick fix suggestions
203+
204+
The light bulb in VS Code represents a quick fix suggestion. It appears when the editor detects an issue or an improvement opportunity in your code. Clicking on the light bulb displays a menu of actions that can address the issue or enhance the code.
205+
206+
:::image type="content" source="./media/visual-studio-code/visual-studio-code-bicep-context-quick-fix-suggestions.png" alt-text="Screenshot of Visual Studio Code quick fix suggestions.":::
207+
208+
For the extract commands, see [Extract parameters, variables, and types](#extract-parameters-variables-and-types). In **More Actions**, it suggests adding [decorators](./variables.md#use-decorators).
209+
210+
## Extract parameters, variables, and types
211+
212+
Extracting [variables](./variables.md), [parameters](./parameters.md), and [user-defined data types](./user-defined-data-types.md) involves isolating and defining these components from existing code to improve code structure, maintainability, and clarity.
213+
214+
The following screenshot shows a definition of an AKS cluster resource. You can extract a parameter or a variable, or a user-defined data type based of a property, such as `identity`.
215+
216+
Select the `identity` line from the code, and then select the yellow light bulb icon. The context windows shows the available extract options.
217+
218+
:::image type="content" source="./media/visual-studio-code/visual-studio-code-azure-variable-parameter-type-extraction.png" alt-text="Screenshot of variable, parameter, type extraction.":::
219+
220+
- **Extract variable**: creates a new variable, and give you an option to update the variable name:
221+
222+
:::image type="content" source="./media/visual-studio-code/visual-studio-code-azure-variable-parameter-type-extract-variable.png" alt-text="Screenshot of extracting variable.":::
223+
224+
- **Extract parameter of a simple data type**: create a new parameter with a simple data type, such as string, int, etc., and give you an option to update the parameter name:
225+
226+
:::image type="content" source="./media/visual-studio-code/visual-studio-code-azure-variable-parameter-type-extract-parameter.png" alt-text="Screenshot of extracting parameter.":::
227+
228+
- **Extract parameter of a user-defined data type**: create a new parameter with a user-defined data type, and give you an option to update the parameter name:
229+
230+
:::image type="content" source="./media/visual-studio-code/visual-studio-code-azure-variable-parameter-type-extract-parameter-with-allowed-values.png" alt-text="Screenshot of extracting parameter with allowed values.":::
231+
232+
After the extract, it requires some customization.
233+
234+
- **Create user-defined type**: create a new user-defined type, and give you an option to update the type name.
235+
236+
:::image type="content" source="./media/visual-studio-code/visual-studio-code-azure-variable-parameter-type-extract-type.png" alt-text="Screenshot of extracting user-defined data types.":::
237+
238+
Unlike the other options, it doesn't replace the selected code with a reference to the new type. In the preceding example, the value of `identity` remains as it is. To use the new type, you must incorporate it into your code.
239+
202240
## View documentation
203241

204242
From Visual Studio Code, you can open the template reference for the resource type you're working on. To do so, hover your cursor over the resource symbolic name, and then select **View Documentation**.

0 commit comments

Comments
 (0)