-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Metadata & description decorators example (#13)
* Metadata & description decorators example merge * syntax and spelling fixes
- Loading branch information
1 parent
c7e3cc5
commit 441e6b9
Showing
6 changed files
with
74 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
# Azure Bicep - Metadata & Descriptions | ||
|
||
## Introduction | ||
|
||
Whether you're starting your Azure Bicep journey and want to align to best practice methods straight from the get go, or you have existing templates that could do with a freshen up - descriptions and metadata has a place in your Azure Bicep templates. | ||
|
||
## 📃 Benefits of using metadata and descriptions in your Azure Bicep files | ||
|
||
1. ✅ Reusability. By defining the `@description` for the parameters other engineers can quickly understand the template and what function each parameter and variable is | ||
|
||
2. ✅ Accountability. By defining the `metadata =` information we're able to define the Azure Bicep name, description and business/team ownership for maintain the module (if applicable. Otherwise this is good just to describe the modules purpose) | ||
|
||
3. ✅ Best practice. It's good practice to have metadata and descriptions in your Azure Bicep files. It offers a consistent experience for everyone, and incorporates the above benefits that align into the best practice model | ||
|
||
> [!TIP] | ||
> You can hover over parameters in your .bicepparam file to get the parameter description information. | ||
## 🚀 Deployment | ||
|
||
> [!NOTE] | ||
> Metadata and descriptions decorators are just for the Azure Bicep file and have no bearing on deployment resources, however, as with all the examples there is a real world example deployment to accommodate the concept to bring the picture full circle. | ||
In VisualStudio Code open a terminal and run: | ||
|
||
CLI | ||
|
||
```bash | ||
az login | ||
az account set --subscription 'subscription name or id' | ||
az deployment sub create --confirm-with-what-if -l 'uksouth' -f .\metadata-example.bicep -p .\metadata-example.bicepparam | ||
``` | ||
|
||
or PowerShell | ||
|
||
```powershell | ||
Connect-AzAccount | ||
Set-AzContext -Subscription "subscription name or id" | ||
New-AzDeployment -Confirm -Location "UKSouth" -TemplateFile ".\metadata-example.bicep" -TemplateParameterFile ".\metadata-example.bicepparam" | ||
``` |
20 changes: 20 additions & 0 deletions
20
bicep-examples/metadata-and-descriptions/metadata-example.bicep
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
targetScope = 'subscription' | ||
|
||
metadata name = 'Resource Group Azure Bicep module' | ||
metadata description = 'Module used to create Resource Groups' | ||
metadata owner = '[email protected]' | ||
|
||
@description('Azure Region where the Resource Group will be created.') | ||
param parLocation string | ||
|
||
@description('Name of Resource Group to be created.') | ||
param parResourceGroupName string | ||
|
||
@description('Azure Tags you would like to be applied to the Resource Group.') | ||
param parTags object = {} | ||
|
||
resource resResourceGroup 'Microsoft.Resources/resourceGroups@2022-09-01' = { | ||
location: parLocation | ||
name: parResourceGroupName | ||
tags: parTags | ||
} |
8 changes: 8 additions & 0 deletions
8
bicep-examples/metadata-and-descriptions/metadata-example.bicepparam
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
using 'metadata-example.bicep' | ||
|
||
// Hover over the param to see their descriptions pulled from the main bicep file | ||
param parLocation = 'uksouth' | ||
param parResourceGroupName = 'rg-uks-test-prod' | ||
param parTags = { | ||
metadata: 'test' | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters