How to Change a CDN Endpoint Origin Type

1.1k views Asked by At

I have already created and been using a CDN endpoint with origin type of 'Custom origin' that was pointed to an Application Gateway. Now I want to change the origin type to 'Web app' and point to a Function App. I am able to change the hostName property to the Function App URL but I cannot find a way to change the origin type and the value continues to be 'Custom origin'. I do not see a property in the ARM template nor any properties in the PowerShell commandlets. Is there a way to change it or do I need to delete and recreate?

enter image description here

1

There are 1 answers

1
Joy Wang On BEST ANSWER

No need to change the Origin type manually, when you change the Origin hostname to the url of the function app, the Origin type will be changed to Web App automatically.

Try the powershell command below, it works on my side.

In my sample, the www-test-com is the Origin Name, it can not be changed once created, so you can just use the old one. If you want to change it, you need to create a new endpoint.

enter image description here

$endpoint = Get-AzResource -ResourceId "/subscriptions/<subscription-id>/resourceGroups/<group-name>/providers/Microsoft.Cdn/profiles/<cdn-name>/endpoints/<endpoint-name>"
$endpoint.Properties.originHostHeader = "joyfun.azurewebsites.net"
$endpoint | Set-AzResource -Force

$origin = Get-AzResource -ResourceId "/subscriptions/<subscription-id>/resourcegroups/<group-name>/providers/Microsoft.Cdn/profiles/<cdn-name>/endpoints/<endpoint-name>/origins/www-test-com"
$origin.Properties.hostName = "joyfun.azurewebsites.net"
$origin | Set-AzResource -Force

After running the commands, the result will be like below.

enter image description here