|
| 1 | +targetScope = 'resourceGroup' |
| 2 | + |
| 3 | +@description('Short workload name.') |
| 4 | +param workloadName string |
| 5 | + |
| 6 | +@description('Deployment environment.') |
| 7 | +param environment string |
| 8 | + |
| 9 | +@description('Azure region.') |
| 10 | +param location string |
| 11 | + |
| 12 | +@description('Deterministic uniqueness suffix.') |
| 13 | +param suffix string |
| 14 | + |
| 15 | +@description('Non-secret Application Insights connection string injected by the platform.') |
| 16 | +param applicationInsightsConnectionString string |
| 17 | + |
| 18 | +@description('Log Analytics workspace identifier for diagnostic settings.') |
| 19 | +param logAnalyticsWorkspaceId string |
| 20 | + |
| 21 | +@description('Common Azure resource tags.') |
| 22 | +param tags object |
| 23 | + |
| 24 | +resource storageAccount 'Microsoft.Storage/storageAccounts@2025-01-01' = { |
| 25 | + name: 'st${workloadName}${environment}${suffix}' |
| 26 | + location: location |
| 27 | + tags: tags |
| 28 | + sku: { |
| 29 | + name: 'Standard_LRS' |
| 30 | + } |
| 31 | + kind: 'StorageV2' |
| 32 | + properties: { |
| 33 | + minimumTlsVersion: 'TLS1_2' |
| 34 | + allowBlobPublicAccess: false |
| 35 | + supportsHttpsTrafficOnly: true |
| 36 | + } |
| 37 | +} |
| 38 | + |
| 39 | +resource hostingPlan 'Microsoft.Web/serverfarms@2025-03-01' = { |
| 40 | + name: 'plan-${workloadName}-${environment}-${suffix}' |
| 41 | + location: location |
| 42 | + tags: tags |
| 43 | + sku: { |
| 44 | + name: 'FC1' |
| 45 | + tier: 'FlexConsumption' |
| 46 | + } |
| 47 | + properties: { |
| 48 | + reserved: true |
| 49 | + } |
| 50 | +} |
| 51 | + |
| 52 | +resource functionApp 'Microsoft.Web/sites@2025-03-01' = { |
| 53 | + name: 'func-${workloadName}-${environment}-${suffix}' |
| 54 | + location: location |
| 55 | + tags: tags |
| 56 | + kind: 'functionapp,linux' |
| 57 | + identity: { |
| 58 | + type: 'SystemAssigned' |
| 59 | + } |
| 60 | + properties: { |
| 61 | + serverFarmId: hostingPlan.id |
| 62 | + siteConfig: { |
| 63 | + linuxFxVersion: 'PYTHON|3.12' |
| 64 | + appSettings: [ |
| 65 | + { |
| 66 | + name: 'AzureWebJobsStorage' |
| 67 | + value: 'DefaultEndpointsProtocol=https;AccountName=${storageAccount.name};AccountKey=${storageAccount.listKeys().keys[0].value};EndpointSuffix=core.windows.net' |
| 68 | + } |
| 69 | + { |
| 70 | + name: 'APPLICATIONINSIGHTS_CONNECTION_STRING' |
| 71 | + value: applicationInsightsConnectionString |
| 72 | + } |
| 73 | + { |
| 74 | + name: 'FUNCTIONS_EXTENSION_VERSION' |
| 75 | + value: '~4' |
| 76 | + } |
| 77 | + { |
| 78 | + name: 'FUNCTIONS_WORKER_RUNTIME' |
| 79 | + value: 'python' |
| 80 | + } |
| 81 | + ] |
| 82 | + } |
| 83 | + httpsOnly: true |
| 84 | + } |
| 85 | +} |
| 86 | + |
| 87 | +#disable-next-line use-recent-api-versions |
| 88 | +resource appDiagnostics 'Microsoft.Insights/diagnosticSettings@2021-05-01-preview' = { |
| 89 | + name: 'send-to-log-analytics' |
| 90 | + scope: functionApp |
| 91 | + properties: { |
| 92 | + workspaceId: logAnalyticsWorkspaceId |
| 93 | + logs: [ |
| 94 | + { |
| 95 | + categoryGroup: 'allLogs' |
| 96 | + enabled: true |
| 97 | + } |
| 98 | + ] |
| 99 | + metrics: [ |
| 100 | + { |
| 101 | + category: 'AllMetrics' |
| 102 | + enabled: true |
| 103 | + } |
| 104 | + ] |
| 105 | + } |
| 106 | +} |
| 107 | + |
| 108 | +@description('Function App identifier.') |
| 109 | +output functionAppId string = functionApp.id |
| 110 | + |
| 111 | +@description('System-assigned managed identity principal identifier.') |
| 112 | +output workloadPrincipalId string = functionApp.identity.principalId |
0 commit comments