From b3a89a8b9ad37a5f1c303f46d0e84f78b552c43d Mon Sep 17 00:00:00 2001 From: "Menghua Chen (WICRESOFT NORTH AMERICA LTD)" Date: Wed, 19 Jun 2024 15:36:13 +0800 Subject: [PATCH] modify models.py modify models.py modify parameter name modify parameter name --- templates/todo/api/python/todo/models.py | 18 ++++++++++++------ .../.repo/bicep/infra/main.bicep | 6 ++++++ .../.repo/bicep/infra/main.bicep | 6 ++++++ .../python-mongo/.repo/bicep/infra/main.bicep | 6 ++++++ 4 files changed, 30 insertions(+), 6 deletions(-) diff --git a/templates/todo/api/python/todo/models.py b/templates/todo/api/python/todo/models.py index e6933bafb15..4b76159de06 100644 --- a/templates/todo/api/python/todo/models.py +++ b/templates/todo/api/python/todo/models.py @@ -20,18 +20,24 @@ def __init__(self, *args, **kwargs): credential = DefaultAzureCredential() keyvault_client = SecretClient(self.AZURE_KEY_VAULT_ENDPOINT, credential) for secret in keyvault_client.list_properties_of_secrets(): - if secret.name == "AZURE-COSMOS-CONNECTION-STRING": - setattr( - self, - keyvault_name_as_attr(secret.name), - keyvault_client.get_secret(secret.name).value, - ) + setattr( + self, + keyvault_name_as_attr(secret.name), + keyvault_client.get_secret(secret.name).value, + ) AZURE_COSMOS_CONNECTION_STRING: str = "" AZURE_COSMOS_DATABASE_NAME: str = "Todo" AZURE_KEY_VAULT_ENDPOINT: Optional[str] = None APPLICATIONINSIGHTS_CONNECTION_STRING: Optional[str] = None APPLICATIONINSIGHTS_ROLENAME: Optional[str] = "API" + PRIMARY_WRITE_KEY: str = "" + PRIMARY_READONLY_KEY: str = "" + SECONDARY_WRITE_CONNECTION_STRING: str = "" + PRIMARY_READONLY_CONNECTION_STRING: str = "" + SECONDARY_WRITE_KEY: str = "" + SECONDARY_READONLY_KEY: str = "" + SECONDARY_READONLY_CONNECTION_STRING: str = "" class Config: env_file = ".env" diff --git a/templates/todo/projects/python-mongo-aca/.repo/bicep/infra/main.bicep b/templates/todo/projects/python-mongo-aca/.repo/bicep/infra/main.bicep index 6a553a2c274..d20762f6568 100644 --- a/templates/todo/projects/python-mongo-aca/.repo/bicep/infra/main.bicep +++ b/templates/todo/projects/python-mongo-aca/.repo/bicep/infra/main.bicep @@ -26,6 +26,9 @@ param resourceGroupName string = '' param webContainerAppName string = '' param apimServiceName string = '' param connectionStringKey string = 'AZURE-COSMOS-CONNECTION-STRING' +param primaryReadonlyConnectionStringSecretName string= 'PRIMARY-READONLY-CONNECTION-STRING' +param secondaryWriteConnectionStringSecretName string = 'SECONDARY-WRITE-CONNECTION-STRING' +param secondaryReadonlyConnectionStringSecretName string = 'SECONDARY-READONLY-CONNECTION-STRING' param collections array = [ { name: 'TodoList' @@ -263,6 +266,9 @@ module cosmos 'br/public:avm/res/document-db/database-account:0.4.0' = { secretsKeyVault: { keyVaultName: keyVault.outputs.name primaryWriteConnectionStringSecretName: connectionStringKey + primaryReadonlyConnectionStringSecretName: primaryReadonlyConnectionStringSecretName + secondaryWriteConnectionStringSecretName: secondaryWriteConnectionStringSecretName + secondaryReadonlyConnectionStringSecretName: secondaryReadonlyConnectionStringSecretName } } } diff --git a/templates/todo/projects/python-mongo-swa-func/.repo/bicep/infra/main.bicep b/templates/todo/projects/python-mongo-swa-func/.repo/bicep/infra/main.bicep index 6f0e09dac8a..c4da482361b 100644 --- a/templates/todo/projects/python-mongo-swa-func/.repo/bicep/infra/main.bicep +++ b/templates/todo/projects/python-mongo-swa-func/.repo/bicep/infra/main.bicep @@ -26,6 +26,9 @@ param storageAccountName string = '' param webServiceName string = '' param apimServiceName string = '' param connectionStringKey string = 'AZURE-COSMOS-CONNECTION-STRING' +param primaryReadonlyConnectionStringSecretName string= 'PRIMARY-READONLY-CONNECTION-STRING' +param secondaryWriteConnectionStringSecretName string = 'SECONDARY-WRITE-CONNECTION-STRING' +param secondaryReadonlyConnectionStringSecretName string = 'SECONDARY-READONLY-CONNECTION-STRING' param collections array = [ { name: 'TodoList' @@ -183,6 +186,9 @@ module cosmos 'br/public:avm/res/document-db/database-account:0.4.0' = { secretsKeyVault: { keyVaultName: keyVault.outputs.name primaryWriteConnectionStringSecretName: connectionStringKey + primaryReadonlyConnectionStringSecretName: primaryReadonlyConnectionStringSecretName + secondaryWriteConnectionStringSecretName: secondaryWriteConnectionStringSecretName + secondaryReadonlyConnectionStringSecretName: secondaryReadonlyConnectionStringSecretName } } } diff --git a/templates/todo/projects/python-mongo/.repo/bicep/infra/main.bicep b/templates/todo/projects/python-mongo/.repo/bicep/infra/main.bicep index 852e1cf3827..829659923e6 100644 --- a/templates/todo/projects/python-mongo/.repo/bicep/infra/main.bicep +++ b/templates/todo/projects/python-mongo/.repo/bicep/infra/main.bicep @@ -25,6 +25,9 @@ param resourceGroupName string = '' param webServiceName string = '' param apimServiceName string = '' param connectionStringKey string = 'AZURE-COSMOS-CONNECTION-STRING' +param primaryReadonlyConnectionStringSecretName string= 'PRIMARY-READONLY-CONNECTION-STRING' +param secondaryWriteConnectionStringSecretName string = 'SECONDARY-WRITE-CONNECTION-STRING' +param secondaryReadonlyConnectionStringSecretName string = 'SECONDARY-READONLY-CONNECTION-STRING' param collections array = [ { name: 'TodoList' @@ -186,6 +189,9 @@ module cosmos 'br/public:avm/res/document-db/database-account:0.4.0' = { secretsKeyVault: { keyVaultName: keyVault.outputs.name primaryWriteConnectionStringSecretName: connectionStringKey + primaryReadonlyConnectionStringSecretName: primaryReadonlyConnectionStringSecretName + secondaryWriteConnectionStringSecretName: secondaryWriteConnectionStringSecretName + secondaryReadonlyConnectionStringSecretName: secondaryReadonlyConnectionStringSecretName } } }