《Windows Azure Platform 系列文章目录

 

  1.API Management Developer Portal进行测试的时候,报错 "Unable to complete the request. Since the browser Initiates the request, it requires Cross-Origin Resource Sharing (CORS) enable on the server. Lean More.

  Azure API Management (1) 最近遇到的问题总结
    




Windows Azure Platform 系列文章目录

  解决方法:

  点击API Management,点击Portal Overview,点击Enable CORS,点击Manually apply it on the global level。

  复制CORS policy,如下图:

  Azure API Management (1) 最近遇到的问题总结
    




Windows Azure Platform 系列文章目录

  然后点击API Management,API

  Azure API Management (1) 最近遇到的问题总结
    




Windows Azure Platform 系列文章目录 

  在All APIs里面,点击Inbound processing,点击Add Policy,在弹出的窗口中,选择CORS

  Azure API Management (1) 最近遇到的问题总结
    




Windows Azure Platform 系列文章目录

  在CORS配置里,把我们在CORS policy里面的设置复制到cors policy里。

 

 

 

  2. API Management在API clone的时候,为什么backend地址会变化

  解答:API Management在开发的时候,最好设置为backend + path

  举个例子:我们请求的地址为多个,如:

  -  https://myapi.chinacloudsites.cn/home/GetUser

  -  https://myapi.chinacloudsites.cn/home/GetStudent

  我们最好设置为:

  -  backend设置为: https://myapi.chinacloudsites.cn/home

  -  path分别设置为/GetUser,/GetStudent

 

  在API里,设置Setting里面的Web service URL,设置请求路径

  Azure API Management (1) 最近遇到的问题总结
    




Windows Azure Platform 系列文章目录

 

  然后在不同的API里,设置API的Frontend,如下图:

  Azure API Management (1) 最近遇到的问题总结
    




Windows Azure Platform 系列文章目录

  在URL里,设置具体的path。如下图:

  Azure API Management (1) 最近遇到的问题总结
    




Windows Azure Platform 系列文章目录

 

 

  3.在HTTP Post里,如何设置Request Body的类型?

  解答:可以通过设置Definition来实现。

  我们点击APIs,点击方法,点击Definitions。如下图:

  Azure API Management (1) 最近遇到的问题总结
    




Windows Azure Platform 系列文章目录

 

  在Definitions里,设置API的定义,如下图:

  Azure API Management (1) 最近遇到的问题总结
    




Windows Azure Platform 系列文章目录

 

  定义完毕后,选择Frontend

  Azure API Management (1) 最近遇到的问题总结
    




Windows Azure Platform 系列文章目录

 

  在弹出的窗口中,选择Request,然后鼠标下拉,在Definition里,选择我们在上面新建的Definition

  Azure API Management (1) 最近遇到的问题总结
    




Windows Azure Platform 系列文章目录

 

  设置完毕后,可以在API Management 的Developer Portal看到相关的Definition

 

 

 

  4.如何设置API Management里的参数为必须?

  解答:我查找文档:https://github.com/Azure/api-management-developer-portal/issues/349 

  在Azure API Management里,设置Definition里的Required参数。如下图:

  Azure API Management (1) 最近遇到的问题总结
    




Windows Azure Platform 系列文章目录    

  在Developer Portal中显示的结果:

Azure API Management (1) 最近遇到的问题总结
    




Windows Azure Platform 系列文章目录

 

 

 

 

  5.如何保护Azure API Management的后端服务,让客户端只能访问Azure API Management,无法访问后端的服务?

  解答:可以有多种方式实现:

  方式1:把后端的服务加入到VNet里,然后让API Management与VNet集成

  方式2:笔者的环境里,后端服务是使用Azure App Service,可以可以先查看API Management的公网IP地址:

 

  请注意:

  API Managment的公网IP地址,在以下情况下会发生改变:

  •   服务被删除,然后重新创建。
  •   服务订阅被暂停或警告(例如,由于未付款),然后恢复。
  •   在该服务中添加或删除 Azure 虚拟网络。  
  •   API 管理服务在外部和内部 VNet 部署模式间切换。

 

  具体操作如下图:

  Azure API Management (1) 最近遇到的问题总结
    




Windows Azure Platform 系列文章目录

 

  然后在Azure App Service里,设置IPV4防火墙规则。

  Azure API Management (1) 最近遇到的问题总结
    




Windows Azure Platform 系列文章目录

 

  

相关文章:

  • 2022-01-29
  • 2021-06-24
  • 2022-01-14
  • 2022-01-29
  • 2021-10-14
  • 2022-02-13
  • 2021-12-08
  • 2021-10-01
猜你喜欢
  • 2021-10-13
  • 2021-09-16
  • 2021-05-15
  • 2021-10-06
  • 2021-08-15
  • 2021-10-28
  • 2021-05-20
相关资源
相似解决方案