gpt4 book ai didi

使用 swagger 将 Azure Ad 集成到 Azure Functions 中

转载 作者:行者123 更新时间:2023-12-03 03:49:05 25 4
gpt4 key购买 nike

我正在使用带有 swagger UI 的 Azure Functions V3。我在启动中使用以下代码

builder.AddSwashBuckle(Assembly.GetExecutingAssembly(),opts => {
opts.SpecVersion = Microsoft.OpenApi.OpenApiSpecVersion.OpenApi3_0;
opts.Title = "Platform Data Operations";



});

我已在 Azure 门户中为我的应用程序配置了 Azure Ad 身份验证。设置权限并重定向 URI。调用重定向 URI 后,我能够从浏览器成功登录。有人可以帮助我如何集成到代码中吗?

最佳答案

您可以按照下面的示例代码进行操作,

 builder.AddSwashBuckle(Assembly.GetExecutingAssembly(), opts =>
{
opts.SpecVersion = OpenApiSpecVersion.OpenApi3_0;
opts.ConfigureSwaggerGen = (x =>
{
x.DocumentFilter<CustomSwaggerDocumentAttribute>();
x.EnableAnnotations();
x.CustomOperationIds(apiDesc =>
{
return apiDesc.TryGetMethodInfo(out MethodInfo methodInfo)
? methodInfo.Name
: new Guid().ToString();
});
});
// remove code as query parameter
opts.AddCodeParameter = false;
opts.PrependOperationWithRoutePrefix = true;
opts.Title = "Sample Function API Swagger";
});

关于使用 swagger 将 Azure Ad 集成到 Azure Functions 中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/67604306/

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