Azure CDN 清除命令问题

时间:2021-02-19 04:08:21

标签: azure cdn azure-cli

我在资源组 'rgDev' 中创建了一个名为 'cdn-profile' 的 CDN。在 CDN 中,创建的端点是“webqa.azureedge.net”。在里面我创建了一个自定义域“qa.example.com”。我想清除 CDN 缓存。下面是我运行的命令。

$ResourceGroupName='rgDev'
$EndpointName='qa.example.com'
$ProfileName='cdn-profile'
$CDNEndPointName='webqa.azureedge.net'

 az cdn endpoint purge -g $ResourceGroupName -n $EndpointName --profile-name $ProfileName --content-paths '/*' --name $CDNEndPointName

这给了我以下错误: 未找到端点。请验证资源、组或其父资源是否存在。

我在这里遗漏了什么?

1 个答案:

答案 0 :(得分:1)

在 Azure CLI 命令 az cdn endpoint purge 中,CDN 端点的名称是 private static String authority = "https://login.microsoftonline.com/<tenantid>/"; private static String clientId="sp clientId"; private static String secret="sp client secret"; private static String scope="https://management.azure.com/.default"; try { // use msal4j to get token ConfidentialClientApplication app = ConfidentialClientApplication.builder( clientId, ClientCredentialFactory.createFromSecret(secret)) .authority(authority) .build(); ClientCredentialParameters clientCredentialParam = ClientCredentialParameters.builder( Collections.singleton(scope)) .build(); CompletableFuture<IAuthenticationResult> future = app.acquireToken(clientCredentialParam); HttpHeaders headers = new HttpHeaders(); headers.set("Authorization", "Bearer " + future.get().accessToken()); HttpEntity<String> entity = new HttpEntity<String>("",headers); String url ="https://management.azure.com/subscriptions/e5b0fcfa-e859-43f3-8d84-5e5fe29f4c68/resourceGroups/0730BowmanWindow/providers/Microsoft.Web/sites/bowman0210webapp/triggeredwebjobs/test/run?api-version=2019-08-01"; String res= restTemplate.postForObject(url,entity,String.class); return res; } catch (MalformedURLException e) { throw e; } catch (InterruptedException e) { throw e; } catch (ExecutionException e) { throw e; }finally { return "cannot start"; } (它是资源组中类型为 Endpoint 的资源的名称。)而不是主机名 {{ 1}} 或 webqa

你应该像这样使用它:

webqa.azureedge.net