Last active
March 1, 2022 14:57
-
-
Save justinyoo/4b0138f38c8b15edbaa6fafe2c2a9e1e to your computer and use it in GitHub Desktop.
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
{ | |
"Values": { | |
"FUNCTIONS_WORKER_RUNTIME": "dotnet" | |
} | |
} |
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
- name: Generate OpenAPI document | |
shell: pwsh | |
env: | |
OpenApi__HostNames: 'https://<azure-functions-app>.azurewebsites.net/api' | |
AZURE_FUNCTIONS_ENVIRONMENT: 'Production' | |
run: | | |
cd MyFunctionApp | |
mkdir outputs | |
# Create local.settings.json | |
cp ./local.settings.sample.json ./local.settings.json | |
Start-Process -NoNewWindow func @("start","--verbose","false") | |
Start-Sleep -s 60 | |
Invoke-RestMethod -Method Get -Uri http://localhost:7071/api/swagger.json | ConvertTo-Json -Depth 100 | Out-File -FilePath outputs/swagger.json -Force | |
Get-Content -Path outputs/swagger.json -Raw | |
cd .. |
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
// OpenAPI v2 | |
{ | |
"swagger": "2.0", | |
"host": "<azure-functions-app>.azurewebsites.net", | |
"basePath": "/api", | |
"schemes": [ | |
"https" | |
] | |
} | |
// OpenAPI v3 | |
{ | |
"openapi": "3.0.1", | |
"servers": [ | |
{ | |
"url": "https://<azure-functions-app>.azurewebsites.net/api" | |
} | |
] | |
} |
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
// azuredeploy.bicep | |
param servicename string | |
resource apim 'Microsoft.ApiManagement/service@2021-08-01' existing = { | |
name: servicename | |
scope: resourceGroup(apiManagement.groupName) | |
} |
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
// azuredeploy.bicep | |
param openapidoc string | |
resource apimapi 'Microsoft.ApiManagement/service/apis@2021-08-01' = { | |
name: '${apim.name}/my-api' | |
properties: { | |
type: 'http' | |
displayName: 'My API' | |
description: 'This is my API.' | |
path: 'myapi' | |
subscriptionRequired: true | |
format: 'openapi+json-link' | |
value: openapidoc | |
} | |
} |
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
$servicename = "<my_apim_service_name>" | |
$openapidoc = https://<my_blob_storage_name>.blob.core.windows.net/<container>/openapi.json | |
az deployment group create ` | |
-g <resource_group_name> ` | |
-n <deployment_name> ` | |
-f ./azuredeploy.bicep ` | |
-p servicename=$servicename ` | |
-p openapidoc=$openapidoc |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment