Pamela Fox commited on
Commit
cd77237
·
1 Parent(s): d9e656a

update infra

Browse files
infra/core/host/appservice-appsettings.bicep ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ metadata description = 'Updates app settings for an Azure App Service.'
2
+ @description('The name of the app service resource within the current resource group scope')
3
+ param name string
4
+
5
+ @description('The app settings to be applied to the app service')
6
+ @secure()
7
+ param appSettings object
8
+
9
+ resource appService 'Microsoft.Web/sites@2022-03-01' existing = {
10
+ name: name
11
+ }
12
+
13
+ resource settings 'Microsoft.Web/sites/config@2022-03-01' = {
14
+ name: 'appsettings'
15
+ parent: appService
16
+ properties: appSettings
17
+ }
infra/core/host/appservice.bicep CHANGED
@@ -1,3 +1,4 @@
 
1
  param name string
2
  param location string = resourceGroup().location
3
  param tags object = {}
@@ -23,6 +24,7 @@ param kind string = 'app,linux'
23
  param allowedOrigins array = []
24
  param alwaysOn bool = true
25
  param appCommandLine string = ''
 
26
  param appSettings object = {}
27
  param clientAffinityEnabled bool = false
28
  param enableOryxBuild bool = contains(kind, 'linux')
@@ -63,29 +65,49 @@ resource appService 'Microsoft.Web/sites@2022-03-01' = {
63
 
64
  identity: { type: managedIdentity ? 'SystemAssigned' : 'None' }
65
 
66
- resource configAppSettings 'config' = {
67
- name: 'appsettings'
68
- properties: union(appSettings,
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
69
  {
70
  SCM_DO_BUILD_DURING_DEPLOYMENT: string(scmDoBuildDuringDeployment)
71
  ENABLE_ORYX_BUILD: string(enableOryxBuild)
72
  },
 
73
  !empty(applicationInsightsName) ? { APPLICATIONINSIGHTS_CONNECTION_STRING: applicationInsights.properties.ConnectionString } : {},
74
  !empty(keyVaultName) ? { AZURE_KEY_VAULT_ENDPOINT: keyVault.properties.vaultUri } : {})
75
  }
 
76
 
77
- resource configLogs 'config' = {
78
- name: 'logs'
79
- properties: {
80
- applicationLogs: { fileSystem: { level: 'Verbose' } }
81
- detailedErrorMessages: { enabled: true }
82
- failedRequestsTracing: { enabled: true }
83
- httpLogs: { fileSystem: { enabled: true, retentionInDays: 1, retentionInMb: 35 } }
84
- }
85
- dependsOn: [
86
- configAppSettings
87
- ]
88
  }
 
89
  }
90
 
91
  resource keyVault 'Microsoft.KeyVault/vaults@2022-07-01' existing = if (!(empty(keyVaultName))) {
 
1
+ metadata description = 'Creates an Azure App Service in an existing Azure App Service plan.'
2
  param name string
3
  param location string = resourceGroup().location
4
  param tags object = {}
 
24
  param allowedOrigins array = []
25
  param alwaysOn bool = true
26
  param appCommandLine string = ''
27
+ @secure()
28
  param appSettings object = {}
29
  param clientAffinityEnabled bool = false
30
  param enableOryxBuild bool = contains(kind, 'linux')
 
65
 
66
  identity: { type: managedIdentity ? 'SystemAssigned' : 'None' }
67
 
68
+ resource basicPublishingCredentialsPoliciesFtp 'basicPublishingCredentialsPolicies' = {
69
+ name: 'ftp'
70
+ properties: {
71
+ allow: false
72
+ }
73
+ }
74
+
75
+ resource basicPublishingCredentialsPoliciesScm 'basicPublishingCredentialsPolicies' = {
76
+ name: 'scm'
77
+ properties: {
78
+ allow: false
79
+ }
80
+ }
81
+ }
82
+
83
+ // Updates to the single Microsoft.sites/web/config resources that need to be performed sequentially
84
+ // sites/web/config 'appsettings'
85
+ module configAppSettings 'appservice-appsettings.bicep' = {
86
+ name: '${name}-appSettings'
87
+ params: {
88
+ name: appService.name
89
+ appSettings: union(appSettings,
90
  {
91
  SCM_DO_BUILD_DURING_DEPLOYMENT: string(scmDoBuildDuringDeployment)
92
  ENABLE_ORYX_BUILD: string(enableOryxBuild)
93
  },
94
+ runtimeName == 'python' && appCommandLine == '' ? { PYTHON_ENABLE_GUNICORN_MULTIWORKERS: 'true'} : {},
95
  !empty(applicationInsightsName) ? { APPLICATIONINSIGHTS_CONNECTION_STRING: applicationInsights.properties.ConnectionString } : {},
96
  !empty(keyVaultName) ? { AZURE_KEY_VAULT_ENDPOINT: keyVault.properties.vaultUri } : {})
97
  }
98
+ }
99
 
