Skip to content

Commit

Permalink
fix: Fix generate_arm_templates.sh script, reformat all Bicep files (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
cecheta authored May 15, 2024
1 parent c750216 commit 8c46627
Show file tree
Hide file tree
Showing 14 changed files with 409 additions and 118 deletions.
80 changes: 70 additions & 10 deletions infra/app/adminweb.bicep
Original file line number Diff line number Diff line change
Expand Up @@ -38,20 +38,80 @@ module adminweb '../core/host/appservice.bicep' = {
runtimeName: runtimeName
runtimeVersion: runtimeVersion
keyVaultName: keyVaultName
dockerFullImageName: dockerFullImageName
dockerFullImageName: dockerFullImageName
scmDoBuildDuringDeployment: useDocker ? false : true
applicationInsightsName: applicationInsightsName
appServicePlanId: appServicePlanId
appSettings: union(appSettings, {
AZURE_AUTH_TYPE: authType
USE_KEY_VAULT: useKeyVault ? useKeyVault : ''
AZURE_OPENAI_API_KEY: useKeyVault ? openAIKeyName : listKeys(resourceId(subscription().subscriptionId, resourceGroup().name, 'Microsoft.CognitiveServices/accounts', azureOpenAIName), '2023-05-01').key1
AZURE_SEARCH_KEY: useKeyVault ? searchKeyName : listAdminKeys(resourceId(subscription().subscriptionId, resourceGroup().name, 'Microsoft.Search/searchServices', azureAISearchName), '2021-04-01-preview').primaryKey
AZURE_BLOB_ACCOUNT_KEY: useKeyVault ? storageAccountKeyName : listKeys(resourceId(subscription().subscriptionId, resourceGroup().name, 'Microsoft.Storage/storageAccounts', storageAccountName), '2021-09-01').keys[0].value
AZURE_FORM_RECOGNIZER_KEY: useKeyVault ? formRecognizerKeyName : listKeys(resourceId(subscription().subscriptionId, resourceGroup().name, 'Microsoft.CognitiveServices/accounts', formRecognizerName), '2023-05-01').key1
AZURE_CONTENT_SAFETY_KEY: useKeyVault ? contentSafetyKeyName : listKeys(resourceId(subscription().subscriptionId, resourceGroup().name, 'Microsoft.CognitiveServices/accounts', contentSafetyName), '2023-05-01').key1
AZURE_SPEECH_SERVICE_KEY: useKeyVault ? speechKeyName : listKeys(resourceId(subscription().subscriptionId, resourceGroup().name, 'Microsoft.CognitiveServices/accounts', speechServiceName), '2023-05-01').key1
})
AZURE_AUTH_TYPE: authType
USE_KEY_VAULT: useKeyVault ? useKeyVault : ''
AZURE_OPENAI_API_KEY: useKeyVault
? openAIKeyName
: listKeys(
resourceId(
subscription().subscriptionId,
resourceGroup().name,
'Microsoft.CognitiveServices/accounts',
azureOpenAIName
),
'2023-05-01'
).key1
AZURE_SEARCH_KEY: useKeyVault
? searchKeyName
: listAdminKeys(
resourceId(
subscription().subscriptionId,
resourceGroup().name,
'Microsoft.Search/searchServices',
azureAISearchName
),
'2021-04-01-preview'
).primaryKey
AZURE_BLOB_ACCOUNT_KEY: useKeyVault
? storageAccountKeyName
: listKeys(
resourceId(
subscription().subscriptionId,
resourceGroup().name,
'Microsoft.Storage/storageAccounts',
storageAccountName
),
'2021-09-01'
).keys[0].value
AZURE_FORM_RECOGNIZER_KEY: useKeyVault
? formRecognizerKeyName
: listKeys(
resourceId(
subscription().subscriptionId,
resourceGroup().name,
'Microsoft.CognitiveServices/accounts',
formRecognizerName
),
'2023-05-01'
).key1
AZURE_CONTENT_SAFETY_KEY: useKeyVault
? contentSafetyKeyName
: listKeys(
resourceId(
subscription().subscriptionId,
resourceGroup().name,
'Microsoft.CognitiveServices/accounts',
contentSafetyName
),
'2023-05-01'
).key1
AZURE_SPEECH_SERVICE_KEY: useKeyVault
? speechKeyName
: listKeys(
resourceId(
subscription().subscriptionId,
resourceGroup().name,
'Microsoft.CognitiveServices/accounts',
speechServiceName
),
'2023-05-01'
).key1
})
}
}

