首页 > 其他分享 >【Azure 应用服务】调用Azure REST API来获取 App Service的访问限制信息(Access Restrictions)以及修改

【Azure 应用服务】调用Azure REST API来获取 App Service的访问限制信息(Access Restrictions)以及修改

时间:2023-05-16 23:32:57浏览次数:45  
标签:Restrictions Web cn Service web api https Azure

问题描述

介绍了使用Python SDK 来获取App Service的访问限制信息,那么如何调用REST API来实现呢? 

问题解答

如大家所知,Azure 不管是SDK, 门户UI,或者是PowerShell命令方式对Azure中资源进行操作,都是通过REST API方式处理请求。所以,如果不知道当前操作使用的是一个接口时,最简单的方法是:通过浏览器打开Azure门户,同时开启开发者模式(F12),在Azure门户上执行想执行的操作。然后查看Network Trace。

比如,想知道App Service的Access Restrictions操作是调用的哪一个API,找到点击保存时候,浏览器发出的请求即可找到。如下图中标记的1,2,3处。

【Azure 应用服务】调用Azure REST API来获取 App Service的访问限制信息(Access Restrictions)以及修改_Web

在找到对于的API URL后,就可以知道大概的调查方向了。

以上两个接口,就可以实现获取,更新App Service的访问限制信息需求。

PS:  因文档为Global Azure说明文档,所以中国区的 API URL为:https://management.chinacloudapi.cn/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Web/sites/{name}/config/web?api-version=2022-03-01

 

操作示例步骤为:

获取Web Apps 配置信息(其中包含Access Restrictions)

Request Method:GET

Request URL: https://management.chinacloudapi.cn/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Web/sites/{name}/config/web?api-version=2022-03-01

Request Authorization:如是临时性操作,可以通过浏览器(开发者模式F12-->Network Trace)获取到请求所携带的Authorization Token(注:这个值过期时间为1个消失)。

Request Body:无

 

示例截图

【Azure 应用服务】调用Azure REST API来获取 App Service的访问限制信息(Access Restrictions)以及修改_Web_02

没有Token的效果图:

【Azure 应用服务】调用Azure REST API来获取 App Service的访问限制信息(Access Restrictions)以及修改_Azure_03

Token过期效果图:

【Azure 应用服务】调用Azure REST API来获取 App Service的访问限制信息(Access Restrictions)以及修改_Azure_04

 

仅仅更新Access Restrictions部分

Request Method:PATCH

Request URL: https://management.chinacloudapi.cn/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Web/sites/{name}/config/web?api-version=2022-03-01

Request Authorization:如是临时性操作,可以通过浏览器(开发者模式F12-->Network Trace)获取到请求所携带的Authorization Token(注:这个值过期时间为1个消失)。

Request Body:

{
	"properties": {
		"ipSecurityRestrictions": [
			{
				"ipAddress": "183.220.92.41/32",
				"action": "Allow",
				"tag": "Default",
				"priority": 200,
				"name": "111111"
			},
			{
				"ipAddress": "Any",
				"action": "Deny",
				"priority": 2147483647,
				"name": "Deny all",
				"description": "Deny all access"
			}
		]
	}
}

特别注意:以上JSON内容为覆盖模式,如果需要在以前的数据中新添加,需要在Body中包含之前的数据。否则,PATCH操作完成后,就只会剩下Body中的信数据。

示例截图

【Azure 应用服务】调用Azure REST API来获取 App Service的访问限制信息(Access Restrictions)以及修改_Azure_05

 

参考资料

Web Apps - Get Configurationhttps://learn.microsoft.com/zh-cn/rest/api/appservice/web-apps/get-configuration

Web Apps - Update Configurationhttps://learn.microsoft.com/zh-cn/rest/api/appservice/web-apps/update-configuration

 

当在复杂的环境中面临问题,格物之道需:浊而静之徐清,安以动之徐生。 云中,恰是如此!