100
+ // sites/web/config 'logs'
101
+ resource configLogs 'Microsoft.Web/sites/config@2022-03-01' = {
102
+ name: 'logs'
103
+ parent: appService
104
+ properties: {
105
+ applicationLogs: { fileSystem: { level: 'Verbose' } }
106
+ detailedErrorMessages: { enabled: true }
107
+ failedRequestsTracing: { enabled: true }
108
+ httpLogs: { fileSystem: { enabled: true, retentionInDays: 1, retentionInMb: 35 } }
 
 
109
  }
110
+ dependsOn: [configAppSettings]
111
  }
112
 
113
  resource keyVault 'Microsoft.KeyVault/vaults@2022-07-01' existing = if (!(empty(keyVaultName))) {
infra/core/host/appserviceplan.bicep CHANGED
@@ -1,3 +1,4 @@
 
1
  param name string
2
  param location string = resourceGroup().location
3
  param tags object = {}
@@ -18,3 +19,4 @@ resource appServicePlan 'Microsoft.Web/serverfarms@2022-03-01' = {
18
  }
19
 
20
  output id string = appServicePlan.id
 
 
1
+ metadata description = 'Creates an Azure App Service plan.'
2
  param name string
3
  param location string = resourceGroup().location
4
  param tags object = {}
 
19
  }
20
 
21
  output id string = appServicePlan.id
