Aya*_*ick 1 azure azure-api-management swagger-2.0 azure-functions
怎么能一个配置,直通Visual Studio代码,一个PowerShell API在Azure中运行的功能,使其可以食用从Azure的API管理提供的OpenAPI,规范API类似这样的URL如提到的,教程?
目前,如果我尝试在Azure API管理中将以下PowerShell API添加为OpenAPI规范API,则会出错
Unable to parse specified file. Please ensure it is valid OpenAPI specification document.
Run Code Online (Sandbox Code Playgroud)
Azure函数PowerShell API URL:https: //vscpsapi.azurewebsites.net/api/VSCPSapi
更新
事情发生了变化,当我们点击V2 Function app中的API定义时,请参阅
目前V2运行时不支持函数API定义(Swagger)功能.
我们可以直接将Function app导入到API Management而无需API定义.
您需要首先为Azure功能创建OpenAPI定义.
请参阅创建OpenAPI定义.
脚步:
平台功能> API定义.
在API定义源下,选择Function(Preview)将HTTP触发器用作API处理程序.
生成API定义模板>保存.
为httptrigger函数模板粘贴以下swagger模板.
然后使用您的功能应用程序和触发器名称修改它.security如果您的功能授权级别是匿名的,请删除部分.
swagger: '2.0'
info:
title: <myfunctionapp>.azurewebsites.net
version: 1.0.0
host: <myfunctionapp>.azurewebsites.net
basePath: /
schemes:
- https
- http
paths:
/api/<MyHttpTrigger>:
get:
operationId: /api/<MyHttpTrigger>/get
description: Send a name to API to get Hello name back
summary: Get Hello name
parameters:
- in: query
name: name
description: Name to send
required: true
type: string
responses:
'200':
description: Return Hello name
security:
- apikeyQuery: []
post:
operationId: /api/<MyHttpTrigger>/post
description: Send a name to API to get Hello name back
summary: Get Hello name
consumes:
- application/json
parameters:
- name: requestbody
in: body
description: Name to send
required: true
schema:
type: object
properties:
name:
type: string
responses:
'200':
description: Return Hello name
security:
- apikeyQuery: []
securityDefinitions:
apikeyQuery:
type: apiKey
name: code
in: query
Run Code Online (Sandbox Code Playgroud)
在API管理中添加API时,您可以选择OpenAPI specification或Function App.
如果您保留安全部件,因为您的功能授权级别为Admin/Function,您必须在Manage功能部件下拉菜单中找到功能键并更新后端URL Inbound Processing.
您可以在选择时明确提示添加密钥Function App.
功能应用程序"funcappname"已导入.请确保将以下命名值的值替换为函数的秘密:funcappname_triggername_query_xxxxxx.
如果需要修改swagger,请参阅OpenAPI 2.0文档.
| 归档时间: |
|
| 查看次数: |
602 次 |
| 最近记录: |