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

Introducing the Unified Azure Maps Experience

We are thrilled to announce the unification of Bing Maps for Enterprise (BME) with Azure Maps, marking a significant milestone ...

1 hour ago

Enhancing Azure Files resilience and performance

Azure Files provides the best-in-class fully managed file share solution in the cloud. We are excited to showcase several new capabilities, so...

13 hours ago

Secure Access to Your Azure Virtual Machines for Free with Bastion Developer

As Microsoft Azure continues to evolve to accommodate its expanding user community, we are pleased to release a groundbreaking offering in res...

18 hours ago

Faster server onboarding and disaster recovery with Azure File Sync (Public Preview)

We are excited to announce the public preview of faster server onboarding and disaster recovery. This will significantly accelerate customer o...

19 hours ago

Coding at the Speed of Innovation: AI and more with Azure SQL Database

The Azure SQL Database team is all set to unveil new product announcements as Build 2024 approaches. Innovation is the prominent theme this ti...

4 days ago

Generate insights from audio and video data using Speech analytics in Azure AI Studio

In this video, we explore the power of speech analytics in Azure AI Studio to extract insights from audio and video data. This technology help...

4 days ago

Azure Custom Policy- PostgreSQL Product - Compliance Report not Available- New Feature Request

If you're attempting to create custom policies for Azure Cosmos DB for PostgreSQL at the subscription level and are running into issues where ...

4 days ago

Microsoft Causes Fuss Around Azure MFA Announcement

Microsoft's recent announcement regarding the requirement of Azure MFA for connections to services starting in July 2024 has caused quite a st...

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