22
+ output name string = appServicePlan.name
infra/core/host/container-app.bicep DELETED
@@ -1,77 +0,0 @@
1
- param name string
2
- param location string = resourceGroup().location
3
- param tags object = {}
4
-
5
- param containerAppsEnvironmentName string = ''
6
- param containerName string = 'main'
7
- param containerRegistryName string = ''
8
- param env array = []
9
- param external bool = true
10
- param imageName string
11
- param keyVaultName string = ''
12
- param managedIdentity bool = !empty(keyVaultName)
13
- param targetPort int = 80
14
-
15
- @description('CPU cores allocated to a single container instance, e.g. 0.5')
16
- param containerCpuCoreCount string = '0.5'
17
-
18
- @description('Memory allocated to a single container instance, e.g. 1Gi')
19
- param containerMemory string = '1.0Gi'
20
-
21
- resource app 'Microsoft.App/containerApps@2022-03-01' = {
22
- name: name
23
- location: location
24
- tags: tags
25
- identity: { type: managedIdentity ? 'SystemAssigned' : 'None' }
26
- properties: {
27
- managedEnvironmentId: containerAppsEnvironment.id
28
- configuration: {
29
- activeRevisionsMode: 'single'
30
- ingress: {
31
- external: external
32
- targetPort: targetPort
33
- transport: 'auto'
34
- }
35
- secrets: [
36
- {
37
- name: 'registry-password'
38
- value: containerRegistry.listCredentials().passwords[0].value
39
- }
40
- ]
41
- registries: [
42
- {
43
- server: '${containerRegistry.name}.azurecr.io'
44
- username: containerRegistry.name
45
- passwordSecretRef: 'registry-password'
46
- }
47
- ]
48
- }
49
- template: {
50
- containers: [
51
- {
52
- image: imageName
53
- name: containerName
54
- env: env
55
- resources: {
56
- cpu: json(containerCpuCoreCount)
57
- memory: containerMemory
58
- }
59
- }
60
- ]
61
- }
62
- }
63
- }
64
-
65
- resource containerAppsEnvironment 'Microsoft.App/managedEnvironments@2022-03-01' existing = {
66
- name: containerAppsEnvironmentName
67
- }
68
-
69
- // 2022-02-01-preview needed for anonymousPullEnabled
70
- resource containerRegistry 'Microsoft.ContainerRegistry/registries@2022-02-01-preview' existing = {
71
- name: containerRegistryName
72
- }
73
-
74
- output identityPrincipalId string = managedIdentity ? app.identity.principalId : ''
75
- output imageName string = imageName
76
- output name string = app.name
77
- output uri string = 'https://${app.properties.configuration.ingress.fqdn}'
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
infra/core/host/container-apps-environment.bicep DELETED
@@ -1,26 +0,0 @@
1
- param name string
2
- param location string = resourceGroup().location
3
- param tags object = {}
4
-
5
- param logAnalyticsWorkspaceName string
6
-
7
- resource containerAppsEnvironment 'Microsoft.App/managedEnvironments@2022-03-01' = {
8
- name: name
9
- location: location
10
- tags: tags
11
- properties: {
12
- appLogsConfiguration: {
13
- destination: 'log-analytics'
14
- logAnalyticsConfiguration: {
15
- customerId: logAnalyticsWorkspace.properties.customerId
16
- sharedKey: logAnalyticsWorkspace.listKeys().primarySharedKey
17
- }
18
- }
19
- }
20
- }
21
-
22
- resource logAnalyticsWorkspace 'Microsoft.OperationalInsights/workspaces@2022-10-01' existing = {
23
- name: logAnalyticsWorkspaceName
24
- }
25
-
26
- output name string = containerAppsEnvironment.name
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
infra/core/host/container-apps.bicep DELETED
@@ -1,30 +0,0 @@
1
- param name string
2
- param location string = resourceGroup().location
3
- param tags object = {}
4
-
5
- param containerAppsEnvironmentName string = ''
6
- param containerRegistryName string = ''
7
- param logAnalyticsWorkspaceName string = ''
8
-
9
- module containerAppsEnvironment 'container-apps-environment.bicep' = {
10
- name: '${name}-container-apps-environment'
11
- params: {
12
- name: containerAppsEnvironmentName
13
- location: location
14
- tags: tags
15
- logAnalyticsWorkspaceName: logAnalyticsWorkspaceName
16
- }
17
- }
18
-
19
- module containerRegistry 'container-registry.bicep' = {
20
- name: '${name}-container-registry'
21
- params: {
22
- name: containerRegistryName
23
- location: location
24
- tags: tags
25
- }
26
- }
27
-
28
- output environmentName string = containerAppsEnvironment.outputs.name
29
- output registryLoginServer string = containerRegistry.outputs.loginServer
30
- output registryName string = containerRegistry.outputs.name
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
infra/core/host/container-registry.bicep DELETED
@@ -1,36 +0,0 @@
1
- param name string
2
- param location string = resourceGroup().location
3
- param tags object = {}
4
-
5
- param adminUserEnabled bool = true
6
- param anonymousPullEnabled bool = false
7
- param dataEndpointEnabled bool = false
8
- param encryption object = {
9
- status: 'disabled'
10
- }
11
- param networkRuleBypassOptions string = 'AzureServices'
12
- param publicNetworkAccess string = 'Enabled'
13
- param sku object = {
14
- name: 'Basic'
15
- }
16
- param zoneRedundancy string = 'Disabled'
17
-
18
- // 2022-02-01-preview needed for anonymousPullEnabled
19
- resource containerRegistry 'Microsoft.ContainerRegistry/registries@2022-02-01-preview' = {
20
- name: name
21
- location: location
22
- tags: tags
23
- sku: sku
24
- properties: {
25
- adminUserEnabled: adminUserEnabled
26
- anonymousPullEnabled: anonymousPullEnabled
27
- dataEndpointEnabled: dataEndpointEnabled
28
- encryption: encryption
29
- networkRuleBypassOptions: networkRuleBypassOptions
30
- publicNetworkAccess: publicNetworkAccess
31
- zoneRedundancy: zoneRedundancy
32
- }
33
- }
34
-
35
- output loginServer string = containerRegistry.properties.loginServer
36
- output name string = containerRegistry.name
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
infra/core/host/functions.bicep DELETED
@@ -1,82 +0,0 @@
1
- param name string
2
- param location string = resourceGroup().location
3
- param tags object = {}
4
-
5
- // Reference Properties
6
- param applicationInsightsName string = ''
7
- param appServicePlanId string
8
- param keyVaultName string = ''
9
- param managedIdentity bool = !empty(keyVaultName)
10
- param storageAccountName string
11
-
12
- // Runtime Properties
13
- @allowed([
14
- 'dotnet', 'dotnetcore', 'dotnet-isolated', 'node', 'python', 'java', 'powershell', 'custom'
15
- ])
16
- param runtimeName string
17
- param runtimeNameAndVersion string = '${runtimeName}|${runtimeVersion}'
18
- param runtimeVersion string
19
-
20
- // Function Settings
21
- @allowed([
22
- '~4', '~3', '~2', '~1'
23
- ])
24
- param extensionVersion string = '~4'
25
-
26
- // Microsoft.Web/sites Properties
27
- param kind string = 'functionapp,linux'
28
-
29
- // Microsoft.Web/sites/config
30
- param allowedOrigins array = []
31
- param alwaysOn bool = true
32
- param appCommandLine string = ''
33
- param appSettings object = {}
34
- param clientAffinityEnabled bool = false
35
- param enableOryxBuild bool = contains(kind, 'linux')
36
- param functionAppScaleLimit int = -1
37
- param linuxFxVersion string = runtimeNameAndVersion
38
- param minimumElasticInstanceCount int = -1
39
- param numberOfWorkers int = -1
40
- param scmDoBuildDuringDeployment bool = true
41
- param use32BitWorkerProcess bool = false
42
-
43
- module functions 'appservice.bicep' = {
44
- name: '${name}-functions'
45
- params: {
46
- name: name
47
- location: location
48
- tags: tags
49
- allowedOrigins: allowedOrigins
50
- alwaysOn: alwaysOn
51
- appCommandLine: appCommandLine
52
- applicationInsightsName: applicationInsightsName
53
- appServicePlanId: appServicePlanId
54
- appSettings: union(appSettings, {
55
- AzureWebJobsStorage: 'DefaultEndpointsProtocol=https;AccountName=${storage.name};AccountKey=${storage.listKeys().keys[0].value};EndpointSuffix=${environment().suffixes.storage}'
56
- FUNCTIONS_EXTENSION_VERSION: extensionVersion
57
- FUNCTIONS_WORKER_RUNTIME: runtimeName
58
- })
59
- clientAffinityEnabled: clientAffinityEnabled
60
- enableOryxBuild: enableOryxBuild
61
- functionAppScaleLimit: functionAppScaleLimit
62
- keyVaultName: keyVaultName
63
- kind: kind
64
- linuxFxVersion: linuxFxVersion
65
- managedIdentity: managedIdentity
66
- minimumElasticInstanceCount: minimumElasticInstanceCount
67
- numberOfWorkers: numberOfWorkers
68
- runtimeName: runtimeName
69
- runtimeVersion: runtimeVersion
70
- runtimeNameAndVersion: runtimeNameAndVersion
71
- scmDoBuildDuringDeployment: scmDoBuildDuringDeployment
72
- use32BitWorkerProcess: use32BitWorkerProcess
73
- }
74
- }
75
-
76
- resource storage 'Microsoft.Storage/storageAccounts@2021-09-01' existing = {
77
- name: storageAccountName
78
- }
79
-
80
- output identityPrincipalId string = managedIdentity ? functions.outputs.identityPrincipalId : ''
81
- output name string = functions.outputs.name
82
- output uri string = functions.outputs.uri
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
infra/core/host/staticwebapp.bicep DELETED
@@ -1,21 +0,0 @@
1
- param name string
2
- param location string = resourceGroup().location
3
- param tags object = {}
4
-
5
- param sku object = {
6
- name: 'Free'
7
- tier: 'Free'
8
- }
9
-
10
- resource web 'Microsoft.Web/staticSites@2022-03-01' = {
11
- name: name
12
- location: location
13
- tags: tags
14
- sku: sku
15
- properties: {
16
- provider: 'Custom'
17
- }
18
- }
19
-
20
- output name string = web.name
21
- output uri string = 'https://${web.properties.defaultHostname}'