问题描述
Azure团队您好,
Hello Azure Team,
创建了一个外部应用程序,该应用程序使用令牌身份验证来调用Azure应用程序(请参见下面的代码段).还应该提及的是,我们以前具有应用程序功能,但我们的MSDN订阅已转移到新帐户.我们 进入Azure门户并重新配置现有终结点,并为新帐户创建了一个新应用程序.
Created an external application that calls an Azure application using token authentication (see code snippet below). Also should mention that we previously had the application functional BUT our MSDN subscription was transferred to a new account. We went into the Azure portal and reconfigured existing endpoints and created a new application for the new account.
在调用 cdn.Endpoints.PurgeContent操作时,我们收到以下错误:
When calling the cdn.Endpoints.PurgeContent operation, we're receiving the following error:
" Microsoft.Azure.Management.Cdn.Models.ErrorResponseException:操作返回了无效的状态码禁止".在Microsoft.Azure.Management.Cdn.EndpointsOperations处< BeginPurgeContentWithHttpMessagesAsync> d__21.MoveNext()\ r \ n-- 从先前引发异常的位置开始的堆栈结束跟踪--- \ r \ n 在System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(任务任务)处\ r \ n 在System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task 任务)\ r \ n < PurgeContentWithHttpMessagesAsync> d__12.MoveNext()\ r \ n--从先前引发异常的位置开始的堆栈跟踪结束.在System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task 任务)\ r \ n 在System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(任务任务)处在Microsoft.Azure.Management.Cdn.EndpointsOperationsExtensions中.< PurgeContentAsync> d__15.MoveNext()\ r \ n--结束 从先前引发异常的位置开始的堆栈跟踪--- \ r \ n 在System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(任务任务)处\ r \ n 在System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task 任务)\ r \ n 在Microsoft.Azure.Management.Cdn.EndpointsOperationsExtensions.PurgeContent(IEndpointsOperations操作,字符串resourceGroupName,字符串profileName,字符串EndpointName,IList`1 contentPaths)处.在_4Rent.App_Data.AzureCDN.PurgeCdnEndpoint(CdnManagementClient cdn,在D:\\ ... \\ AzureCDN.cs:line 119中列出1个contPaths)"
""Microsoft.Azure.Management.Cdn.Models.ErrorResponseException: Operation returned an invalid status code 'Forbidden'\r\n at Microsoft.Azure.Management.Cdn.EndpointsOperations.<BeginPurgeContentWithHttpMessagesAsync>d__21.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at Microsoft.Azure.Management.Cdn.EndpointsOperations.<PurgeContentWithHttpMessagesAsync>d__12.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at Microsoft.Azure.Management.Cdn.EndpointsOperationsExtensions.<PurgeContentAsync>d__15.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at Microsoft.Azure.Management.Cdn.EndpointsOperationsExtensions.PurgeContent(IEndpointsOperations operations, String resourceGroupName, String profileName, String endpointName, IList`1 contentPaths)\r\n at _4Rent.App_Data.AzureCDN.PurgeCdnEndpoint(CdnManagementClient cdn, List`1 contPaths) in D:\\...\\AzureCDN.cs:line 119"
我们已经遍历了Azure门户,以确保配置正确无误.使用以下文章作为参考:
We've gone through the Azure portal to try to make sure the configuration is correct but am at a loss. Used following articles as reference:
https://docs.microsoft.com/en-ca/azure /cdn/cdn-app-dev-net
https://code.msdn.microsoft.com/Azure-CDN-Management-1f2fba2c
https://www.nuget.org/packages/Microsoft.Azure.Management.Cdn/
https://www.nuget.org/packages/Microsoft.IdentityModel.Clients.ActiveDirectory/
https://docs.microsoft.com/en-us/rest /api/searchservice/http-status-codes
甚至,我们的api密钥似乎是正确的.我们需要尝试找出解决方法,以找出问题所在.任何帮助都会 不胜感激.
Even from the status code article, our api key seems to be correct. We need to try to find out how to troubleshoot to figure out what the issue is. Any help would be appreciated.
谢谢
戴夫
示例代码:
private const string clientID = "****"; //"<YOUR CLIENT/APPLICATION ID>";
private const string clientSecret = "****"; //"<YOUR CLIENT AUTHENTICATION KEY>"; //Only for service principals
private const string authority = "https://login.microsoftonline.com/****/domain.onmicrosoft.com"; //"https://login.microsoftonline.com/<YOUR TENANT/DIRECTORY ID>/<YOUR TENANT DOMAIN NAME>";
//Application constants
private const string subscriptionId = "***"; //"<YOUR SUBSCRIPTION ID>";
private const string profileName = "profileName";
private const string endpointName = "EndPointName"; //" < A UNIQUE NAME FOR YOUR CDN ENDPOINT>";
private const string resourceGroupName = "ResourceGroupName"; //"CdnConsoleTutorial"; //
private const string resourceLocation = "Canada Central"; //"Central US";
public static string PurgeEndpointContent(List<string> contentFiles)
{
//Get a token
AuthenticationResult authResult = GetAccessToken();
// Create CDN client
CdnManagementClient cdn = new CdnManagementClient(new TokenCredentials(authResult.AccessToken))
{ SubscriptionId = subscriptionId };
PurgeCdnEndpoint(cdn, contentFiles);
return _results;
}
private static void PurgeCdnEndpoint(CdnManagementClient cdn, List<string> contPaths)
{
try
{
if (contPaths.Count > 0)
{
cdn.Endpoints.PurgeContent(endpointName, profileName, resourceGroupName, contPaths);
}
}
catch (Exception ex)
{
_error = ex.ToString();
}
}
戴夫
推荐答案
禁止"访问代码似乎是Authenticaiton问题.
The "Forbidden" access code seems to be an Authenticaiton issue.
这篇关于端点清除内容-操作返回了无效的状态码“禁止"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!