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

Running Teams PowerShell Cmdlets in Azure Automation

This article describes the prerequisites and how to run cmdlets from the Teams PowerShell module in Azure Automation runbooks. We also conside...

1 day ago

Azure Storage APIs gain Entra ID and RBAC support

To align with security best practices, Microsoft Entra ID and RBAC support is now generally available for several Azure Storage data plane API...

3 days ago

Introducing the Azure Cosmos DB Account Overview Hub

A Simpler Way to Navigate, Learn, and Optimize your Azure Cosmos DB Account within the Azure Portal. Whether you are just getting started with...

3 days ago

Video: Master Copilot Studio Prompts with Azure AI Foundry Models

What if you could use any Azure AI Foundry model in your Copilot Studio custom ... The post Video: Master Copilot Studio Prompts with Azure AI...

6 days ago

Creating an Agent with Actions in Azure AI Foundry

Azure AI Foundry is an Azure service where you can create agents using various LLMs (including your own). In this post we will look at how to ...

7 days ago

New Test Run Hub in Azure Test Plans

Delivering high-quality software is a necessity and that’s why Azure Test Plans has introduced the all-new Test Run Hub, an enabler for teams ...

9 days ago

Microsoft Teams: New SlimCore-based optimization for Microsoft Teams in VDI – support for MacOS on Citrix and Azure Virtual Desktops/Windows 365

This feature allows MAC endpoints to optimize Microsoft Teams in VDI environments with the new SlimCore-based media engine, providing an expan...

9 days ago

Microsoft Whiteboard: Azure to OneDrive migration progress update

Microsoft Whiteboard storage is migrating from Azure to OneDrive, starting February 2024 and completing by August 2025, with full deprecation ...

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