Update CDN Endpoint originHostHeader

1
2
3
4
5
6
7
8
9
10
11
12
13
$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)
$token = $profileClient.AcquireAccessToken($azContext.Subscription.TenantId)
$authHeader = @{
'Content-Type'='application/json'
'Authorization'='Bearer ' + $token.AccessToken
}

$body=ConvertTo-Json -Depth 2 @{"properties"=@{originHostHeader= $null}}
$restUri = 'https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/endpoints/{endpointName}?api-version=2020-04-15'

$response = Invoke-RestMethod -Uri $restUri -Method PATCH -Headers $authHeader -Body $body -ContentType 'application/json'

Reference: https://docs.microsoft.com/en-us/rest/api/cdn/cdn/endpoints/update

HTH. 2021-6-8 By Jacky Chiou