简体   繁体   English

在Microsoft Azure中导出和导入入站安全规则

[英]Export and import Inbound Security Rules in Microsoft Azure

I've to Delete an existing Virtual Machine in Azure and the Network Security Group associated with the VM . 我将删除Azure的现有Virtual Machine以及与VM关联的Network Security Group But I need to store the Inbound Security Rules of the Network Security Group that I'm gonna Delete. 但我需要存储我要删除的Network Security GroupInbound Security Rules

Is there any way to export the Inbound Security Rules as a template to some sort of JSON , CSV or any other format and then I can apply it to other Network Security Group by Importing the Inbound Security Rules from the template? 有没有办法将Inbound Security Rules作为模板导出为某种JSONCSV或任何其他格式,然后我可以通过从模板导入Inbound Security Rules将其应用于其他Network Security Group

If you don't want to use shell, you can use a simple API call to: 如果您不想使用shell,可以使用简单的API调用:

https://management.azure.com/subscriptions/YOUR_SUBSCRIPTIONID/resourceGroups/YOUR_RESOURCE_GROUP_NAME/providers/Microsoft.Network/networkSecurityGroups/YOUR_NSG_NAME?api-version=2016-07-01

This will return a JSON response with your rules under properties.securityRules. 这将使用properties.securityRules下的规则返回JSON响应。

You need to include the an Authorization header, which you can get by: 您需要包含一个Authorization标头,您可以通过以下方式获取:

Log into Azure > open developer mode on your browser > open the network tab and look for invoke > copy the Authorization header (should start with Bearer ). 在浏览器上登录Azure>打开开发人员模式>打开网络选项卡,然后查找调用 >复制授权标头 (应以Bearer开头)。

Here is an example: 这是一个例子:

如何获取Azure授权标头

You can also use this handy chrome extension to get it. 你也可以使用这个方便的镀铬扩展来获得它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM