Cloud can be tricky sometimes. Find out what scenarios we've ran into that are worth being mentioned and explained.
Introduction
Azure-Bicep-Deploy/
│── BicepFiles/
│ └── main.bicep
│── pipelines/
│ └── pipeline.yaml
param location string = resourceGroup().location
param functionAppName string = 'myFunctionApp'
param storageAccountName string = 'funcstorageapp'
resource storageAccount 'Microsoft.Storage/storageAccounts@2022-09-01' = {
name: storageAccountName
location: location
sku: {
name: 'Standard_LRS'
}
kind: 'StorageV2'
}
resource functionApp 'Microsoft.Web/sites@2022-09-01' = {
name: functionAppName
location: location
properties: {
serverFarmId: ''
siteConfig: {
appSettings: [
{
name: 'AzureWebJobsStorage'
value: storageAccount.properties.primaryEndpoints.blob
}
]
}
}
}
This Bicep file:
name: $(BuildDefinitionName)_$(date:yyyyMMdd)$(rev:.r)
trigger:
batch: true
branches:
include:
- main
pr: none
stages:
- stage: deployBicep
jobs:
- job: "BicepDeployment"
steps:
- task: PowerShell@2
displayName: 'Build Bicep File'
inputs:
targetType: 'inline'
script: |
az bicep build --file $(System.DefaultWorkingDirectory)/BicepFiles/main.bicep
- task: AzureCLI@2
displayName: 'Deploy Bicep Configuration'
inputs:
azureSubscription: 'my-azure-subscription'
scriptType: pscore
scriptLocation: inlineScript
addSpnToEnvironment: true
inlineScript: |
az group create --name function-rg --location eastus
az deployment group create --resource-group function-rg --template-file $(System.DefaultWorkingDirectory)/BicepFiles/main.json
Conclusion