Skip to content

05 - Infrastructure as Code (Dedicated)

Define your Dedicated (App Service Plan) PowerShell app in Bicep for reproducible deployments.

Bicep Template

param appName string
param location string = resourceGroup().location
param storageName string

resource storage 'Microsoft.Storage/storageAccounts@2023-01-01' = {
  name: storageName
  location: location
  sku: { name: 'Standard_LRS' }
  kind: 'StorageV2'
}

resource app 'Microsoft.Web/sites@2023-12-01' = {
  name: appName
  location: location
  kind: 'functionapp,linux'
  properties: {
    siteConfig: {
      appSettings: [
        { name: 'FUNCTIONS_EXTENSION_VERSION', value: '~4' }
        { name: 'FUNCTIONS_WORKER_RUNTIME', value: 'powershell' }
        { name: 'FUNCTIONS_WORKER_RUNTIME_VERSION', value: '7.4' }
      ]
    }
  }
}

Deploy

az deployment group create \
  --resource-group $RG \
  --template-file infra/main.bicep \
  --parameters appName=$APP_NAME storageName=$STORAGE_NAME
| Command/Parameter | Purpose | | --- | --- | | az deployment group create | Deploy the Bicep template to the resource group. | | --resource-group | Target resource group for the deployment. | | --template-file | Path to the Bicep template. | | --parameters | Template parameter values. |

Verification

az deployment group show --resource-group $RG --name main --query properties.provisioningState
| Command/Parameter | Purpose | | --- | --- | | az deployment group show | Show the status of a completed deployment. | | --resource-group | Resource group that contains the deployment. | | --name | Name of the deployment. | | --query | JMESPath query selecting the provisioning state. |

Returns Succeeded.

Next Steps

Automate the build and deploy with CI/CD.

Next: 06 - CI/CD

See Also

Sources