Hello Grzegorz Koperczak
The “AnotherPEOperationInProgress” is coming from the vault RP
UserErrorAnotherPEOperationInProgress“Call to Microsoft.RecoveryServices/vaults failed. Error message: Another private endpoint operation is in progress on this vault.”
is returned by the Microsoft.RecoveryServices provider (the vault itself), not by the Microsoft.Network private endpoint. That’s why both:
-
Set-AzPrivateEndpoint -
Remove-AzPrivateEndpoint
fail with the same message – the networking RP calls into RecoveryServices to update/remove the connection, and the RecoveryServices RP says “no, I already have a PE operation in flight,” and the whole long-running operation is marked Failed.
Here is the PowerShell script checks the state of the PrivateEndpoint before deletion; if the PrivateEndpoint is connected, it will not be deleted $privateEndpoint = Get-AzPrivateEndpoint -Name "venkat-endpoint" -ResourceGroupName "RG_Name"
if ($privateEndpoint -eq $null) { Write-Host "Private endpoint not found." } else { $endpointstate = $privateEndpoint.PrivateLinkServiceConnectionsText | ConvertFrom-Json | Select-Object -ExpandProperty PrivateLinkServiceConnectionState | Select-Object -ExpandProperty Status if ($endpointstate -eq 'Disconnected') { Write-Host "Private endpoint name : venkat-endpoint is in : $endpointstate state" Remove-AzPrivateEndpoint -Name "venkat-endpoint" -ResourceGroupName "v-vallepuv-Mindtree" -Force Write-Host "Private endpoint deleted successfully." } else { Write-Host "Private endpoint is not in a disconnected state. Current state: Connected" }}