首页 > 解决方案 > 如何更改 CDN 端点源类型

问题描述

我已经创建并一直在使用指向应用程序网关的源类型为“自定义源”的 CDN 端点。现在我想将源类型更改为“Web 应用程序”并指向一个函数应用程序。我可以将hostName属性更改为函数应用程序 URL,但我找不到更改源类型的方法,并且值仍然是“自定义源”。我看不到 ARM 模板中的属性,也看不到 PowerShell 命令行开关中的任何属性。有没有办法改变它还是我需要删除并重新创建?

在此处输入图像描述

标签: azure-resource-managerazure-powershellarm-templateazure-cdn

解决方案


无需Origin type手动更改,当您更改Origin hostname为函数应用的url时,Origin type将更改为Web App自动。

试试下面的 powershell 命令,它对我有用。

在我的示例中,www-test-comOrigin Name,一旦创建就无法更改,因此您可以使用旧的。如果要更改它,则需要创建一个新端点。

在此处输入图像描述

$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

运行命令后,结果将如下所示。

在此处输入图像描述


推荐阅读