标签:Restrictions,Web,cn,Service,web,api,https,Azure
From: https://blog.51cto.com/u_13773780/6287999

相关文章

  • 【Azure 应用服务】应用服务连接 Azure MySQL 一直失败,报错 Create connection error
    问题描述AppService上部署的Java应用,连接 AzureDatabaseforMySQL失败。错误信息:Createconnectionerror,url:jdbc:mysql://.......................communicationslinkfailure. 问题解答应用的错误信息提示为:与MySQL数据库建立连接失败。所以需要考虑如下几种......
  • 问题记录之mysql:Job for mysqld.service failed because the control process exited
    今天服务器连接mysql发现一直超时(查出的原因是磁盘满了)清了磁盘以后,mysqld.service 还是无法启动执行命令及报错如下:(注意,因为磁盘满的问题,我的mysql并不是正常途径关闭的)控制进程以错误代码退出导致无法以正常的方式启动它了,错误说明:Jobformysqld.servicefailedbecauset......
  • Best practices for customization | Kentico 12 Service Pack Documentation (xperie
    Bestpracticesforcustomization|Kentico12ServicePackDocumentation(xperience.io)UsingjQuery Note:TheinformationinthissectiononlyappliestotheKenticoadministrationinterfaceandsitesbuiltusingthePortalEnginedevelopmentmodel,......
  • DrawerLayout配合WindowManager在service中使用
    1.原理理解抽屉组件依附在WindowManager上,WindowManager大于DrawerLayout,因此DrawerLayout抽出和放回是基于WindowManager已经展示出来的情况。2.布局文件<?xmlversion="1.0"encoding="utf-8"?><RelativeLayoutxmlns:android="http://schemas.android.com/apk/res/androi......
  • Spring 3 & jBPM 5 & LocalTaskService
    帖子地址:[url]https://community.jboss.org/thread/195386[/url]HiGuys,IamalsostrugglinginconfigSpring+LocalHumanTask.Iamusing[color=red][b]Spring3.0,JBPM5.4.0.Final,Drools5.5.0.Final[/b][/color]IcanconfigtouseJTA......
  • springboot 整合webservice 相关说明
    1.环境依赖jdk8,springboot2.3.12.release,cxf版本需要根据springboot版本修改,方法:查看springboot版本的发布日期,然后根据日期找相近的两个版本<dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter</artifactId><versi......
  • hibernate Restrictions用法
    [url]http://xuganggogo.iteye.com/blog/440078[/url]QBC常用限定方法[b]Restrictions.eq-->equal,等于.Restrictions.ne-->不等于Restrictions.allEq-->利用Map来进行多个等于的限制,参数为Map对象,使用key/value进行多个等于的比对,相当于多个Re......
  • 【Azure Redis 缓存】使用开源工具redis-copy时遇见6379端口无法连接到Redis服务器的
    问题描述当使用AzureRedis服务时,需要把一个Redis服务的数据导入到另一个Redis上,因为Redis服务没有使用高级版,所以不支持直接导入/导出RDB文件。以编程方式来读取数据并写入到新的Redis服务端,使用开源工具Redis-Copy却遇见了6379端口无法连接的问题。而用redis-cli.exe却......
  • Microsoft.Exchange.WebServices.Data;
    using Microsoft.Exchange.WebServices.Data;using Microsoft.Identity.Client;using System;using System.Configuration; namespace EwsOAuth{   class Program  {     static async System.Threading.Tasks.Task Main(string[] args) ......
  • Parameter 9 of constructor in com.xxx.impl.xxxServiceImpl required a bean of ty
    1查看Service实现类是否加了@AllArgsConstructor2删除@AllArgsConstructor3给每个要注入的serviceBean加@Resource原因lombok的@AllArgsConstructor注解会代替@Autowired注入,导致某些不需要手动注入的bean重复加了@Autowired......