Loading...

PowerShell Script to disable Public Network Access for Azure Relay

PowerShell Script to disable Public Network Access for Azure Relay

Scenario: PowerShell script to disable Public Network access for Azure Relay

 

In today’s azure world, it is always better to do automations rather than do a Manual work. It becomes a headache for all of us to navigate to Azure Portal

 

Here is the simple way to disable Public Network access by using PowerShell script.

 

Solution:

 

Connect-AzAccount Set-AzContext -SubscriptionId "<Sub ID>" $accessToken = $(Get-AzAccessToken).Token $body = '{"location": "xxxxxx","properties": {"publicNetworkAccess": "Disabled","defaultAction": "Deny","virtualNetworkRules": [],"ipRules": []}}' | ConvertTo-Json $obj = ConvertFrom-Json -InputObject $body $uri = 'https://management.azure.com/subscriptions/<Sub ID>/resourceGroups/<RG>/providers/Microsoft.Relay/namespaces/<NS>/networkrulesets/default?api-version=2021-11-01' Invoke-RestMethod -Method PUT -Uri $uri -Headers @{ "Authorization" = "Bearer $accessToken" } -Body $obj -ContentType "application/json"

 

 

Please find below steps on how to run the PowerShell script to disable Public Network access for Azure Relay. 

 

Step 1: Login to Azure portal

 

Step 2: Open Azure PowerShell terminal and connect to your Azure account using any of options mentioned in Authentication Methods

 

Step 3: Just add the Resource Group name and Subscription Id and Relay namespace.

 

Step 4: Run the above commands to enable Public Network access for Azure Relay

 

Reference Links: -

Network security for Azure Relay - Azure Relay | Microsoft Learn

 

Happy Learning :smile:

 

Published on:

Learn more
Azure PaaS Blog articles
Azure PaaS Blog articles

Azure PaaS Blog articles

Share post:

Related posts

Azure Backup for Azure Cosmos DB Public Preview Adds Immutable Backups and Long-Term Retention

Azure Backup for Azure Cosmos DB Public Preview Adds Immutable Backups and Long-Term Retention Picture the first few hours after a serious dat...

3 days ago

Announcing General Availability of the Azure Cosmos DB Built-in Connector for Logic Apps Standard

Today, we’re excited to announce the general availability of the Azure Cosmos DB built-in connector for Azure Logic Apps Standard. This ...

4 days ago

Microsoft Purview: Data Lifecycle Management – Azure PST Import

Azure PST Import is a migration method that enables PST files stored in Azure Blob Storage to be imported directly into Exchange Online mailbo...

5 days ago

June Patches for Azure DevOps Server

We are releasing new patches for our self‑hosted product, Azure DevOps Server. We strongly recommend that all customers stay up to date with t...

9 days ago

Copilot Autofix for GitHub Advanced Security for Azure DevOps

Over the last few years, we’ve encouraged customers to move their repositories from Azure Repos to GitHub, where the newest AI-powered a...

9 days ago
Stay up to date with latest Microsoft Dynamics 365 and Power Platform news!
* Yes, I agree to the privacy policy