Expand Down
92 changes: 81 additions & 11 deletions infra/app/function.bicep
Original file line number Diff line number Diff line change
Expand Up @@ -42,17 +42,87 @@ module function '../core/host/functions.bicep' = {
runtimeVersion: runtimeVersion
dockerFullImageName: dockerFullImageName
appSettings: union(appSettings, {
WEBSITES_ENABLE_APP_SERVICE_STORAGE: 'false'
AZURE_AUTH_TYPE: authType
USE_KEY_VAULT: useKeyVault ? useKeyVault : ''
AZURE_OPENAI_API_KEY: useKeyVault ? openAIKeyName : listKeys(resourceId(subscription().subscriptionId, resourceGroup().name, 'Microsoft.CognitiveServices/accounts', azureOpenAIName), '2023-05-01').key1
AZURE_SEARCH_KEY: useKeyVault ? searchKeyName : listAdminKeys(resourceId(subscription().subscriptionId, resourceGroup().name, 'Microsoft.Search/searchServices', azureAISearchName), '2021-04-01-preview').primaryKey
AZURE_BLOB_ACCOUNT_KEY: useKeyVault ? storageAccountKeyName : listKeys(resourceId(subscription().subscriptionId, resourceGroup().name, 'Microsoft.Storage/storageAccounts', storageAccountName), '2021-09-01').keys[0].value
AZURE_FORM_RECOGNIZER_KEY: useKeyVault ? formRecognizerKeyName : listKeys(resourceId(subscription().subscriptionId, resourceGroup().name, 'Microsoft.CognitiveServices/accounts', formRecognizerName), '2023-05-01').key1
AZURE_CONTENT_SAFETY_KEY: useKeyVault ? contentSafetyKeyName : listKeys(resourceId(subscription().subscriptionId, resourceGroup().name, 'Microsoft.CognitiveServices/accounts', contentSafetyName), '2023-05-01').key1
AZURE_SPEECH_SERVICE_KEY: useKeyVault ? speechKeyName : listKeys(resourceId(subscription().subscriptionId, resourceGroup().name, 'Microsoft.CognitiveServices/accounts', speechServiceName), '2023-05-01').key1
AZURE_COMPUTER_VISION_KEY: (useKeyVault || computerVisionName == '') ? computerVisionKeyName : listKeys(resourceId(subscription().subscriptionId, resourceGroup().name, 'Microsoft.CognitiveServices/accounts', computerVisionName), '2023-05-01').key1
})
WEBSITES_ENABLE_APP_SERVICE_STORAGE: 'false'
AZURE_AUTH_TYPE: authType
USE_KEY_VAULT: useKeyVault ? useKeyVault : ''
AZURE_OPENAI_API_KEY: useKeyVault
? openAIKeyName
: listKeys(
resourceId(
subscription().subscriptionId,
resourceGroup().name,
'Microsoft.CognitiveServices/accounts',
azureOpenAIName
),
'2023-05-01'
).key1
AZURE_SEARCH_KEY: useKeyVault
? searchKeyName
: listAdminKeys(
resourceId(
subscription().subscriptionId,
resourceGroup().name,
'Microsoft.Search/searchServices',
azureAISearchName
),
'2021-04-01-preview'
).primaryKey
AZURE_BLOB_ACCOUNT_KEY: useKeyVault
? storageAccountKeyName
: listKeys(
resourceId(
subscription().subscriptionId,
resourceGroup().name,
'Microsoft.Storage/storageAccounts',
storageAccountName
),
'2021-09-01'
).keys[0].value
AZURE_FORM_RECOGNIZER_KEY: useKeyVault
? formRecognizerKeyName
: listKeys(
resourceId(
subscription().subscriptionId,
resourceGroup().name,
'Microsoft.CognitiveServices/accounts',
formRecognizerName
),
'2023-05-01'
).key1
AZURE_CONTENT_SAFETY_KEY: useKeyVault
? contentSafetyKeyName
: listKeys(
resourceId(
subscription().subscriptionId,
resourceGroup().name,
'Microsoft.CognitiveServices/accounts',
contentSafetyName
),
'2023-05-01'
).key1
AZURE_SPEECH_SERVICE_KEY: useKeyVault
? speechKeyName
: listKeys(
resourceId(
subscription().subscriptionId,
resourceGroup().name,
'Microsoft.CognitiveServices/accounts',
speechServiceName
),
'2023-05-01'
).key1
AZURE_COMPUTER_VISION_KEY: (useKeyVault || computerVisionName == '')
? computerVisionKeyName
: listKeys(
resourceId(
subscription().subscriptionId,
resourceGroup().name,
'Microsoft.CognitiveServices/accounts',
computerVisionName
),
'2023-05-01'
).key1
})
}
}

