Skip to content

Commit

Permalink
modify models.py
Browse files Browse the repository at this point in the history
modify models.py

modify parameter name

modify parameter name
  • Loading branch information
Menghua1 committed Jun 19, 2024
1 parent 3163c23 commit b3a89a8
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 6 deletions.
18 changes: 12 additions & 6 deletions templates/todo/api/python/todo/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -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
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -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
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -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
}
}
}
Expand Down

0 comments on commit b3a89a8

Please sign in to comment.