gpt4 book ai didi

azure - 使用 Api 管理服务发布 Azure 函数应用程序 - 无法更新 Azure 中的 API(状态代码 : BadRequest))

转载 作者:行者123 更新时间:2023-12-05 04:35:30 24 4
gpt4 key购买 nike

我有一个使用本地运行的 API 管理服务的 Azure 函数应用程序。我使用 Visual Studio 2022 创建了它。但是当我尝试发布它时,一切看起来都很好,直到出现此错误。

========== Build: 1 succeeded, 0 failed, 0 up-to-date, 0 skipped ==========
========== Publish: 1 succeeded, 0 failed, 0 skipped ==========
Waiting for function app to be ready...
Finished waiting for function app to be ready
Starting to update your API
Failed to update your API in Azure (Status code: BadRequest).

应用程序是在资源组下创建的,而不是在 api 管理服务下创建的。并生成分析文件。

Microsoft.WebTools.Shared.Exceptions.WebToolsException: Failed to update your API in Azure (Status code: BadRequest).

at Microsoft.WebTools.Azure.Publish.ApiMApi.BaseApiMApiUpdater.EmitTerminatingError(String bucketName, String displayedErrorMessage, String loggedErrorMessage)
at Microsoft.WebTools.Azure.Publish.ApiMApi.BaseApiMApiUpdater.<UpdateApiMApiInAzureAsync>d__10.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.WebTools.Azure.Publish.ApiMApi.FunctionAppApiMApiPublishHandler.FunctionApiMApiUpdater.<ImportSwaggerLinkToApiMAppAsync>d__8.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.WebTools.Azure.Publish.ApiMApi.FunctionAppApiMApiPublishHandler.FunctionApiMApiUpdater.<RunUpdateAsync>d__6.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.WebTools.Azure.Publish.ApiMApi.BaseApiMApiUpdater.<RunUpdateWithTelemetryAsync>d__9.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.WebTools.Azure.Publish.ApiMApi.FunctionAppApiMApiPublishHandler.<UpdateApiMApiAsync>d__7.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.WebTools.Azure.Functions.PublishProviders.AzureFunctionProfileVisual.<FunctionsAfterPostPublishAsync>d__42.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.Publish.Framework.Nexus.PublishProfilesServiceImpl.ServerProjectProfilesManager.
<RunPublishTaskAsync>d__56.MoveNext()

===================

我还尝试删除所有内容并重试,这次是在发布时创建 api 管理服务。应用程序已像以前一样创建,但 api 管理服务未创建。

最佳答案

如果您使用的是 Azure Function OpenAPI 模板,则需要确保每个 Function 在 OpenApiOperation 属性中具有唯一的 operationId。

默认情况下,新函数的操作 ID 设置为“运行”,将其更改为唯一值修复了发布时的错误请求

[OpenApiOperation(operationId: "UniqueOperationId", tags: new[] { "name" })]

您可以通过查看 Azure 门户中的日志来验证导致错误请求的原因

导航到资源组 --> 事件日志。从这里您应该能够看到创建 API 或更新 API 的失败尝试。

Resource Group Activity Log

选择失败的尝试并查看打开的面板中的 JSON 选项卡,底部附近应该是错误请求的原因

例如:

BadRequest OpenApi operationId

关于azure - 使用 Api 管理服务发布 Azure 函数应用程序 - 无法更新 Azure 中的 API(状态代码 : BadRequest)),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/71021740/

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