Expand Down
37 changes: 30 additions & 7 deletions infra/app/storekeys.bicep
Original file line number Diff line number Diff line change
Expand Up @@ -19,55 +19,78 @@ resource storageAccountKeySecret 'Microsoft.KeyVault/vaults/secrets@2022-07-01'
parent: keyVault
name: storageAccountKeyName
properties: {
value: listKeys(resourceId(subscription().subscriptionId, rgName, 'Microsoft.Storage/storageAccounts', storageAccountName), '2021-09-01').keys[0].value
value: listKeys(
resourceId(subscription().subscriptionId, rgName, 'Microsoft.Storage/storageAccounts', storageAccountName),
'2021-09-01'
).keys[0].value
}
}

resource openAIKeySecret 'Microsoft.KeyVault/vaults/secrets@2022-07-01' = {
parent: keyVault
name: openAIKeyName
properties: {
value: listKeys(resourceId(subscription().subscriptionId, rgName, 'Microsoft.CognitiveServices/accounts', azureOpenAIName), '2023-05-01').key1
value: listKeys(
resourceId(subscription().subscriptionId, rgName, 'Microsoft.CognitiveServices/accounts', azureOpenAIName),
'2023-05-01'
).key1
}
}

resource searchKeySecret 'Microsoft.KeyVault/vaults/secrets@2022-07-01' = {
parent: keyVault
name: searchKeyName
properties: {
value: listAdminKeys(resourceId(subscription().subscriptionId, rgName, 'Microsoft.Search/searchServices', azureAISearchName), '2021-04-01-preview').primaryKey
value: listAdminKeys(
resourceId(subscription().subscriptionId, rgName, 'Microsoft.Search/searchServices', azureAISearchName),
'2021-04-01-preview'
).primaryKey
}
}

resource formRecognizerKeySecret 'Microsoft.KeyVault/vaults/secrets@2022-07-01' = {
parent: keyVault
name: formRecognizerKeyName
properties: {
value: listKeys(resourceId(subscription().subscriptionId, rgName, 'Microsoft.CognitiveServices/accounts', formRecognizerName), '2023-05-01').key1
value: listKeys(
resourceId(subscription().subscriptionId, rgName, 'Microsoft.CognitiveServices/accounts', formRecognizerName),
'2023-05-01'
).key1
}
}

resource contentSafetyKeySecret 'Microsoft.KeyVault/vaults/secrets@2022-07-01' = {
parent: keyVault
name: contentSafetyKeyName
properties: {
value: listKeys(resourceId(subscription().subscriptionId, rgName, 'Microsoft.CognitiveServices/accounts', contentSafetyName), '2023-05-01').key1
value: listKeys(
resourceId(subscription().subscriptionId, rgName, 'Microsoft.CognitiveServices/accounts', contentSafetyName),
'2023-05-01'
).key1
}
}

resource speechKeySecret 'Microsoft.KeyVault/vaults/secrets@2022-07-01' = {
parent: keyVault
name: speechKeyName
properties: {
value: listKeys(resourceId(subscription().subscriptionId, rgName, 'Microsoft.CognitiveServices/accounts', speechServiceName), '2023-05-01').key1
value: listKeys(
resourceId(subscription().subscriptionId, rgName, 'Microsoft.CognitiveServices/accounts', speechServiceName),
'2023-05-01'
).key1
}
}

resource computerVisionKeySecret 'Microsoft.KeyVault/vaults/secrets@2022-07-01' = if (computerVisionName != '') {
parent: keyVault
name: computerVisionKeyName
properties: {
value: computerVisionName != '' ? listKeys(resourceId(subscription().subscriptionId, rgName, 'Microsoft.CognitiveServices/accounts', computerVisionName), '2023-05-01').key1 : ''
value: computerVisionName != ''
? listKeys(
resourceId(subscription().subscriptionId, rgName, 'Microsoft.CognitiveServices/accounts', computerVisionName),
'2023-05-01'
).key1
: ''
}
}

