Bicep files cannot yet be directly deployed via the Az CLI or PowerShell Az module. You must first compile the bicep file with bicep build then deploy via deployment commands (az deployment group create or New-AzResourceGroupDeployment).
Let's start by compiling and deploying the main.bicep file that we've been working with. I can do this via Azure PowerShell or Az CLI. For Powershell be sure to have the Az module installed to follow this tutorial by running Install-Module -Name Az -AllowClobber in an elevated Powershell session. For CLI download the correct version for your OS
Note: make sure you update your storage account name to be globally unique.
Via Azure PowerShell:
bicep build ./main.bicep # generates main.json
New-AzResourceGroup -Name my-rg -Location eastus # optional - create resource group 'my-rg'
New-AzResourceGroupDeployment -TemplateFile ./main.json -ResourceGroupName my-rgVia Az CLI:
bicep build ./main.bicep # generates main.json
az group create -n my-rg -l eastus # optional - create resource group 'my-rg'
az deployment group create -f ./main.json -g my-rgIn our 0.2 release, there is no new "bicep-style" of authoring a parameters file. Since the compiled bicep file is a standard JSON ARM Template, parameters can be passed to the template in the same ways you are likely already used to.
Our bicep file exposed two parameters that we can override (location and name)
Note: make sure you update your storage account name to be globally unique.
CLI:
az deployment group create -f ./main.json -g my-rg --parameters location=westus name=logstorage001PowerShell:
New-AzResourceGroupDeployment -TemplateFile ./main.json -ResourceGroupName my-rg -location westus -name logstorage001ARM Templates support providing all of the parameters for a template via a JSON file. You can take a look at this parameters tutorial to learn how the parameters file is structured. Once you have your parameters file, you can pass it to the deployment command-line tools:
CLI:
az deployment group create -f ./main.json -g my-rg --parameters ./parameters.main.jsonPowerShell:
New-AzResourceGroupDeployment -TemplateFile ./main.json -ResourceGroupName my-rg -TemplateParameterFile ./parameters.main.jsonBicep will compile a template that uses the resource group $schema by default:
{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#"
...
}However, you can deploy this template to any scope with the correct command. Note that this is a temporary workaround until Bicep has better support for deploying resources to any scope in Azure.
The next tutorial will walk you through the basics of using expressions like functions, string interpolation, and ternary operators in bicep.