Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions Durable-Functions-Order-Processing.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.5.2.0
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OrderProcessor", "OrderProcessor\OrderProcessor.csproj", "{0288CA01-7BAB-2761-1E65-8139AFEA16AA}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{0288CA01-7BAB-2761-1E65-8139AFEA16AA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{0288CA01-7BAB-2761-1E65-8139AFEA16AA}.Debug|Any CPU.Build.0 = Debug|Any CPU
{0288CA01-7BAB-2761-1E65-8139AFEA16AA}.Release|Any CPU.ActiveCfg = Release|Any CPU
{0288CA01-7BAB-2761-1E65-8139AFEA16AA}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {55E95CFE-B613-4782-B6F6-7A40F4BF2A62}
EndGlobalSection
EndGlobal
17 changes: 9 additions & 8 deletions OrderProcessor/OrderProcessor.csproj
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<TargetFramework>net10.0</TargetFramework>
<AzureFunctionsVersion>v4</AzureFunctionsVersion>
<OutputType>Exe</OutputType>
<ImplicitUsings>enable</ImplicitUsings>
Expand All @@ -9,13 +9,14 @@
</PropertyGroup>
<ItemGroup>
<FrameworkReference Include="Microsoft.AspNetCore.App" />
<PackageReference Include="Microsoft.Azure.Functions.Worker" Version="1.23.0" />
<PackageReference Include="Microsoft.Azure.Functions.Worker.Extensions.DurableTask" Version="1.1.1" />
<PackageReference Include="Microsoft.Azure.Functions.Worker.Extensions.Http" Version="3.2.0" />
<PackageReference Include="Microsoft.Azure.Functions.Worker.Extensions.Http.AspNetCore" Version="1.3.2" />
<PackageReference Include="Microsoft.Azure.Functions.Worker.Sdk" Version="1.17.4" />
<PackageReference Include="Microsoft.ApplicationInsights.WorkerService" Version="2.22.0" />
<PackageReference Include="Microsoft.Azure.Functions.Worker.ApplicationInsights" Version="1.2.0" />
<PackageReference Include="Microsoft.Azure.Functions.Worker" Version="2.51.0" />
<PackageReference Include="Microsoft.Azure.Functions.Worker.Extensions.DurableTask" Version="1.14.1" />
<PackageReference Include="Microsoft.Azure.Functions.Worker.Extensions.DurableTask.AzureManaged" Version="1.4.0" />
<PackageReference Include="Microsoft.Azure.Functions.Worker.Extensions.Http" Version="3.3.0" />
<PackageReference Include="Microsoft.Azure.Functions.Worker.Extensions.Http.AspNetCore" Version="2.1.0" />
<PackageReference Include="Microsoft.Azure.Functions.Worker.Sdk" Version="2.0.7" />
<PackageReference Include="Microsoft.ApplicationInsights.WorkerService" Version="2.23.0" />
<PackageReference Include="Microsoft.Azure.Functions.Worker.ApplicationInsights" Version="2.50.0" />
</ItemGroup>
<ItemGroup>
<None Update="host.json">
Expand Down
13 changes: 7 additions & 6 deletions OrderProcessor/host.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,18 @@
"isEnabled": true,
"excludedTypes": "Request"
},
"enableLiveMetricsFilters": true,
"logLevel": {
"Host.Triggers.DurableTask": "Information"
}
"enableLiveMetricsFilters": true
},
"logLevel": {
"DurableTask.AzureManagedBackend": "Information"
}
},
"extensions": {
"durableTask": {
"hubName": "%TASKHUB_NAME%",
"storageProvider": {
"type": "AzureStorage",
"maxQueuePollingInterval": "00:00:01"
"type": "azureManaged",
"connectionStringName": "DURABLE_TASK_SCHEDULER_CONNECTION_STRING"
}
}
}
Expand Down
2 changes: 2 additions & 0 deletions infra/abbreviations.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@
"devicesProvisioningServices": "provs-",
"devicesProvisioningServicesCertificates": "pcert-",
"documentDBDatabaseAccounts": "cosmos-",
"durableTaskSchedulers": "dts-",
"durableTaskHubs": "th-",
"eventGridDomains": "evgd-",
"eventGridDomainsTopics": "evgt-",
"eventGridEventSubscriptions": "evgs-",
Expand Down
18 changes: 18 additions & 0 deletions infra/app/dts-Access.bicep
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
param principalID string
param roleDefinitionID string
param dtsName string
param principalType string

resource dts 'Microsoft.DurableTask/schedulers@2025-04-01-preview' existing = {
name: dtsName
}

resource dtsRoleAssignment 'Microsoft.Authorization/roleAssignments@2022-04-01' = {
name: guid(dts.id, principalID, roleDefinitionID)
scope: dts
properties: {
roleDefinitionId: resourceId('Microsoft.Authorization/roleDefinitions', roleDefinitionID)
principalId: principalID
principalType: principalType
}
}
31 changes: 31 additions & 0 deletions infra/app/dts.bicep
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
param ipAllowlist array
param location string
param tags object = {}
param name string
param taskhubname string
param skuName string
param skuCapacity int = 0

resource dts 'Microsoft.DurableTask/schedulers@2025-04-01-preview' = {
location: location
tags: tags
name: name
properties: {
ipAllowlist: ipAllowlist
sku: skuName == 'Consumption' ? {
name: skuName
} : {
name: skuName
capacity: skuCapacity
}
}
}

resource taskhub 'Microsoft.DurableTask/schedulers/taskHubs@2025-04-01-preview' = {
parent: dts
name: taskhubname
}

