-
Notifications
You must be signed in to change notification settings - Fork 4.1k
Description
Description of the new feature
Public IP Prefixes are GA, however, do not appear to be supported when attempting to utilise via Add-AzLoadBalancerFrontendIpConfig and New-AzLoadBalancerFrontendIpConfig when setting up (or modifying) a Load Balancer.
This is contrary to the capabilities provided via the Azure Portal, which allows FEC to be setup against the PIPP object - which can then be utilised by Outbound rules without an issue, when manually setup.
Ideally, the aforementioned cmdlets should be updated to allow both Microsoft.Azure.Commands.Network.Models.PSPublicIpPrefix and Microsoft.Azure.Commands.Network.Models.PSPublicIpAddress to be utilised for the -PublicIPAddress flag to bring in-line with the deployments available via the portal (and ARM).
Current Workaround
The current workaround that I've had to resort to is completely cutting out the use of the aforementioned cmdlets, and fudging together the below within my workflow:
$azContext = Get-AzContext
$azProfile = [Microsoft.Azure.Commands.Common.Authentication.Abstractions.AzureRmProfileProvider]::Instance.Profile
$profileClient = New-Object -TypeName Microsoft.Azure.Commands.ResourceManager.Common.RMProfileClient -ArgumentList ($azProfile)
$tokenHeader = @{
'Content-Type' = 'application/json';
'Authorization' = 'Bearer ' + ($profileClient.AcquireAccessToken($azContext.Subscription.TenantId)).AccessToken;
}
$lbConfigEP = 'https://management.azure.com/subscriptions/EXAMPLE/resourceGroups/EXAMPLE/providers/Microsoft.Network/loadBalancers/exampleLb?api-version=2020-05-01'
$currentConfig = Invoke-RestMethod -Method GET -Uri $lbConfigEP -Headers $tokenHeader
$currentConfig.properties.frontendIPConfigurations += @{
"name" = "portalExample2";
"properties" = @{
"privateIPAllocationMethod" = "Dynamic";
"publicIPPrefix" = @{
"id" = "/subscriptions/EXAMPLE/resourceGroups/PPIP_Container/providers/Microsoft.Network/publicIPPrefixes/exampleTest"
}
}
}
$updatedConfig = Invoke-RestMethod -Method PUT -Uri $lbConfigEP -Headers $tokenHeader -Body ($currentConfig | ConvertTo-JSON -Depth 100)