アジュールAPI管理101
12605 ワード
概要
これは、あなたの最初のステップを歩くのノートですAzure Azure API Mamanagement . AzureパイプラインYAMLとのコードサンプルはこちらです.NET 6
TOC
Step by Step
建築
一歩一歩
配備する
BASE_NAME
and ENVIRONMENT_SYMBOL
in variables-template.yml スガー.JSON OpenAPI format in API Management requires [swagger.json] file. You can extract the file by running the app TravelApi ローカル.ファイルの位置は以下のようになります
https://localhost:7228/swagger/v1/swagger.json
スワガーJSONの例{
"openapi": "3.0.1",
"info": {
"title": "TravelApi",
"version": "1.0"
},
"paths": {
"/TravelPlan": {
"get": {
"tags": [
"TravelPlan"
],
"summary": "Get a list of destinations",
"description": "Sample request:\r\n \r\n GET /travelplan",
"responses": {
"400": {
"description": "Bad Request"
},
"401": {
"description": "Unauthorized"
},
"500": {
"description": "Server Error"
},
"503": {
"description": "Server Error"
},
"200": {
"description": "Success",
"content": {
"application/json": {
"schema": {
"type": "array",
"items": {
"$ref": "#/components/schemas/Destination"
}
}
}
}
}
}
}
}
},
"components": {
"schemas": {
"Destination": {
"type": "object",
"properties": {
"country": {
"type": "string",
"nullable": true
},
"city": {
"type": "string",
"nullable": true
},
"food": {
"type": "string",
"nullable": true
},
"sightSeeing": {
"type": "string",
"nullable": true
}
},
"additionalProperties": false
}
}
}
}
スワガーローカルで走るときAPIをインポート The code sample already includes a
TravelApi
api in ARM template azuredeploy-apim.json . これはAPIのコンテンツを持っていない、あなたがインポートし、swaggerを追加する必要があります.それをJSON.Azuredeploy APIMJSON
{
"type": "Microsoft.ApiManagement/service/apis",
"apiVersion": "2021-08-01",
"name": "[concat(variables('apim_name'), '/travelapi')]",
"dependsOn": [
"[resourceId('Microsoft.ApiManagement/service', variables('apim_name'))]"
],
"properties": {
"displayName": "TravelApi",
"subscriptionRequired": true,
"serviceUrl": "[variables('apim_service_url')]",
"protocols": [
"https"
],
"path": ""
}
}
Azureポータルと展開されたAzure API管理に移動します.あなたが表示されますTravelApi
ARMテンプレートで既に設定されています.あなたは加えるつもりですswagger.json
はい.APIs
--> TravelApi
--> 輸入絹篩で篩うたよう
OpenAPI
絹篩で篩うたよう
swagger.json
前のステップで抽出.絹篩で篩うたようAppend
and Postfix
, and Import
.APIをテストする
Go to API Management --> APIs
--> TravelApi
--> Test
--> GET /TravelPlan
, and Send
. You will see the successful response from the deployed App Service.
サブスクリプションキーを取得する
In order to test the API from your local machine, you need to get a subscription key to access the API.
Go to API Management --> Subscriptions
--> Build-in all-access subscription
, and then keep Primary Key for later usage.
APIをテストする
Send HTTP request from the terminal like below.
Bash example
curl -H "Ocp-Apim-Subscription-Key: {Primary Key}" https://{API Management name}.azure-api.net/travelplan
Example response
[
{
"country": "France",
"city": "Paris",
"food": "Wine",
"sightSeeing": "Eiffel Tower"
},
{
"country": "Japan",
"city": "Tokyo",
"food": "Ramen",
"sightSeeing": "Skytree"
}
]
API管理パージ According to the Microsoft official document 2022年1月現在、API管理インスタンスはソフト削除(Azure Resource Manager API 2010 - 06 - 01 -プレビューまたはそれ以降)です.ソフト削除例の保留間隔は48時間である.また、ハード削除されたインスタンスをハードthe REST API .
パワーシェルサンプル
az rest --method delete --header "Accept=application/json" `
-u 'https://management.azure.com/subscriptions/{Azure Subscription ID}/providers/Microsoft.ApiManagement/locations/{Location}/deletedservices/{API Management name}?api-version=2021-08-01'
Reference
この問題について(アジュールAPI管理101), 我々は、より多くの情報をここで見つけました https://dev.to/koheikawata/azure-api-management-101-3j7cテキストは自由に共有またはコピーできます。ただし、このドキュメントのURLは参考URLとして残しておいてください。
Collection and Share based on the CC Protocol