Mostafiz Rahman
Mostafiz Rahman

Reputation: 8522

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. But I need to store the Inbound Security Rules of the Network Security Group that I'm gonna Delete.

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?

Upvotes: 0

Views: 3347

Answers (1)

mbrg
mbrg

Reputation: 558

If you don't want to use shell, you can use a simple API call to:

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.

You need to include the an Authorization header, which you can get by:

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).

Here is an example:

How to get Azure Authorization header

You can also use this handy chrome extension to get it.

Upvotes: 0

Related Questions