Skip to content

Commit 2708dfc

Browse files
committed
Get shared-key version working as well
1 parent c9cd4cc commit 2708dfc

File tree

2 files changed

+21
-21
lines changed

2 files changed

+21
-21
lines changed

rg.bicep

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ resource packageContainer 'Microsoft.Storage/storageAccounts/blobServices/contai
6363
properties: {
6464
}
6565
}
66-
resource pythonContainer 'Microsoft.Storage/storageAccounts/blobServices/containers@2025-01-01' = if (!use_shared_keys) {
66+
resource pythonContainer 'Microsoft.Storage/storageAccounts/blobServices/containers@2025-01-01' = {
6767
parent: defBlobServices
6868
name: python_container_name
6969
properties: {
@@ -139,4 +139,4 @@ output apt_sources string = 'deb [trusted=yes] blob://${storageAccount.name}.blo
139139
output function_app_name string = appName
140140
output storage_account string = storageAccount.name
141141
output package_container string = packageContainer.name
142-
output python_container string = use_shared_keys ? '' : pythonContainer.name
142+
output python_container string = pythonContainer.name

rg_funcapp.bicep

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ var package_container_name = 'packages'
2727
// Create a container for the Python code
2828
var python_container_name = 'python'
2929

30+
var storage_connection_string = 'DefaultEndpointsProtocol=https;AccountName=${storageAccount.name};EndpointSuffix=${environment().suffixes.storage};AccountKey=${storageAccount.listKeys().keys[0].value}'
31+
3032
// The version of Python to run with
3133
var python_version = '3.11'
3234

@@ -50,7 +52,7 @@ resource packageContainer 'Microsoft.Storage/storageAccounts/blobServices/contai
5052
parent: defBlobServices
5153
name: package_container_name
5254
}
53-
resource pythonContainer 'Microsoft.Storage/storageAccounts/blobServices/containers@2025-01-01' existing = if (!use_shared_keys) {
55+
resource pythonContainer 'Microsoft.Storage/storageAccounts/blobServices/containers@2025-01-01' existing = {
5456
parent: defBlobServices
5557
name: python_container_name
5658
}
@@ -108,15 +110,11 @@ var common_settings = [
108110
var app_settings = use_shared_keys ? concat(common_settings, [
109111
{
110112
name: 'AzureWebJobsStorage'
111-
value: 'DefaultEndpointsProtocol=https;AccountName=${storageAccount.name};EndpointSuffix=${environment().suffixes.storage};AccountKey=${storageAccount.listKeys().keys[0].value}'
112-
}
113-
{
114-
name: 'WEBSITE_CONTENTAZUREFILECONNECTIONSTRING'
115-
value: 'DefaultEndpointsProtocol=https;AccountName=${storageAccount.name};EndpointSuffix=${environment().suffixes.storage};AccountKey=${storageAccount.listKeys().keys[0].value}'
113+
value: storage_connection_string
116114
}
117115
{
118-
name: 'WEBSITE_CONTENTSHARE'
119-
value: toLower(functionAppName)
116+
name: 'DEPLOYMENT_STORAGE_CONNECTION_STRING'
117+
value: storage_connection_string
120118
}
121119
]) : concat(common_settings, [
122120
{
@@ -134,13 +132,20 @@ var function_runtime = {
134132
version: python_version
135133
}
136134

135+
var deployment_storage_value = 'https://${storageAccount.name}.blob.${environment().suffixes.storage}/${pythonContainer.name}'
136+
137+
var deployment_authentication = use_shared_keys ? {
138+
type: 'StorageAccountConnectionString'
139+
storageAccountConnectionStringName: 'DEPLOYMENT_STORAGE_CONNECTION_STRING'
140+
} : {
141+
type: 'SystemAssignedIdentity'
142+
}
143+
137144
var flex_deployment_configuration = {
138145
storage: {
139146
type: 'blobContainer'
140-
value: 'https://${storageAccount.name}.blob.${environment().suffixes.storage}/${pythonContainer.name}'
141-
authentication: {
142-
type: 'SystemAssignedIdentity'
143-
}
147+
value: deployment_storage_value
148+
authentication: deployment_authentication
144149
}
145150
}
146151

@@ -149,16 +154,11 @@ var flex_scale_and_concurrency = {
149154
instanceMemoryMB: 2048
150155
}
151156

152-
// Define common app config
153-
var common_app_config = {
157+
var function_app_config = {
154158
runtime: function_runtime
155159
scaleAndConcurrency: flex_scale_and_concurrency
156-
}
157-
158-
// For managed identity, add the deployment configuration, otherwise just use common config
159-
var function_app_config = use_shared_keys ? common_app_config : union(common_app_config, {
160160
deployment: flex_deployment_configuration
161-
})
161+
}
162162

163163
// Create the function app.
164164
resource functionApp 'Microsoft.Web/sites@2024-11-01' = {

0 commit comments

Comments
 (0)