Expand Down
78 changes: 69 additions & 9 deletions infra/app/web.bicep
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,75 @@ module web '../core/host/appservice.bicep' = {
applicationInsightsName: applicationInsightsName
appServicePlanId: appServicePlanId
appSettings: union(appSettings, {
AZURE_AUTH_TYPE: authType
USE_KEY_VAULT: useKeyVault ? useKeyVault : ''
AZURE_OPENAI_API_KEY: useKeyVault ? openAIKeyName : listKeys(resourceId(subscription().subscriptionId, resourceGroup().name, 'Microsoft.CognitiveServices/accounts', azureOpenAIName), '2023-05-01').key1
AZURE_SEARCH_KEY: useKeyVault ? searchKeyName : listAdminKeys(resourceId(subscription().subscriptionId, resourceGroup().name, 'Microsoft.Search/searchServices', azureAISearchName), '2021-04-01-preview').primaryKey
AZURE_BLOB_ACCOUNT_KEY: useKeyVault ? storageAccountKeyName : listKeys(resourceId(subscription().subscriptionId, resourceGroup().name, 'Microsoft.Storage/storageAccounts', storageAccountName), '2021-09-01').keys[0].value
AZURE_FORM_RECOGNIZER_KEY: useKeyVault ? formRecognizerKeyName : listKeys(resourceId(subscription().subscriptionId, resourceGroup().name, 'Microsoft.CognitiveServices/accounts', formRecognizerName), '2023-05-01').key1
AZURE_CONTENT_SAFETY_KEY: useKeyVault ? contentSafetyKeyName : listKeys(resourceId(subscription().subscriptionId, resourceGroup().name, 'Microsoft.CognitiveServices/accounts', contentSafetyName), '2023-05-01').key1
AZURE_SPEECH_SERVICE_KEY: useKeyVault ? speechKeyName : listKeys(resourceId(subscription().subscriptionId, resourceGroup().name, 'Microsoft.CognitiveServices/accounts', speechServiceName), '2023-05-01').key1
})
AZURE_AUTH_TYPE: authType
USE_KEY_VAULT: useKeyVault ? useKeyVault : ''
AZURE_OPENAI_API_KEY: useKeyVault
? openAIKeyName
: listKeys(
resourceId(
subscription().subscriptionId,
resourceGroup().name,
'Microsoft.CognitiveServices/accounts',
azureOpenAIName
),
'2023-05-01'
).key1
AZURE_SEARCH_KEY: useKeyVault
? searchKeyName
: listAdminKeys(
resourceId(
subscription().subscriptionId,
resourceGroup().name,
'Microsoft.Search/searchServices',
azureAISearchName
),
'2021-04-01-preview'
).primaryKey
AZURE_BLOB_ACCOUNT_KEY: useKeyVault
? storageAccountKeyName
: listKeys(
resourceId(
subscription().subscriptionId,
resourceGroup().name,
'Microsoft.Storage/storageAccounts',
storageAccountName
),
'2021-09-01'
).keys[0].value
AZURE_FORM_RECOGNIZER_KEY: useKeyVault
? formRecognizerKeyName
: listKeys(
resourceId(
subscription().subscriptionId,
resourceGroup().name,
'Microsoft.CognitiveServices/accounts',
formRecognizerName
),
'2023-05-01'
).key1
AZURE_CONTENT_SAFETY_KEY: useKeyVault
? contentSafetyKeyName
: listKeys(
resourceId(
subscription().subscriptionId,
resourceGroup().name,
'Microsoft.CognitiveServices/accounts',
contentSafetyName
),
'2023-05-01'
).key1
AZURE_SPEECH_SERVICE_KEY: useKeyVault
? speechKeyName
: listKeys(
resourceId(
subscription().subscriptionId,
resourceGroup().name,
'Microsoft.CognitiveServices/accounts',
speechServiceName
),
'2023-05-01'
).key1
})
keyVaultName: keyVaultName
runtimeName: runtimeName
runtimeVersion: runtimeVersion
Expand Down
Loading

0 comments on commit 8c46627

Please sign in to comment.