Unable to delete delegation to my Subnet, my Subnet is empty not using any IP's

Hanuma Suresh 0 Reputation points
2024-07-17T15:29:38.6933333+00:00

Hi,

I was wondering if any one can help me with solution for deleting of delegation for my subnet.

I am using below script but looks like it was not working.

$net = @{

Name = 'Vnet'

ResourceGroupName = 'RG'
```}

$vnet = Get-AzVirtualNetwork @net

$sub = @{

```sql
Name = 'subnet'

VirtualNetwork = $vnet
```}

$subnet = Get-AzVirtualNetworkSubnetConfig @sub

$del = @{

```powershell
Name = 'Microsoft.Web/serverfarms'

Subnet = $subnet
```}

$subnet = Remove-AzDelegation @del

Set-AzVirtualNetwork -VirtualNetwork $vnet
Azure
Azure
A cloud computing platform and infrastructure for building, deploying and managing applications and services through a worldwide network of Microsoft-managed datacenters.
1,035 questions
Azure Virtual Network
Azure Virtual Network
An Azure networking service that is used to provision private networks and optionally to connect to on-premises datacenters.
2,473 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Luis Arias 6,801 Reputation points
    2024-07-17T19:41:10.3166667+00:00

    Hi Hanuma Suresh,

    You can use below powershell to remove the delegation on a subnet , it's only required update with your values:

    Connect-AzAccount
    $vnet = Get-AzVirtualNetwork -ResourceGroupName "<your RG name>" -Name "<Vnet Name>"
    $subnet = Get-AzVirtualNetworkSubnetConfig -Name "<Subnet Name>" -VirtualNetwork $vnet
    $subnet = Remove-AzDelegation -Name "<your delegation  example: Microsoft.DBforMySQL/flexibleServers>" -Subnet $subnet
    Set-AzVirtualNetwork -VirtualNetwork $vnet
    

    If the information helped address your question, please Accept the answer.

    Luis


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.