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 Storage - TLS 1.0 and 1.1 retirement

Overview TLS 1.0 and 1.1 retirement on Azure Storage was previously announced for Nov 1st, 2024, and it was postponed recently to 1 year later...

1 year ago

Efficient Management of Append and Page Blobs Using Azure Storage Actions

  Overview In Azure Storage, Blob Lifecycle Management (BLM) allows you to automate the management of your data based on rules defined by...

1 year ago

[Azure AI Search] Internal Server Error when creating CMK encrypted objects

Scenario Customers follow the Microsoft doc to create CMK encrypted objects (data source, index etc.), but get the 500 Internal Serv...

1 year ago

Optimizing Azure Table Storage: Automated Data Cleanup using a PowerShell script with Azure Automate

Scenario This blog’s aim is to manage Table Storage data efficiently. Imagine you have a large Azure Table Storage that accumulates logs from ...

1 year ago

Optimizing Azure Table Storage: Automated Data Clean-up using a PowerShell script with Azure Automat

Scenario This blog’s aim is to manage Table Storage data efficiently. Imagine you have a large Azure Table Storage that accumulates logs from ...

1 year ago

Restoring Soft-Deleted Blobs with multithreading in Azure Storage Using C#

Blob soft delete is an essential feature that safeguards your data against accidental deletions or overwrites. By retaining deleted data for a...

1 year ago

Performing simple Azure Table Storage REST API operations using curl command.

The blog provides guidance to perform simple Table Storage REST API operations such as Create table, Delete Table, Insert entity, Delete entit...

1 year ago

Bulk delete all the old jobs from the batch account

Deleting a Job also deletes all Tasks that are part of that Job, and all Job statistics. This also overrides the retention period for Task dat...

1 year ago

Utilizing Azure Storage and Runbooks for scheduled automated backups of Azure SQL Databases

In this article, we are going to provide detailed steps to create a scheduled Azure SQL Database backup to storage account using automation. T...

1 year ago

[Azure Service Bus] JMS messages getting dead-lettered

The article discusses a problem where numerous messages end up in the dead letter queue (DLQ) when the JMS service bus consumer connects to th...

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