Created
May 3, 2022 08:17
-
-
Save shibayan/21290078e52d3de187fd820491a24f03 to your computer and use it in GitHub Desktop.
Deploying Durable Functions to Azure Container Apps
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
param appName string | |
param location string = resourceGroup().location | |
resource logAnalyticsWorkspace 'Microsoft.OperationalInsights/workspaces@2020-10-01' = { | |
name: 'log-${appName}' | |
location: location | |
properties: { | |
retentionInDays: 30 | |
sku: { | |
name: 'PerGB2018' | |
} | |
} | |
} | |
resource managedEnvironment 'Microsoft.App/managedEnvironments@2022-01-01-preview' = { | |
name: 'cae-${appName}' | |
location: location | |
properties: { | |
appLogsConfiguration: { | |
destination: 'log-analytics' | |
logAnalyticsConfiguration: { | |
customerId: logAnalyticsWorkspace.properties.customerId | |
sharedKey: listKeys(logAnalyticsWorkspace.id, logAnalyticsWorkspace.apiVersion).primarySharedKey | |
} | |
} | |
} | |
} | |
resource storageAccount 'Microsoft.Storage/storageAccounts@2021-08-01' = { | |
name: 'st${appName}' | |
location: location | |
kind: 'StorageV2' | |
sku: { | |
name: 'Standard_LRS' | |
} | |
} | |
resource appInsights 'Microsoft.Insights/components@2020-02-02' = { | |
name: 'appi-${appName}' | |
location: location | |
kind: 'web' | |
properties: { | |
Application_Type: 'web' | |
} | |
} | |
var scaleRules = [for i in range(0, 4): { | |
name: format('{0}-control-{1:D2}', appName, i) | |
azureQueue: { | |
queueName: format('{0}-control-{1:D2}', appName, i) | |
queueLength: 5 | |
auth: [ | |
{ | |
secretRef: 'azure-functions-storage' | |
triggerParameter: 'connection' | |
} | |
] | |
} | |
}] | |
resource containerApp 'Microsoft.App/containerApps@2022-01-01-preview' = { | |
name: 'capp-${appName}' | |
location: location | |
properties: { | |
managedEnvironmentId: managedEnvironment.id | |
configuration: { | |
activeRevisionsMode: 'single' | |
ingress: { | |
external: true | |
targetPort: 80 | |
} | |
secrets: [ | |
{ | |
name: 'azure-functions-storage' | |
value: 'DefaultEndpointsProtocol=https;AccountName=${storageAccount.name};EndpointSuffix=${environment().suffixes.storage};AccountKey=${storageAccount.listKeys().keys[0].value}' | |
} | |
] | |
} | |
template: { | |
containers: [ | |
{ | |
image: 'docker.io/shibayan/durabletest:20220502135304' | |
name: appName | |
env: [ | |
{ | |
name: 'APPLICATIONINSIGHTS_CONNECTION_STRING' | |
value: appInsights.properties.ConnectionString | |
} | |
{ | |
name: 'AzureWebJobsStorage' | |
secretRef: 'azure-functions-storage' | |
} | |
{ | |
name: 'WEBSITE_SITE_NAME' | |
value: appName | |
} | |
] | |
resources: { | |
cpu: '0.25' | |
memory: '0.5Gi' | |
} | |
} | |
] | |
scale: { | |
minReplicas: 0 | |
maxReplicas: 10 | |
rules: union([ | |
{ | |
name: '${appName}-workitems' | |
azureQueue: { | |
queueName: '${appName}-workitems' | |
queueLength: 5 | |
auth: [ | |
{ | |
secretRef: 'azure-functions-storage' | |
triggerParameter: 'connection' | |
} | |
] | |
} | |
} | |
], scaleRules) | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment