Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update the infra/core modules to AVM modules #3975

Merged
merged 3 commits into from
Jun 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions templates/todo/api/python/todo/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,12 @@ 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():
setattr(
self,
keyvault_name_as_attr(secret.name),
keyvault_client.get_secret(secret.name).value,
)
if secret.name == "AZURE-COSMOS-CONNECTION-STRING":
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"
Expand Down
99 changes: 99 additions & 0 deletions templates/todo/common/infra/bicep/app/apim-api-settings.bicep
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
@description('Resource name for the existing apim service')
param name string

@description('Resource name to uniquely identify this API within the API Management service instance')
@minLength(1)
param apiName string

@description('Relative URL uniquely identifying this API and all of its resource paths within the API Management service instance. It is appended to the API endpoint base URL specified during the service instance creation to form a public URL for this API.')
@minLength(1)
param apiPath string

@description('Resource name for the existing applicationInsights service')
param applicationInsightsName string
Menghua1 marked this conversation as resolved.
Show resolved Hide resolved

@description('Resource name for backend Web App or Function App')
param apiAppName string = ''

// Necessary due to https://github.com/Azure/bicep/issues/9594
// placeholderName is never deployed, it is merely used to make the child name validation pass
var appNameForBicep = !empty(apiAppName) ? apiAppName : 'placeholderName'

resource apiDiagnostics 'Microsoft.ApiManagement/service/apis/diagnostics@2021-12-01-preview' = {
name: 'applicationinsights'
parent: apimService::restApi
properties: {
alwaysLog: 'allErrors'
backend: {
request: {
body: {
bytes: 1024
}
}
response: {
body: {
bytes: 1024
}
}
}
frontend: {
request: {
body: {
bytes: 1024
}
}
response: {
body: {
bytes: 1024
}
}
}
httpCorrelationProtocol: 'W3C'
logClientIp: true
loggerId: apimLogger.id
metrics: true
sampling: {
percentage: 100
samplingType: 'fixed'
}
verbosity: 'verbose'
}
}

resource apiAppProperties 'Microsoft.Web/sites/config@2022-03-01' = if (!empty(apiAppName)) {
name: '${appNameForBicep}/web'
kind: 'string'
properties: {
apiManagementConfig: {
id: '${apimService.id}/apis/${apiName}'
}
}
}

resource apimLogger 'Microsoft.ApiManagement/service/loggers@2021-12-01-preview' = if (!empty(applicationInsightsName)) {
name: 'app-insights-logger'
parent: apimService
properties: {
credentials: {
instrumentationKey: applicationInsights.properties.InstrumentationKey
}
description: 'Logger to Azure Application Insights'
isBuffered: false
loggerType: 'applicationInsights'
resourceId: applicationInsights.id
}
}

resource applicationInsights 'Microsoft.Insights/components@2020-02-02' existing = if (!empty(applicationInsightsName)) {
name: applicationInsightsName
}

resource apimService 'Microsoft.ApiManagement/service@2021-08-01' existing = {
name: name

resource restApi 'apis@2021-12-01-preview' existing = {
name: apiName
}
}

output SERVICE_API_URI string = '${apimService.properties.gatewayUrl}/${apiPath}'
Loading
Loading