Skip to content

Commit 6469999

Browse files
committed
feat: add web application configuration and Azure storage role assignments
1 parent 28c3f8d commit 6469999

6 files changed

Lines changed: 66 additions & 141 deletions

File tree

AppHost/infra/web.tmpl.yaml

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
api-version: 2024-02-02-preview
2+
location: {{ .Env.AZURE_LOCATION }}
3+
identity:
4+
type: UserAssigned
5+
userAssignedIdentities:
6+
? "{{ .Env.AZURE_CONTAINER_REGISTRY_MANAGED_IDENTITY_ID }}"
7+
: {}
8+
properties:
9+
environmentId: {{ .Env.AZURE_CONTAINER_APPS_ENVIRONMENT_ID }}
10+
configuration:
11+
activeRevisionsMode: single
12+
runtime:
13+
dotnet:
14+
autoConfigureDataProtection: true
15+
ingress:
16+
external: true
17+
targetPort: {{ targetPortOrDefault 8080 }}
18+
transport: http
19+
allowInsecure: false
20+
customDomains:
21+
- name: 'copilotthatjawn.com'
22+
bindingType: 'SniEnabled'
23+
certificateId: '/subscriptions/09153f92-3cbc-46f1-8872-1683749eda4b/resourceGroups/rg-copilotthatjawn/providers/Microsoft.App/managedEnvironments/cae-uanpydy4xv63a/managedCertificates/copilotthatjawn-com'
24+
- name: 'www.copilotthatjawn.com'
25+
bindingType: 'SniEnabled'
26+
certificateId: '/subscriptions/09153f92-3cbc-46f1-8872-1683749eda4b/resourceGroups/rg-copilotthatjawn/providers/Microsoft.App/managedEnvironments/cae-uanpydy4xv63a/managedCertificates/www-copilotthatjawn-com'
27+
registries:
28+
- server: {{ .Env.AZURE_CONTAINER_REGISTRY_ENDPOINT }}
29+
identity: {{ .Env.AZURE_CONTAINER_REGISTRY_MANAGED_IDENTITY_ID }}
30+
secrets:
31+
- name: connectionstrings--tables
32+
value: '{{ .Env.AZURE_STORAGE_TABLEENDPOINT }}'
33+
template:
34+
containers:
35+
- image: {{ .Image }}
36+
name: web
37+
env:
38+
- name: AZURE_CLIENT_ID
39+
value: {{ .Env.MANAGED_IDENTITY_CLIENT_ID }}
40+
- name: ASPNETCORE_FORWARDEDHEADERS_ENABLED
41+
value: "true"
42+
- name: HTTP_PORTS
43+
value: '{{ targetPortOrDefault 0 }}'
44+
- name: OTEL_DOTNET_EXPERIMENTAL_OTLP_EMIT_EVENT_LOG_ATTRIBUTES
45+
value: "true"
46+
- name: OTEL_DOTNET_EXPERIMENTAL_OTLP_EMIT_EXCEPTION_LOG_ATTRIBUTES
47+
value: "true"
48+
- name: OTEL_DOTNET_EXPERIMENTAL_OTLP_RETRY
49+
value: in_memory
50+
- name: ConnectionStrings__tables
51+
secretRef: connectionstrings--tables
52+
scale:
53+
minReplicas: 1
54+
tags:
55+
azd-service-name: web
56+
aspire-resource-name: web

AppHost/infra/web/web.tmpl.bicepparam

Lines changed: 0 additions & 10 deletions
This file was deleted.

infra/web-roles-azure-storage/web-roles-azure-storage.module.bicep renamed to infra/azure-storage-roles/azure-storage-roles.module.bicep

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ param location string = resourceGroup().location
33

44
param azure_storage_outputs_name string
55

6+
param principalType string
7+
68
param principalId string
79

810
resource azure_storage 'Microsoft.Storage/storageAccounts@2024-01-01' existing = {
@@ -14,7 +16,7 @@ resource azure_storage_StorageBlobDataContributor 'Microsoft.Authorization/roleA
1416
properties: {
1517
principalId: principalId
1618
roleDefinitionId: subscriptionResourceId('Microsoft.Authorization/roleDefinitions', 'ba92f5b4-2d11-453d-a403-e96b0029c9fe')
17-
principalType: 'ServicePrincipal'
19+
principalType: principalType
1820
}
1921
scope: azure_storage
2022
}
@@ -24,7 +26,7 @@ resource azure_storage_StorageTableDataContributor 'Microsoft.Authorization/role
2426
properties: {
2527
principalId: principalId
2628
roleDefinitionId: subscriptionResourceId('Microsoft.Authorization/roleDefinitions', '0a9a7e1f-b9d0-4cc4-a60d-0319b160aaa3')
27-
principalType: 'ServicePrincipal'
29+
principalType: principalType
2830
}
2931
scope: azure_storage
3032
}
@@ -34,7 +36,7 @@ resource azure_storage_StorageQueueDataContributor 'Microsoft.Authorization/role
3436
properties: {
3537
principalId: principalId
3638
roleDefinitionId: subscriptionResourceId('Microsoft.Authorization/roleDefinitions', '974c5e8b-45b9-4653-ba55-5f855dd0fb88')
37-
principalType: 'ServicePrincipal'
39+
principalType: principalType
3840
}
3941
scope: azure_storage
4042
}

infra/main.bicep

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ param location string
1212
@description('Id of the user or app to assign application roles')
1313
param principalId string = ''
1414

15+
1516
var tags = {
1617
'azd-env-name': environmentName
1718
}
@@ -38,20 +39,14 @@ module azure_storage 'azure-storage/azure-storage.module.bicep' = {
3839
location: location
3940
}
4041
}
41-
module web_identity 'web-identity/web-identity.module.bicep' = {
42-
name: 'web-identity'
43-
scope: rg
44-
params: {
45-
location: location
46-
}
47-
}
48-
module web_roles_azure_storage 'web-roles-azure-storage/web-roles-azure-storage.module.bicep' = {
49-
name: 'web-roles-azure-storage'
42+
module azure_storage_roles 'azure-storage-roles/azure-storage-roles.module.bicep' = {
43+
name: 'azure-storage-roles'
5044
scope: rg
5145
params: {
5246
azure_storage_outputs_name: azure_storage.outputs.name
5347
location: location
54-
principalId: web_identity.outputs.principalId
48+
principalId: resources.outputs.MANAGED_IDENTITY_PRINCIPAL_ID
49+
principalType: 'ServicePrincipal'
5550
}
5651
}
5752

@@ -65,5 +60,3 @@ output AZURE_CONTAINER_APPS_ENVIRONMENT_NAME string = resources.outputs.AZURE_CO
6560
output AZURE_CONTAINER_APPS_ENVIRONMENT_ID string = resources.outputs.AZURE_CONTAINER_APPS_ENVIRONMENT_ID
6661
output AZURE_CONTAINER_APPS_ENVIRONMENT_DEFAULT_DOMAIN string = resources.outputs.AZURE_CONTAINER_APPS_ENVIRONMENT_DEFAULT_DOMAIN
6762
output AZURE_STORAGE_TABLEENDPOINT string = azure_storage.outputs.tableEndpoint
68-
output WEB_IDENTITY_CLIENTID string = web_identity.outputs.clientId
69-
output WEB_IDENTITY_ID string = web_identity.outputs.id

infra/web-identity/web-identity.module.bicep

Lines changed: 0 additions & 15 deletions
This file was deleted.

infra/web/web.module.bicep

Lines changed: 0 additions & 101 deletions
This file was deleted.

0 commit comments

Comments
 (0)