원클릭으로
format-bicep
Format Bicep code for readability and consistency.
Codex 또는 Claude로 설치 이 Prompt를 복사해 Codex, Claude 또는 다른 어시스턴트에 붙여 넣으면 Skill 페이지를 검토하고 설치를 진행할 수 있습니다.
메뉴
Format Bicep code for readability and consistency.
Codex 또는 Claude로 설치 이 Prompt를 복사해 Codex, Claude 또는 다른 어시스턴트에 붙여 넣으면 Skill 페이지를 검토하고 설치를 진행할 수 있습니다.
SOC 직업 분류 기준
Converts Bicep resource definitions to Azure Verified Modules (AVM). Use when user asks to convert to AVM, replace resources with modules, use verified modules, or modernize bicep templates.
Converts loosely typed Bicep parameters using object or array to strongly typed alternatives like string[], user-defined types, or resource-derived types. Use when user mentions type safety, weak typing, object parameters, array parameters, resourceInput, resourceOutput, or asks to improve parameter definitions.
Validates Bicep functions using bicep console with piped input. Use when user asks to test, validate, or run Bicep functions, or wants to verify function behavior with test cases.
| name | format-bicep |
| description | Format Bicep code for readability and consistency. |
This skill reformats Bicep code to enhance readability and maintainability by applying consistent styling, indentation, and organization.
To format a Bicep file, follow these guidelines:
To avoid chaos keep a strict structure for Bicep files. The recommended structure is as follows:
// Imports
// Metadata (optional)
// TargetScope (optional)
// Parameters
// Variables
// Existing resource references
// Resources / Modules
// Outputs
// User-Defined Types Types
// Functions
Do not add blank lines between section comment headers and the first definition in that section.
Correct:
// Parameters
@description('The supported Azure location')
param location string
Wrong:
// Parameters
@description('The supported Azure location')
param location string
Resource definitions should follow a consistent property order:
resource <name> '<type>@<apiVersion>' = {
name: '<name>'
location: '<location>'
tags: '<tags>'
<property>: '<otherProperties>' // other resource-specific properties in alphabetical order
dependsOn: [
// dependencies
] // optional, prefer implicit dependencies
properties: {
// resource-specific properties
}
}
Module defitinitions should follow a consistent property order. If the module has the name property, it should be removed since the Azure Resource Manager handles the deployment name.
module <name> '<path>' = {
scope: '<scope>' // optional
identity: {
// identity properties
} // optional
dependsOn: [
// dependencies
] // optional, prefer implicit dependencies
params: {
// module parameters
}
}
Resources which have an existing reference should have the name ending with Ref. For example:
resource subnetRef '<type>@<apiVersion>' existing = {
...
}
When formatting a Bicep file, perform these steps in order:
Analyze the current structure
Reorganize sections according to the standard structure
Apply property ordering
Run bicep format
bicep format <.bicep file>Remove commented code
Validate the result
Use the following command to compile and validate the Bicep file:
bicep build <.bicep file> --stdout --no-restore
param location string='eastus'
var storageAccountName='mystorageaccount'
resource storageAccount 'Microsoft.Storage/storageAccounts@2021-09-01'={
name:storageAccountName
location:location
properties:{
accessTier:'Hot'
}
sku: {
name: 'Standard_LRS'
}
}
// Parameters
@sys.description('The Azure region for resource deployment')
param location string = 'eastus'
// Variables
var storageAccountName = 'mystorageaccount'
// Resources
resource storageAccount 'Microsoft.Storage/storageAccounts@2021-09-01' = {
name: storageAccountName
location: location
sku: {
name: 'Standard_LRS'
}
properties: {
accessTier: 'Hot'
}
}