gpt4 book ai didi

c# - 是否可以使用存储 key 清除 azure cdn 端点?

转载 作者:行者123 更新时间:2023-12-05 07:22:44 35 4
gpt4 key购买 nike

我想创建一个函数来清除 Azure CDN 上的文件。 Here在文档中它说如何清除指定路径的内容。

POST https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/endpoints/{endpointName}/purge?api-version=2017-10-12

但安全性是由 Azure Active Directory OAuth2 Flow 提供的。因此,我需要使用 clientIdsecretId(来自此处 https://blogs.msdn.microsoft.com/maheshk/2017/04/01/azure-cdn-how-to-purge-cdn-content-from-c-code/)

var authenticationContext = new AuthenticationContext("https://login.microsoftonline.com/microsoft.onmicrosoft.com");
ClientCredential clientCredential = new ClientCredential(clientId, clientSecret);
Task<AuthenticationResult> resultstr = authenticationContext.AcquireTokenAsync("https://management.core.windows.net/", clientCredential);

WebClient client = new WebClient();
//authentication using the Azure AD application
var token = resultstr.Result.AccessToken;

我在想有没有办法使用存储 key 而不是 clientIdsecretId 来发出清除请求?

最佳答案

不,这是不可能的。 Azure Rest API Endpoints - Purge Content与 Azure AD 身份验证集成,它需要您的有效凭据才能获取访问 token 。

请参阅此链接:Getting Started with REST - Register your client application with Azure AD .

Most Azure services (such as Azure Resource Manager providers and the classic deployment model) require your client code to authenticate with valid credentials before you can call the service's API. Authentication is coordinated between the various actors by Azure AD, and provides your client with an access token as proof of the authentication. The token is then sent to the Azure service in the HTTP Authorization header of subsequent REST API requests. The token's claims also provide information to the service, allowing it to validate the client and perform any required authorization.

关于c# - 是否可以使用存储 key 清除 azure cdn 端点?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56430292/

35 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com