-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
19 changed files
with
12,571 additions
and
8,484 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,6 @@ | ||
ARG VARIANT=bullseye | ||
FROM mcr.microsoft.com/vscode/devcontainers/base:0-${VARIANT} | ||
FROM --platform=amd64 mcr.microsoft.com/vscode/devcontainers/base:0-${VARIANT} | ||
RUN export DEBIAN_FRONTEND=noninteractive \ | ||
&& apt-get update && apt-get install -y xdg-utils \ | ||
&& apt-get clean -y && rm -rf /var/lib/apt/lists/* | ||
RUN curl -fsSL https://aka.ms/install-azd.sh | bash |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
<!-- Policy configuration for the API. Explore other sample policies at https://learn.microsoft.com/en-us/azure/api-management/policies/ --> | ||
<policies> | ||
<inbound> | ||
<base /> | ||
<!-- This policy is needed to handle preflight requests using the OPTIONS method. Learn more at https://learn.microsoft.com/en-us/azure/api-management/api-management-cross-domain-policies --> | ||
<cors allow-credentials="false"> | ||
<allowed-origins> | ||
<origin>{origin}</origin> | ||
</allowed-origins> | ||
<allowed-methods> | ||
<method>PUT</method> | ||
<method>GET</method> | ||
<method>POST</method> | ||
<method>DELETE</method> | ||
<method>PATCH</method> | ||
</allowed-methods> | ||
<allowed-headers> | ||
<header>*</header> | ||
</allowed-headers> | ||
<expose-headers> | ||
<header>*</header> | ||
</expose-headers> | ||
</cors> | ||
<!-- Optional policy to validate the request content. Learn more at https://learn.microsoft.com/en-us/azure/api-management/validation-policies#validate-content --> | ||
<validate-content unspecified-content-type-action="ignore" max-size="1024" size-exceeded-action="detect" errors-variable-name="requestBodyValidation"> | ||
<content type="application/json" validate-as="json" action="detect" /> | ||
</validate-content> | ||
<!-- Optional policy to send custom trace telemetry to Application Insights. Learn more at https://learn.microsoft.com/en-us/azure/api-management/api-management-advanced-policies#Trace --> | ||
<trace source="@(context.Api.Name)" severity="verbose"> | ||
<message>Call to the @(context.Api.Name)</message> | ||
<metadata name="User-Agent" value="@(context.Request.Headers.GetValueOrDefault("User-Agent",""))" /> | ||
<metadata name="Operation Method" value="@(context.Request.Method)" /> | ||
<metadata name="Host" value="@(context.Request.Url.Host)" /> | ||
<metadata name="Path" value="@(context.Request.Url.Path)" /> | ||
</trace> | ||
</inbound> | ||
<backend> | ||
<limit-concurrency key="@(context.Request.IpAddress)" max-count="3"> | ||
<forward-request timeout="120" /> | ||
</limit-concurrency> | ||
</backend> | ||
<outbound> | ||
<base /> | ||
<!-- Optional policy to validate the response headers. Learn more at https://learn.microsoft.com/en-us/azure/api-management/validation-policies#validate-headers --> | ||
<validate-headers specified-header-action="ignore" unspecified-header-action="ignore" errors-variable-name="responseHeadersValidation" /> | ||
<!-- Optional policy to to send custom metrics to Application Insights. Learn more at https://learn.microsoft.com/en-us/azure/api-management/api-management-advanced-policies#emit-metrics --> | ||
<choose> | ||
<when condition="@(context.Response.StatusCode >= 200 && context.Response.StatusCode < 300)"> | ||
<emit-metric name="Successful requests" value="1" namespace="apim-metrics"> | ||
<dimension name="API" value="@(context.Api.Name)" /> | ||
<dimension name="Client IP" value="@(context.Request.IpAddress)" /> | ||
<dimension name="Status Code" value="@((String)context.Response.StatusCode.ToString())" /> | ||
<dimension name="Status Reason" value="@(context.Response.StatusReason)" /> | ||
</emit-metric> | ||
</when> | ||
<when condition="@(context.Response.StatusCode >= 400 && context.Response.StatusCode < 600)"> | ||
<emit-metric name="Failed requests" value="1" namespace="apim-metrics"> | ||
<dimension name="API" value="@(context.Api.Name)" /> | ||
<dimension name="Client IP" value="@(context.Request.IpAddress)" /> | ||
<dimension name="Status Code" value="@(context.Response.StatusCode.ToString())" /> | ||
<dimension name="Status Reason" value="@(context.Response.StatusReason)" /> | ||
<dimension name="Error Source" value="backend" /> | ||
</emit-metric> | ||
</when> | ||
</choose> | ||
</outbound> | ||
<on-error> | ||
<base /> | ||
<!-- Optional policy to handle errors. Learn more at https://learn.microsoft.com/en-us/azure/api-management/api-management-error-handling-policies --> | ||
<trace source="@(context.Api.Name)" severity="error"> | ||
<message>Failed to process the @(context.Api.Name)</message> | ||
<metadata name="User-Agent" value="@(context.Request.Headers.GetValueOrDefault("User-Agent",""))" /> | ||
<metadata name="Operation Method" value="@(context.Request.Method)" /> | ||
<metadata name="Host" value="@(context.Request.Url.Host)" /> | ||
<metadata name="Path" value="@(context.Request.Url.Path)" /> | ||
<metadata name="Error Reason" value="@(context.LastError.Reason)" /> | ||
<metadata name="Error Message" value="@(context.LastError.Message)" /> | ||
</trace> | ||
<emit-metric name="Failed requests" value="1" namespace="apim-metrics"> | ||
<dimension name="API" value="@(context.Api.Name)" /> | ||
<dimension name="Client IP" value="@(context.Request.IpAddress)" /> | ||
<dimension name="Status Code" value="500" /> | ||
<dimension name="Status Reason" value="@(context.LastError.Reason)" /> | ||
<dimension name="Error Source" value="gateway" /> | ||
</emit-metric> | ||
<!-- Optional policy to hide error details and provide a custom generic message. Learn more at https://learn.microsoft.com/en-us/azure/api-management/api-management-advanced-policies#ReturnResponse --> | ||
<return-response> | ||
<set-status code="500" reason="Internal Server Error" /> | ||
<set-body>An unexpected error has occurred.</set-body> | ||
</return-response> | ||
</on-error> | ||
</policies> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
param name string | ||
|
||
@description('Resouce name to uniquely dentify this API within the API Management service instance') | ||
@minLength(1) | ||
param apiName string | ||
|
||
@description('The Display Name of the API') | ||
@minLength(1) | ||
@maxLength(300) | ||
param apiDisplayName string | ||
|
||
@description('Description of the API. May include HTML formatting tags.') | ||
@minLength(1) | ||
param apiDescription 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('Absolute URL of the web frontend') | ||
param webFrontendUrl string | ||
|
||
@description('Absolute URL of the backend service implementing this API.') | ||
param apiBackendUrl string | ||
|
||
var apiPolicyContent = replace(loadTextContent('./apim-api-policy.xml'), '{origin}', webFrontendUrl) | ||
|
||
resource restApi 'Microsoft.ApiManagement/service/apis@2021-12-01-preview' = { | ||
name: apiName | ||
parent: apimService | ||
properties: { | ||
description: apiDescription | ||
displayName: apiDisplayName | ||
path: apiPath | ||
protocols: [ 'https' ] | ||
subscriptionRequired: false | ||
type: 'http' | ||
format: 'openapi' | ||
serviceUrl: apiBackendUrl | ||
value: loadTextContent('../../src/api/wwwroot/openapi.yaml') | ||
} | ||
} | ||
|
||
resource apiPolicy 'Microsoft.ApiManagement/service/apis/policies@2021-12-01-preview' = { | ||
name: 'policy' | ||
parent: restApi | ||
properties: { | ||
format: 'rawxml' | ||
value: apiPolicyContent | ||
} | ||
} | ||
|
||
resource apiDiagnostics 'Microsoft.ApiManagement/service/apis/diagnostics@2021-12-01-preview' = { | ||
name: 'applicationinsights' | ||
parent: 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 apimService 'Microsoft.ApiManagement/service@2021-08-01' existing = { | ||
name: name | ||
} | ||
|
||
resource apimLogger 'Microsoft.ApiManagement/service/loggers@2021-12-01-preview' existing = { | ||
name: 'app-insights-logger' | ||
parent: apimService | ||
} | ||
|
||
output SERVICE_API_URI string = '${apimService.properties.gatewayUrl}/${apiPath}' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
param name string | ||
param location string = resourceGroup().location | ||
param tags object = {} | ||
|
||
@description('The email address of the owner of the service') | ||
@minLength(1) | ||
param publisherEmail string = '[email protected]' | ||
|
||
@description('The name of the owner of the service') | ||
@minLength(1) | ||
param publisherName string = 'n/a' | ||
|
||
@description('The pricing tier of this API Management service') | ||
@allowed([ | ||
'Consumption' | ||
'Developer' | ||
'Standard' | ||
'Premium' | ||
]) | ||
param sku string = 'Consumption' | ||
|
||
@description('The instance size of this API Management service.') | ||
@allowed([ 0, 1, 2 ]) | ||
param skuCount int = 0 | ||
|
||
@description('Azure Application Insights Name') | ||
param applicationInsightsName string | ||
|
||
resource apimService 'Microsoft.ApiManagement/service@2021-08-01' = { | ||
name: name | ||
location: location | ||
tags: union(tags, { 'azd-service-name': name }) | ||
sku: { | ||
name: sku | ||
capacity: (sku == 'Consumption') ? 0 : ((sku == 'Developer') ? 1 : skuCount) | ||
} | ||
properties: { | ||
publisherEmail: publisherEmail | ||
publisherName: publisherName | ||
} | ||
} | ||
|
||
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 | ||
} | ||
|
||
output apimServiceName string = apimService.name |
Oops, something went wrong.