In my previous posts I wrote about creating infrastructure for Azure WebJob using PowerShell or Terraform. Most recent approach for creating Azure resources is Azure Bicep. Bicep is a Domain Specific Language (DSL) for deploying Azure resources declaratively. Bicep code is transpiled to standard ARM Template. Bicep file for creating infrastructure for Azure WebJob is:
var baseName = resourceGroup().name var baseNameLower = toLower(baseName) resource appServicePlan 'Microsoft.Web/serverfarms@2018-02-01' = { name: baseName location: resourceGroup().location sku: { name: 'B1' capacity: 1 } } resource appService 'Microsoft.Web/sites@2018-11-01' = { name: baseNameLower location: resourceGroup().location properties: { serverFarmId: appServicePlan.id clientAffinityEnabled: false } } resource config 'Microsoft.Web/sites/config@2018-11-01' = { parent: appService name: 'web' properties: { use32BitWorkerProcess: false alwaysOn: true } } resource appSettings 'Microsoft.Web/sites/config@2018-11-01' = { parent: appService name: 'appsettings' properties: { APPINSIGHTS_INSTRUMENTATIONKEY: appInsights.properties.InstrumentationKey } } resource connectionStrings 'Microsoft.Web/sites/config@2018-11-01' = { parent: appService name: 'connectionstrings' properties: { AzureWebJobsDashboard: { value: 'DefaultEndpointsProtocol=https;AccountName=${baseNameLower};AccountKey=${listKeys(storageAccounts.id, '2019-06-01').keys[0].value};EndpointSuffix=${environment().suffixes.storage}' type: 'Custom' } AzureWebJobsStorage: { value: 'DefaultEndpointsProtocol=https;AccountName=${baseNameLower};AccountKey=${listKeys(storageAccounts.id, '2019-06-01').keys[0].value};EndpointSuffix=${environment().suffixes.storage}' type: 'Custom' } } } resource storageAccounts 'Microsoft.Storage/storageAccounts@2019-06-01' = { name: baseNameLower location: resourceGroup().location kind: 'StorageV2' sku: { name: 'Standard_LRS' tier: 'Standard' } } resource appInsights 'Microsoft.Insights/components@2015-05-01' = { name: baseName location: resourceGroup().location kind: 'web' properties: { Application_Type: 'web' } }
Resource group is then deployed using standart Azure CLI commands like using ARM template:
az group create --name WebJobTest --location westeurope az deployment group create --resource-group WebJobTest --template-file azuredeploy.bicep --verbose