diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index bc2f44220..24a6a6cae 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -4,9 +4,22 @@ repos: hooks: - id: black language_version: python3 - + - repo: https://github.com/pycqa/flake8 rev: 7.0.0 hooks: - - id: flake8 - args: [--extend-ignore=E501] \ No newline at end of file + - id: flake8 + args: [--extend-ignore=E501] + + - repo: local + hooks: + - id: bicep + name: bicep + description: Lint and build Bicep files + entry: ./scripts/generate_arm_templates.sh + language: script + files: \.bicep$ + require_serial: true + args: # Bicep files that we want to generate ARM templates from + - -f=./infra/deployment.bicep + - -f=./extensions/infrastructure/main.bicep diff --git a/code/dev-requirements.txt b/code/dev-requirements.txt index 4f41e9faf..39cf2c15b 100644 --- a/code/dev-requirements.txt +++ b/code/dev-requirements.txt @@ -1,5 +1,5 @@ pytest==8.0.0 pytest-cov==4.1.0 flake8==7.0.0 -pre-commit==3.5.0 +pre-commit==3.6.0 black==23.12.1 diff --git a/extensions/infrastructure/main.bicep b/extensions/infrastructure/main.bicep index 22d52530f..0e8080717 100644 --- a/extensions/infrastructure/main.bicep +++ b/extensions/infrastructure/main.bicep @@ -119,7 +119,7 @@ param AzureFormRecognizerEndpoint string @secure() param AzureFormRecognizerKey string -@description('Storage Account Name - Created during the "Chat with your data" Solution Accelerator') +@description('Storage Account Name - Created during the "Chat with your data" Solution Accelerator') param AzureBlobAccountName string @description('Storage Account Key - Created during the "Chat with your data" Solution Accelerator') @@ -151,39 +151,39 @@ resource Function 'Microsoft.Web/sites@2018-11-01' = { properties: { siteConfig: { appSettings: [ - { name: 'FUNCTIONS_EXTENSION_VERSION', value: '~4'} - { name: 'WEBSITES_ENABLE_APP_SERVICE_STORAGE', value: 'false'} - { name: 'APPINSIGHTS_CONNECTION_STRING', value: AppInsightsConnectionString} - { name: 'AZURE_SEARCH_SERVICE', value: 'https://${AzureSearchName}.search.windows.net'} - { name: 'AZURE_SEARCH_INDEX', value: AzureSearchIndex} - { name: 'AZURE_SEARCH_CONVERSATIONS_LOG_INDEX', value: AzureSearchConversationLogIndex} - { name: 'AZURE_SEARCH_KEY', value: AzureSearchKey} - { name: 'AZURE_SEARCH_SEMANTIC_SEARCH_CONFIG', value: AzureSearchSemanticSearchConfig} - { name: 'AZURE_SEARCH_INDEX_IS_PRECHUNKED', value: AzureSearchIndexIsPrechunked} - { name: 'AZURE_SEARCH_TOP_K', value: AzureSearchTopK} - { name: 'AZURE_SEARCH_ENABLE_IN_DOMAIN', value: AzureSearchEnableInDomain} - { name: 'AZURE_SEARCH_CONTENT_COLUMNS', value: AzureSearchContentColumns} - { name: 'AZURE_SEARCH_FILENAME_COLUMN', value: AzureSearchFilenameColumn} - { name: 'AZURE_SEARCH_TITLE_COLUMN', value: AzureSearchTitleColumn} - { name: 'AZURE_SEARCH_URL_COLUMN', value: AzureSearchUrlColumn} - { name: 'AZURE_OPENAI_RESOURCE', value: AzureOpenAIResource} - { name: 'AZURE_OPENAI_KEY', value: AzureOpenAIKey} - { name: 'AZURE_OPENAI_MODEL', value: AzureOpenAIModel} - { name: 'AZURE_OPENAI_MODEL_NAME', value: AzureOpenAIModelName} - { name: 'AZURE_OPENAI_TEMPERATURE', value: AzureOpenAITemperature} - { name: 'AZURE_OPENAI_TOP_P', value: AzureOpenAITopP} - { name: 'AZURE_OPENAI_MAX_TOKENS', value: AzureOpenAIMaxTokens} - { name: 'AZURE_OPENAI_STOP_SEQUENCE', value: AzureOpenAIStopSequence} - { name: 'AZURE_OPENAI_SYSTEM_MESSAGE', value: AzureOpenAISystemMessage} - { name: 'AZURE_OPENAI_API_VERSION', value: AzureOpenAIApiVersion} - { name: 'AZURE_OPENAI_STREAM', value: AzureOpenAIStream} - { name: 'AZURE_OPENAI_EMBEDDING_MODEL', value: AzureOpenAIEmbeddingModel} - { name: 'AZURE_FORM_RECOGNIZER_ENDPOINT', value: AzureFormRecognizerEndpoint} - { name: 'AZURE_FORM_RECOGNIZER_KEY', value: AzureFormRecognizerKey} - { name: 'AZURE_BLOB_ACCOUNT_NAME', value: AzureBlobAccountName} - { name: 'AZURE_BLOB_ACCOUNT_KEY', value: AzureBlobAccountKey} - { name: 'AZURE_BLOB_CONTAINER_NAME', value: AzureBlobContainerName} - { name: 'ORCHESTRATION_STRATEGY', value: OrchestrationStrategy} + { name: 'FUNCTIONS_EXTENSION_VERSION', value: '~4' } + { name: 'WEBSITES_ENABLE_APP_SERVICE_STORAGE', value: 'false' } + { name: 'APPINSIGHTS_CONNECTION_STRING', value: AppInsightsConnectionString } + { name: 'AZURE_SEARCH_SERVICE', value: 'https://${AzureSearchName}.search.windows.net' } + { name: 'AZURE_SEARCH_INDEX', value: AzureSearchIndex } + { name: 'AZURE_SEARCH_CONVERSATIONS_LOG_INDEX', value: AzureSearchConversationLogIndex } + { name: 'AZURE_SEARCH_KEY', value: AzureSearchKey } + { name: 'AZURE_SEARCH_SEMANTIC_SEARCH_CONFIG', value: AzureSearchSemanticSearchConfig } + { name: 'AZURE_SEARCH_INDEX_IS_PRECHUNKED', value: AzureSearchIndexIsPrechunked } + { name: 'AZURE_SEARCH_TOP_K', value: AzureSearchTopK } + { name: 'AZURE_SEARCH_ENABLE_IN_DOMAIN', value: AzureSearchEnableInDomain } + { name: 'AZURE_SEARCH_CONTENT_COLUMNS', value: AzureSearchContentColumns } + { name: 'AZURE_SEARCH_FILENAME_COLUMN', value: AzureSearchFilenameColumn } + { name: 'AZURE_SEARCH_TITLE_COLUMN', value: AzureSearchTitleColumn } + { name: 'AZURE_SEARCH_URL_COLUMN', value: AzureSearchUrlColumn } + { name: 'AZURE_OPENAI_RESOURCE', value: AzureOpenAIResource } + { name: 'AZURE_OPENAI_KEY', value: AzureOpenAIKey } + { name: 'AZURE_OPENAI_MODEL', value: AzureOpenAIModel } + { name: 'AZURE_OPENAI_MODEL_NAME', value: AzureOpenAIModelName } + { name: 'AZURE_OPENAI_TEMPERATURE', value: AzureOpenAITemperature } + { name: 'AZURE_OPENAI_TOP_P', value: AzureOpenAITopP } + { name: 'AZURE_OPENAI_MAX_TOKENS', value: AzureOpenAIMaxTokens } + { name: 'AZURE_OPENAI_STOP_SEQUENCE', value: AzureOpenAIStopSequence } + { name: 'AZURE_OPENAI_SYSTEM_MESSAGE', value: AzureOpenAISystemMessage } + { name: 'AZURE_OPENAI_API_VERSION', value: AzureOpenAIApiVersion } + { name: 'AZURE_OPENAI_STREAM', value: AzureOpenAIStream } + { name: 'AZURE_OPENAI_EMBEDDING_MODEL', value: AzureOpenAIEmbeddingModel } + { name: 'AZURE_FORM_RECOGNIZER_ENDPOINT', value: AzureFormRecognizerEndpoint } + { name: 'AZURE_FORM_RECOGNIZER_KEY', value: AzureFormRecognizerKey } + { name: 'AZURE_BLOB_ACCOUNT_NAME', value: AzureBlobAccountName } + { name: 'AZURE_BLOB_ACCOUNT_KEY', value: AzureBlobAccountKey } + { name: 'AZURE_BLOB_CONTAINER_NAME', value: AzureBlobContainerName } + { name: 'ORCHESTRATION_STRATEGY', value: OrchestrationStrategy } ] cors: { allowedOrigins: [ @@ -214,4 +214,4 @@ resource WaitFunctionDeploymentSection 'Microsoft.Resources/deploymentScripts@20 dependsOn: [ Function ] -} +} \ No newline at end of file diff --git a/extensions/teams/infra/azure.bicep b/extensions/teams/infra/azure.bicep index 67dcc366d..7ef6223c2 100644 --- a/extensions/teams/infra/azure.bicep +++ b/extensions/teams/infra/azure.bicep @@ -79,4 +79,4 @@ module azureBotRegistration './botRegistration/azurebot.bicep' = { // The output will be persisted in .env.{envName}. Visit https://aka.ms/teamsfx-actions/arm-deploy for more details. output BOT_AZURE_APP_SERVICE_RESOURCE_ID string = webApp.id -output BOT_DOMAIN string = webApp.properties.defaultHostName +output BOT_DOMAIN string = webApp.properties.defaultHostName \ No newline at end of file diff --git a/extensions/teams/infra/botRegistration/azurebot.bicep b/extensions/teams/infra/botRegistration/azurebot.bicep index ab67c7a56..fbf492bf8 100644 --- a/extensions/teams/infra/botRegistration/azurebot.bicep +++ b/extensions/teams/infra/botRegistration/azurebot.bicep @@ -34,4 +34,4 @@ resource botServiceMsTeamsChannel 'Microsoft.BotService/botServices/channels@202 properties: { channelName: 'MsTeamsChannel' } -} +} \ No newline at end of file diff --git a/infra/deployment.bicep b/infra/deployment.bicep index 396e0aad4..8f6da40ad 100644 --- a/infra/deployment.bicep +++ b/infra/deployment.bicep @@ -217,7 +217,7 @@ resource AzureCognitiveSearch_resource 'Microsoft.Search/searchServices@2022-09- name: AzureCognitiveSearch location: Location tags: { - deployment : 'chatwithyourdata-sa' + deployment: 'chatwithyourdata-sa' } sku: { name: AzureCognitiveSearchSku @@ -315,44 +315,44 @@ resource Website 'Microsoft.Web/sites@2020-06-01' = { serverFarmId: HostingPlanName siteConfig: { appSettings: [ - { name: 'APPINSIGHTS_CONNECTION_STRING', value: reference(ApplicationInsights.id, '2015-05-01').ConnectionString} - { name: 'AZURE_SEARCH_SERVICE', value: 'https://${AzureCognitiveSearch}.search.windows.net'} - { name: 'AZURE_SEARCH_INDEX', value: AzureSearchIndex} + { name: 'APPINSIGHTS_CONNECTION_STRING', value: reference(ApplicationInsights.id, '2015-05-01').ConnectionString } + { name: 'AZURE_SEARCH_SERVICE', value: 'https://${AzureCognitiveSearch}.search.windows.net' } + { name: 'AZURE_SEARCH_INDEX', value: AzureSearchIndex } { name: 'AZURE_SEARCH_USE_SEMANTIC_SEARCH', value: AzureSearchUseSemanticSearch } - { name: 'AZURE_SEARCH_CONVERSATIONS_LOG_INDEX', value: AzureSearchConversationLogIndex} + { name: 'AZURE_SEARCH_CONVERSATIONS_LOG_INDEX', value: AzureSearchConversationLogIndex } { name: 'AZURE_AUTH_TYPE', value: authType } - { name: 'AZURE_SEARCH_KEY', value: authType == 'keys' ? listAdminKeys('Microsoft.Search/searchServices/${AzureCognitiveSearch}', '2021-04-01-preview').primaryKey : null} - { name: 'AZURE_SEARCH_SEMANTIC_SEARCH_CONFIG', value: AzureSearchSemanticSearchConfig} - { name: 'AZURE_SEARCH_INDEX_IS_PRECHUNKED', value: AzureSearchIndexIsPrechunked} - { name: 'AZURE_SEARCH_TOP_K', value: AzureSearchTopK} - { name: 'AZURE_SEARCH_ENABLE_IN_DOMAIN', value: AzureSearchEnableInDomain} - { name: 'AZURE_SEARCH_CONTENT_COLUMNS', value: AzureSearchContentColumns} - { name: 'AZURE_SEARCH_FILENAME_COLUMN', value: AzureSearchFilenameColumn} - { name: 'AZURE_SEARCH_TITLE_COLUMN', value: AzureSearchTitleColumn} - { name: 'AZURE_SEARCH_URL_COLUMN', value: AzureSearchUrlColumn} - { name: 'AZURE_OPENAI_RESOURCE', value: AzureOpenAIResource} - { name: 'AZURE_OPENAI_KEY', value: authType == 'keys' ? OpenAI.listKeys('2023-05-01').key1 : null} - { name: 'AZURE_OPENAI_MODEL', value: AzureOpenAIGPTModel} - { name: 'AZURE_OPENAI_MODEL_NAME', value: AzureOpenAIGPTModelName} - { name: 'AZURE_OPENAI_TEMPERATURE', value: AzureOpenAITemperature} - { name: 'AZURE_OPENAI_TOP_P', value: AzureOpenAITopP} - { name: 'AZURE_OPENAI_MAX_TOKENS', value: AzureOpenAIMaxTokens} - { name: 'AZURE_OPENAI_STOP_SEQUENCE', value: AzureOpenAIStopSequence} - { name: 'AZURE_OPENAI_SYSTEM_MESSAGE', value: AzureOpenAISystemMessage} - { name: 'AZURE_OPENAI_API_VERSION', value: AzureOpenAIApiVersion} - { name: 'AZURE_OPENAI_STREAM', value: AzureOpenAIStream} - { name: 'AZURE_OPENAI_EMBEDDING_MODEL', value: AzureOpenAIEmbeddingModel} - { name: 'AZURE_FORM_RECOGNIZER_ENDPOINT', value: 'https://${Location}.api.cognitive.microsoft.com/'} - { name: 'AZURE_FORM_RECOGNIZER_KEY', value: listKeys('Microsoft.CognitiveServices/accounts/${FormRecognizerName}', '2023-05-01').key1} - { name: 'AZURE_BLOB_ACCOUNT_NAME', value: StorageAccountName} - { name: 'AZURE_BLOB_ACCOUNT_KEY', value: listKeys(StorageAccount.id, '2019-06-01').keys[0].value} - { name: 'AZURE_BLOB_CONTAINER_NAME', value: BlobContainerName} - { name: 'ORCHESTRATION_STRATEGY', value: OrchestrationStrategy} - { name: 'AZURE_CONTENT_SAFETY_ENDPOINT', value: 'https://${Location}.api.cognitive.microsoft.com/'} - { name: 'AZURE_CONTENT_SAFETY_KEY', value: listKeys('Microsoft.CognitiveServices/accounts/${ContentSafetyName}', '2023-05-01').key1} - { name: 'AZURE_SPEECH_SERVICE_NAME', value: SpeechServiceName} - { name: 'AZURE_SPEECH_SERVICE_KEY', value: listKeys('Microsoft.CognitiveServices/accounts/${SpeechServiceName}', '2023-05-01').key1} - { name: 'AZURE_SPEECH_SERVICE_REGION', value: Location} + { name: 'AZURE_SEARCH_KEY', value: authType == 'keys' ? listAdminKeys('Microsoft.Search/searchServices/${AzureCognitiveSearch}', '2021-04-01-preview').primaryKey : null } + { name: 'AZURE_SEARCH_SEMANTIC_SEARCH_CONFIG', value: AzureSearchSemanticSearchConfig } + { name: 'AZURE_SEARCH_INDEX_IS_PRECHUNKED', value: AzureSearchIndexIsPrechunked } + { name: 'AZURE_SEARCH_TOP_K', value: AzureSearchTopK } + { name: 'AZURE_SEARCH_ENABLE_IN_DOMAIN', value: AzureSearchEnableInDomain } + { name: 'AZURE_SEARCH_CONTENT_COLUMNS', value: AzureSearchContentColumns } + { name: 'AZURE_SEARCH_FILENAME_COLUMN', value: AzureSearchFilenameColumn } + { name: 'AZURE_SEARCH_TITLE_COLUMN', value: AzureSearchTitleColumn } + { name: 'AZURE_SEARCH_URL_COLUMN', value: AzureSearchUrlColumn } + { name: 'AZURE_OPENAI_RESOURCE', value: AzureOpenAIResource } + { name: 'AZURE_OPENAI_KEY', value: authType == 'keys' ? OpenAI.listKeys('2023-05-01').key1 : null } + { name: 'AZURE_OPENAI_MODEL', value: AzureOpenAIGPTModel } + { name: 'AZURE_OPENAI_MODEL_NAME', value: AzureOpenAIGPTModelName } + { name: 'AZURE_OPENAI_TEMPERATURE', value: AzureOpenAITemperature } + { name: 'AZURE_OPENAI_TOP_P', value: AzureOpenAITopP } + { name: 'AZURE_OPENAI_MAX_TOKENS', value: AzureOpenAIMaxTokens } + { name: 'AZURE_OPENAI_STOP_SEQUENCE', value: AzureOpenAIStopSequence } + { name: 'AZURE_OPENAI_SYSTEM_MESSAGE', value: AzureOpenAISystemMessage } + { name: 'AZURE_OPENAI_API_VERSION', value: AzureOpenAIApiVersion } + { name: 'AZURE_OPENAI_STREAM', value: AzureOpenAIStream } + { name: 'AZURE_OPENAI_EMBEDDING_MODEL', value: AzureOpenAIEmbeddingModel } + { name: 'AZURE_FORM_RECOGNIZER_ENDPOINT', value: 'https://${Location}.api.cognitive.microsoft.com/' } + { name: 'AZURE_FORM_RECOGNIZER_KEY', value: listKeys('Microsoft.CognitiveServices/accounts/${FormRecognizerName}', '2023-05-01').key1 } + { name: 'AZURE_BLOB_ACCOUNT_NAME', value: StorageAccountName } + { name: 'AZURE_BLOB_ACCOUNT_KEY', value: listKeys(StorageAccount.id, '2019-06-01').keys[0].value } + { name: 'AZURE_BLOB_CONTAINER_NAME', value: BlobContainerName } + { name: 'ORCHESTRATION_STRATEGY', value: OrchestrationStrategy } + { name: 'AZURE_CONTENT_SAFETY_ENDPOINT', value: 'https://${Location}.api.cognitive.microsoft.com/' } + { name: 'AZURE_CONTENT_SAFETY_KEY', value: listKeys('Microsoft.CognitiveServices/accounts/${ContentSafetyName}', '2023-05-01').key1 } + { name: 'AZURE_SPEECH_SERVICE_NAME', value: SpeechServiceName } + { name: 'AZURE_SPEECH_SERVICE_KEY', value: listKeys('Microsoft.CognitiveServices/accounts/${SpeechServiceName}', '2023-05-01').key1 } + { name: 'AZURE_SPEECH_SERVICE_REGION', value: Location } ] linuxFxVersion: WebAppImageName minTlsVersion: '1.2' @@ -374,19 +374,19 @@ resource WebsiteName_admin 'Microsoft.Web/sites@2020-06-01' = { { name: 'APPINSIGHTS_INSTRUMENTATIONKEY', value: reference(ApplicationInsights.id, '2015-05-01').InstrumentationKey } { name: 'AZURE_SEARCH_SERVICE', value: 'https://${AzureCognitiveSearch}.search.windows.net' } { name: 'AZURE_AUTH_TYPE', value: authType } - { name: 'AZURE_SEARCH_KEY', value: authType == 'keys' ? listAdminKeys('Microsoft.Search/searchServices/${AzureCognitiveSearch}', '2021-04-01-preview').primaryKey : null} + { name: 'AZURE_SEARCH_KEY', value: authType == 'keys' ? listAdminKeys('Microsoft.Search/searchServices/${AzureCognitiveSearch}', '2021-04-01-preview').primaryKey : null } { name: 'AZURE_SEARCH_INDEX', value: AzureSearchIndex } { name: 'AZURE_SEARCH_USE_SEMANTIC_SEARCH', value: AzureSearchUseSemanticSearch } { name: 'AZURE_SEARCH_SEMANTIC_SEARCH_CONFIG', value: AzureSearchSemanticSearchConfig } { name: 'AZURE_SEARCH_INDEX_IS_PRECHUNKED', value: AzureSearchIndexIsPrechunked } { name: 'AZURE_SEARCH_TOP_K', value: AzureSearchTopK } { name: 'AZURE_SEARCH_ENABLE_IN_DOMAIN', value: AzureSearchEnableInDomain } - { name: 'AZURE_SEARCH_CONTENT_COLUMNS', value: AzureSearchContentColumns} + { name: 'AZURE_SEARCH_CONTENT_COLUMNS', value: AzureSearchContentColumns } { name: 'AZURE_SEARCH_FILENAME_COLUMN', value: AzureSearchFilenameColumn } - { name: 'AZURE_SEARCH_TITLE_COLUMN', value: AzureSearchTitleColumn} + { name: 'AZURE_SEARCH_TITLE_COLUMN', value: AzureSearchTitleColumn } { name: 'AZURE_SEARCH_URL_COLUMN', value: AzureSearchUrlColumn } - { name: 'AZURE_OPENAI_RESOURCE', value: AzureOpenAIResource} - { name: 'AZURE_OPENAI_KEY', value: authType == 'keys' ? OpenAI.listKeys('2023-05-01').key1 : null} + { name: 'AZURE_OPENAI_RESOURCE', value: AzureOpenAIResource } + { name: 'AZURE_OPENAI_KEY', value: authType == 'keys' ? OpenAI.listKeys('2023-05-01').key1 : null } { name: 'AZURE_OPENAI_MODEL', value: AzureOpenAIGPTModel } { name: 'AZURE_OPENAI_MODEL_NAME', value: AzureOpenAIGPTModelName } { name: 'AZURE_OPENAI_TEMPERATURE', value: AzureOpenAITemperature } @@ -402,12 +402,12 @@ resource WebsiteName_admin 'Microsoft.Web/sites@2020-06-01' = { { name: 'AZURE_BLOB_ACCOUNT_NAME', value: StorageAccountName } { name: 'AZURE_BLOB_ACCOUNT_KEY', value: listKeys(StorageAccount.id, '2019-06-01').keys[0].value } { name: 'AZURE_BLOB_CONTAINER_NAME', value: BlobContainerName } - { name: 'DOCUMENT_PROCESSING_QUEUE_NAME', value: QueueName} - { name: 'BACKEND_URL', value: 'https://${FunctionName}.azurewebsites.net'} - { name: 'FUNCTION_KEY', value: ClientKey} - { name: 'ORCHESTRATION_STRATEGY', value: OrchestrationStrategy} - { name: 'AZURE_CONTENT_SAFETY_ENDPOINT', value: 'https://${Location}.api.cognitive.microsoft.com/'} - { name: 'AZURE_CONTENT_SAFETY_KEY', value: listKeys('Microsoft.CognitiveServices/accounts/${ContentSafetyName}', '2023-05-01').key1} + { name: 'DOCUMENT_PROCESSING_QUEUE_NAME', value: QueueName } + { name: 'BACKEND_URL', value: 'https://${FunctionName}.azurewebsites.net' } + { name: 'FUNCTION_KEY', value: ClientKey } + { name: 'ORCHESTRATION_STRATEGY', value: OrchestrationStrategy } + { name: 'AZURE_CONTENT_SAFETY_ENDPOINT', value: 'https://${Location}.api.cognitive.microsoft.com/' } + { name: 'AZURE_CONTENT_SAFETY_KEY', value: listKeys('Microsoft.CognitiveServices/accounts/${ContentSafetyName}', '2023-05-01').key1 } ] linuxFxVersion: AdminWebAppImageName minTlsVersion: '1.2' @@ -479,7 +479,6 @@ resource StorageAccountName_default_doc_processing_poison 'Microsoft.Storage/sto dependsOn: [] } - resource logAnalyticsWorkspace 'Microsoft.OperationalInsights/workspaces@2021-06-01' = { name: logAnalyticsWorkspaceName location: Location @@ -511,28 +510,28 @@ resource Function 'Microsoft.Web/sites@2018-11-01' = { properties: { siteConfig: { appSettings: [ - { name: 'FUNCTIONS_EXTENSION_VERSION', value: '~4'} - { name: 'WEBSITES_ENABLE_APP_SERVICE_STORAGE', value: 'false'} - { name: 'APPINSIGHTS_INSTRUMENTATIONKEY', value: reference(ApplicationInsights.id, '2015-05-01').InstrumentationKey} - { name: 'AzureWebJobsStorage', value: 'DefaultEndpointsProtocol=https;AccountName=${StorageAccountName};AccountKey=${listKeys(StorageAccount.id, '2019-06-01').keys[0].value};EndpointSuffix=core.windows.net'} + { name: 'FUNCTIONS_EXTENSION_VERSION', value: '~4' } + { name: 'WEBSITES_ENABLE_APP_SERVICE_STORAGE', value: 'false' } + { name: 'APPINSIGHTS_INSTRUMENTATIONKEY', value: reference(ApplicationInsights.id, '2015-05-01').InstrumentationKey } + { name: 'AzureWebJobsStorage', value: 'DefaultEndpointsProtocol=https;AccountName=${StorageAccountName};AccountKey=${listKeys(StorageAccount.id, '2019-06-01').keys[0].value};EndpointSuffix=core.windows.net' } { name: 'AZURE_AUTH_TYPE', value: authType } - { name: 'AZURE_OPENAI_MODEL', value: AzureOpenAIGPTModel} - { name: 'AZURE_OPENAI_EMBEDDING_MODEL', value: AzureOpenAIEmbeddingModel} - { name: 'AZURE_OPENAI_RESOURCE', value: AzureOpenAIResource} - { name: 'AZURE_OPENAI_KEY', value: authType == 'keys' ? OpenAI.listKeys('2023-05-01').key1 : null} - { name: 'AZURE_BLOB_ACCOUNT_NAME', value: StorageAccountName} - { name: 'AZURE_BLOB_ACCOUNT_KEY', value: listKeys(StorageAccount.id, '2019-06-01').keys[0].value} - { name: 'AZURE_BLOB_CONTAINER_NAME', value: BlobContainerName} - { name: 'AZURE_FORM_RECOGNIZER_ENDPOINT', value: 'https://${Location}.api.cognitive.microsoft.com/'} - { name: 'AZURE_FORM_RECOGNIZER_KEY', value: listKeys('Microsoft.CognitiveServices/accounts/${FormRecognizerName}', '2023-05-01').key1} - { name: 'AZURE_SEARCH_SERVICE', value: 'https://${AzureCognitiveSearch}.search.windows.net'} - { name: 'AZURE_SEARCH_KEY', value: authType == 'keys' ? listAdminKeys('Microsoft.Search/searchServices/${AzureCognitiveSearch}', '2021-04-01-preview').primaryKey : null} - { name: 'DOCUMENT_PROCESSING_QUEUE_NAME', value: QueueName} - { name: 'AZURE_OPENAI_API_VERSION', value: AzureOpenAIApiVersion} - { name: 'AZURE_SEARCH_INDEX', value: AzureSearchIndex} - { name: 'ORCHESTRATION_STRATEGY', value: OrchestrationStrategy} - { name: 'AZURE_CONTENT_SAFETY_ENDPOINT', value: 'https://${Location}.api.cognitive.microsoft.com/'} - { name: 'AZURE_CONTENT_SAFETY_KEY', value: listKeys('Microsoft.CognitiveServices/accounts/${ContentSafetyName}', '2023-05-01').key1} + { name: 'AZURE_OPENAI_MODEL', value: AzureOpenAIGPTModel } + { name: 'AZURE_OPENAI_EMBEDDING_MODEL', value: AzureOpenAIEmbeddingModel } + { name: 'AZURE_OPENAI_RESOURCE', value: AzureOpenAIResource } + { name: 'AZURE_OPENAI_KEY', value: authType == 'keys' ? OpenAI.listKeys('2023-05-01').key1 : null } + { name: 'AZURE_BLOB_ACCOUNT_NAME', value: StorageAccountName } + { name: 'AZURE_BLOB_ACCOUNT_KEY', value: listKeys(StorageAccount.id, '2019-06-01').keys[0].value } + { name: 'AZURE_BLOB_CONTAINER_NAME', value: BlobContainerName } + { name: 'AZURE_FORM_RECOGNIZER_ENDPOINT', value: 'https://${Location}.api.cognitive.microsoft.com/' } + { name: 'AZURE_FORM_RECOGNIZER_KEY', value: listKeys('Microsoft.CognitiveServices/accounts/${FormRecognizerName}', '2023-05-01').key1 } + { name: 'AZURE_SEARCH_SERVICE', value: 'https://${AzureCognitiveSearch}.search.windows.net' } + { name: 'AZURE_SEARCH_KEY', value: authType == 'keys' ? listAdminKeys('Microsoft.Search/searchServices/${AzureCognitiveSearch}', '2021-04-01-preview').primaryKey : null } + { name: 'DOCUMENT_PROCESSING_QUEUE_NAME', value: QueueName } + { name: 'AZURE_OPENAI_API_VERSION', value: AzureOpenAIApiVersion } + { name: 'AZURE_SEARCH_INDEX', value: AzureSearchIndex } + { name: 'ORCHESTRATION_STRATEGY', value: OrchestrationStrategy } + { name: 'AZURE_CONTENT_SAFETY_ENDPOINT', value: 'https://${Location}.api.cognitive.microsoft.com/' } + { name: 'AZURE_CONTENT_SAFETY_KEY', value: listKeys('Microsoft.CognitiveServices/accounts/${ContentSafetyName}', '2023-05-01').key1 } ] cors: { allowedOrigins: [ @@ -688,7 +687,7 @@ module openAiRoleBackend 'security/role.bicep' = if (authType == 'rbac') { scope: resourceGroup() name: 'openai-role-backend' params: { - principalId: Website.identity.principalId + principalId: Website.identity.principalId roleDefinitionId: '5e0bd9bd-7b93-4f28-af87-19fc36ad61bd' principalType: 'ServicePrincipal' } @@ -828,7 +827,7 @@ module searchReaderRoleBackend 'security/role.bicep' = if (authType == 'rbac') { } // Reader role for Function resource - // Used to read index definitions +// Used to read index definitions module searchReaderRoleFunction 'security/role.bicep' = if (authType == 'rbac') { scope: resourceGroup() name: 'search-reader-role-function' @@ -840,7 +839,7 @@ module searchReaderRoleFunction 'security/role.bicep' = if (authType == 'rbac') } // Reader role for Admin Website resource - // Used to read index definitions +// Used to read index definitions module searchReaderRoleAdmin 'security/role.bicep' = if (authType == 'rbac') { scope: resourceGroup() name: 'search-reader-role-admin' @@ -852,8 +851,8 @@ module searchReaderRoleAdmin 'security/role.bicep' = if (authType == 'rbac') { } // Reader role for Admin Website resource - // Used to read index definitions - module searchReaderRoleUser 'security/role.bicep' = if (authType == 'rbac' && principalId != '') { +// Used to read index definitions +module searchReaderRoleUser 'security/role.bicep' = if (authType == 'rbac' && principalId != '') { scope: resourceGroup() name: 'search-reader-role-user' params: { @@ -905,4 +904,4 @@ module searchIndexDataContUser 'security/role.bicep' = if (authType == 'rbac' && roleDefinitionId: '8ebe5a00-799e-43f5-93ac-243d3dce84a7' principalType: 'User' } -} +} \ No newline at end of file diff --git a/infra/security/role.bicep b/infra/security/role.bicep index 0b30cfd34..255ad51b4 100644 --- a/infra/security/role.bicep +++ b/infra/security/role.bicep @@ -18,4 +18,4 @@ resource role 'Microsoft.Authorization/roleAssignments@2022-04-01' = { principalType: principalType roleDefinitionId: resourceId('Microsoft.Authorization/roleDefinitions', roleDefinitionId) } -} +} \ No newline at end of file diff --git a/scripts/generate_arm_templates.sh b/scripts/generate_arm_templates.sh new file mode 100755 index 000000000..a9208105f --- /dev/null +++ b/scripts/generate_arm_templates.sh @@ -0,0 +1,24 @@ +#!/usr/bin/env bash + +set -e + +az bicep version 2>/dev/null || az bicep install + +TEMPLATES=() + +for ARG in $@; do + # If the argument is supplied with "-f", then it is a template file that needs to be built + if [[ $ARG == -f=* ]]; then + TEMPLATES+=(${ARG#-f=}) + else + # Otherwise, it is a file that has been edited + az bicep format -f $ARG + git add $ARG + fi +done + +# Build the templates +for TEMPLATE in ${TEMPLATES[@]}; do + az bicep build -f $TEMPLATE + git add "${TEMPLATE%.bicep}.json" # Change the extension from .bicep to .json +done