Azure API アプリを作成し、Azure にデプロイしました。最初は、ポータルから (つまり、API アプリ ブレードの [API 定義] ボタンをクリックして) Swagger ファイルを問題なく取得できましたが、ある時点で機能しなくなりました。
で Swagger UI を有効にしましたApp_Start\SwaggerConfig.cs
。ローカルでデバッグするときは、http://localhost:12345/Swaggerに移動して Swagger UI にアクセスし、Swagger ファイルをダウンロードすると、すべて正常に動作します。ポータルにアクセスすると、 https://microsoft-apiappad6cxxxxxxxxxxxx426c23a66.azurewebsites.net:443/swagger/docs/v1にアクセスしようとすると 500 エラーが発生します。
API アプリを削除して再デプロイしようとしましたが、うまくいきません。新しいプロジェクトを開始し、それと同じインターフェイスを作成して、それを Azure にデプロイしようとしました...毎回動作します (もちろん)。
重要な場合に備えて、ここに Swagger ファイルを含めますが、理解できないのは、Swashbuckle がローカルでは機能するのに、Azure では機能しないのはなぜですか?
{
"swagger": "2.0",
"info": {
"version": "v1",
"title": "StorefrontApi"
},
"host": "localhost:52912",
"schemes": [
"http"
],
"paths": {
"/api/v1/storefront/applications": {
"get": {
"tags": [
"GET"
],
"operationId": "Storefront_Applications",
"consumes": [],
"produces": [
"application/json",
"text/json",
"application/xml",
"text/xml"
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/Object"
}
}
},
"deprecated": false
}
},
"/api/v1/storefront/aurorastatus": {
"get": {
"tags": [
"GET"
],
"operationId": "Storefront_AuroraStatus",
"consumes": [],
"produces": [
"application/json",
"text/json",
"application/xml",
"text/xml"
],
"parameters": [
{
"name": "auroraSerialNumber",
"in": "query",
"required": true,
"type": "string"
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/Object"
}
}
},
"deprecated": false
}
},
"/api/v1/storefront/order": {
"post": {
"tags": [
"POST"
],
"operationId": "Storefront_Order",
"consumes": [
"application/json",
"text/json",
"application/xml",
"text/xml",
"application/x-www-form-urlencoded"
],
"produces": [
"application/json",
"text/json",
"application/xml",
"text/xml"
],
"parameters": [
{
"name": "requestBody",
"in": "body",
"required": true,
"schema": {
"type": "string"
}
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/Object"
}
}
},
"deprecated": false
}
},
"/api/v1/storefront/register": {
"post": {
"tags": [
"POST"
],
"summary": "",
"operationId": "Storefront_Register",
"consumes": [
"application/json",
"text/json",
"application/xml",
"text/xml",
"application/x-www-form-urlencoded"
],
"produces": [
"application/json",
"text/json",
"application/xml",
"text/xml"
],
"parameters": [
{
"name": "requestBody",
"in": "body",
"description": "",
"required": true,
"schema": {
"type": "string"
}
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/Object"
}
}
},
"deprecated": false
}
},
"/api/v1/storefront/removeapplication": {
"post": {
"tags": [
"POST"
],
"summary": "",
"operationId": "Storefront_RemoveApplication",
"consumes": [
"application/json",
"text/json",
"application/xml",
"text/xml",
"application/x-www-form-urlencoded"
],
"produces": [
"application/json",
"text/json",
"application/xml",
"text/xml"
],
"parameters": [
{
"name": "requestBody",
"in": "body",
"description": "",
"required": true,
"schema": {
"type": "string"
}
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/Object"
}
}
},
"deprecated": false
}
},
"/api/v1/storefront/updateserialnumber": {
"post": {
"tags": [
"POST"
],
"operationId": "Storefront_UpdateSerialNumber",
"consumes": [
"application/json",
"text/json",
"application/xml",
"text/xml",
"application/x-www-form-urlencoded"
],
"produces": [
"application/json",
"text/json",
"application/xml",
"text/xml"
],
"parameters": [
{
"name": "requestBody",
"in": "body",
"required": true,
"schema": {
"type": "string"
}
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/Object"
}
}
},
"deprecated": false
}
}
},
"definitions": {
"Object": {
"type": "object",
"properties": {}
}
}
}
もちろん、これにより、ロジック アプリで API アプリを使用する機能が制限されます。また、右クリックして Azure API アプリ クライアントをプロジェクトに追加する機能も制限されます。(はい、Swagger ファイルをローカルで取得し、それを変更してプロジェクトで使用できますが、それは私たちが探しているフローではありません)。
API アプリが有効な Swagger を生成できない (または Swashbuckle コードを適切に実行できない) 原因について何か考えがある人はいますか?