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

标签 c# azure-active-directory azure-cdn

我想创建一个函数来清除 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/

相关文章:

c# - 开发一个基本的 DNS 服务器(在 C# 中)

c# - 了解 WPF 派生 WIndow 类

azure-active-directory - 尝试登录时,具有 AzureB2c 的 Blazor 服务器始终重定向到 AzureADB2C/Account/Error

azure - 对于一次性下载的 Blob,CDN 是否会比普通 Blob 存储改善延迟?

c# - 如何用ASP Core运行爬虫、服务交互和生命周期问题

c# - 依次读取大量小文件

authentication - 通过 Azure OpenID Connect 进行联合身份验证

node.js - open id connect认证后如何将用户注册到mongodb?

azure - 还有其他方法可以改善 Azure CDN 延迟吗?

Azure 云服务 CDN 字体 CORS 错误