output dts_NAME string = dts.name
output dts_URL string = dts.properties.endpoint
output TASKHUB_NAME string = taskhub.name
11 changes: 10 additions & 1 deletion infra/app/processor.bicep
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,17 @@ param instanceMemoryMB int = 2048
param maximumInstanceCount int = 100
param identityId string = ''
param identityClientId string = ''
param dtsURL string = ''
param taskHubName string = ''

var applicationInsightsIdentity = 'ClientId=${identityClientId};Authorization=AAD'

// Durable Task Scheduler settings
var dtsSettings = !empty(dtsURL) ? {
DURABLE_TASK_SCHEDULER_CONNECTION_STRING: 'Endpoint=${dtsURL};Authentication=ManagedIdentity;ClientID=${identityClientId}'
TASKHUB_NAME: taskHubName
} : {}

module processor '../core/host/functions-flexconsumption.bicep' = {
name: '${serviceName}-functions-module'
params: {
Expand All @@ -28,7 +36,8 @@ module processor '../core/host/functions-flexconsumption.bicep' = {
{
AzureWebJobsStorage__clientId : identityClientId
APPLICATIONINSIGHTS_AUTHENTICATION_STRING: applicationInsightsIdentity
})
},
dtsSettings)
applicationInsightsName: applicationInsightsName
appServicePlanId: appServicePlanId
runtimeName: runtimeName
Expand Down
2 changes: 1 addition & 1 deletion infra/core/host/functions-flexconsumption.bicep
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ param identityId string
'dotnet-isolated', 'node', 'python', 'java', 'powershell', 'custom'
])
param runtimeName string
@allowed(['3.10', '3.11', '7.4', '8.0', '10', '11', '17', '20'])
@allowed(['3.10', '3.11', '7.4', '8.0', '10', '10.0', '11', '17', '20'])
param runtimeVersion string
param kind string = 'functionapp,linux'

Expand Down
59 changes: 57 additions & 2 deletions infra/main.bicep
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ param environmentName string

@minLength(1)
@description('Primary location for all resources')
@allowed(['australiaeast', 'eastasia', 'eastus', 'eastus2', 'northeurope', 'southcentralus', 'southeastasia', 'swedencentral', 'uksouth', 'westus2', 'eastus2euap'])
@allowed(['australiaeast', 'centralus', 'eastasia','eastus2', 'northeurope', 'southeastasia', 'swedencentral', 'uksouth', 'westus2'])
@metadata({
azd: {
type: 'location'
Expand All @@ -24,10 +24,19 @@ param resourceGroupName string = ''
param storageAccountName string = ''
param vNetName string = ''
param disableLocalAuth bool = true
param dtsName string = ''
param taskHubName string = ''
param dtsLocation string = location
param dtsSkuName string = 'Consumption'
param dtsCapacity int = 1
@description('Id of the user identity to be used for testing and debugging. This is not required in production. Leave empty if not needed.')
param principalId string = deployer().objectId

var abbrs = loadJsonContent('./abbreviations.json')
var resourceToken = toLower(uniqueString(subscription().id, environmentName, location))
var tags = { 'azd-env-name': environmentName }
var dtsResourceName = !empty(dtsName) ? dtsName : '${abbrs.durableTaskSchedulers}${resourceToken}'
var taskHubResourceName = !empty(taskHubName) ? taskHubName : '${abbrs.durableTaskHubs}${resourceToken}'

// Organize resources in a resource group
resource rg 'Microsoft.Resources/resourceGroups@2021-04-01' = {
Expand Down Expand Up @@ -58,13 +67,15 @@ module processor './app/processor.bicep' = {
applicationInsightsName: monitoring.outputs.applicationInsightsName
appServicePlanId: appServicePlan.outputs.id
runtimeName: 'dotnet-isolated'
runtimeVersion: '8.0'
runtimeVersion: '10.0'
storageAccountName: storage.outputs.name
identityId: processorUserAssignedIdentity.outputs.identityId
identityClientId: processorUserAssignedIdentity.outputs.identityClientId
appSettings: {
}
virtualNetworkSubnetId: serviceVirtualNetwork.outputs.appSubnetID
dtsURL: dts.outputs.dts_URL
taskHubName: dts.outputs.TASKHUB_NAME
}
}

Expand Down Expand Up @@ -191,6 +202,50 @@ module appInsightsRoleAssignmentApi './core/monitor/appinsights-access.bicep' =
}
}

// Durable Task Scheduler
module dts './app/dts.bicep' = {
scope: rg
name: 'dtsResource'
params: {
name: dtsResourceName
taskhubname: taskHubResourceName
location: dtsLocation
tags: tags
ipAllowlist: [
'0.0.0.0/0'
]
skuName: dtsSkuName
skuCapacity: dtsCapacity
}
}

// Durable Task Data Contributor role ID
var dtsRoleDefinitionId = '0ad04412-c4d5-4796-b79c-f76d14c8d402'

// Allow access from function app to DTS using user assigned managed identity
module dtsRoleAssignment 'app/dts-Access.bicep' = {
name: 'dtsRoleAssignment'
scope: rg
params: {
roleDefinitionID: dtsRoleDefinitionId
principalID: processorUserAssignedIdentity.outputs.identityPrincipalId
principalType: 'ServicePrincipal'
dtsName: dts.outputs.dts_NAME
}
}

// Allow the deployer identity to access the DTS dashboard
module dtsDashboardRoleAssignment 'app/dts-Access.bicep' = {
name: 'dtsDashboardRoleAssignment'
scope: rg
params: {
roleDefinitionID: dtsRoleDefinitionId
principalID: principalId
principalType: 'User'
dtsName: dts.outputs.dts_NAME
}
}

// App outputs
output APPLICATIONINSIGHTS_CONNECTION_STRING string = monitoring.outputs.applicationInsightsConnectionString
output AZURE_LOCATION string = location
Expand Down