5

General Availability of Azure Functions OpenAPI Extension

 2 years ago
source link: https://techcommunity.microsoft.com/t5/apps-on-azure/general-availability-of-azure-functions-openapi-extension/ba-p/2931231?WT_mc_id=DOP-MVP-4025064
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client
General Availability of Azure Functions OpenAPI Extension

General Availability of Azure Functions OpenAPI Extension

Published Nov 08 2021 08:10 AM 1,744 Views

Exactly a year ago, the first public preview version of Azure Functions OpenAPI Extension was released, which had been a long-waited feature from the dev communities for a long time. Today, we cannot be more excited to announce the general availability of Azure Functions OpenAPI Extension. It was originally a community-driven project, and then it's now become the "official" extension. This extension supports .NET Core 2.1 (LTS), 3.1 (LTS), .NET 5 and .NET 6 (LTS). It also supports both in-process worker and out-of-process worker of Azure Functions runtime. Throughout this post, let's take a look at how to create a function app with the OpenAPI extension in .NET 6, in Visual Studio 2022.



NOTE: The updated Visual Studio project template for this extension supporting both in-process and out-of-process workers is on the way. Please stay tuned.



In-Process Worker



In Visual Studio 2022, you can create a function app in .NET with the in-process worker.









You will see the code like below, with several decorators starting with OpenApi (line #7-10).





public class Function1
{
    ...

    [FunctionName("Function1")]

    [OpenApiOperation(operationId: "Run", tags: new[] { "name" })]
    [OpenApiSecurity("function_key", SecuritySchemeType.ApiKey, Name = "code", In = OpenApiSecurityLocationType.Query)]
    [OpenApiParameter(name: "name", In = ParameterLocation.Query, Required = true, Type = typeof(string), Description = "The **Name** parameter")]
    [OpenApiResponseWithBody(statusCode: HttpStatusCode.OK, contentType: "text/plain", bodyType: typeof(string), Description = "The OK response")]

    public async Task<IActionResult> Run(
        [HttpTrigger(AuthorizationLevel.Function, "get", "post", Route = null)] HttpRequest req)
    {
        ...
    }
}




Since the updated Visual Studio project template for this extension is on the way, the OpenApi extension needs to be updated for now. Right mouse click on the "Dependencies" menu in Solution Explorer, then click the "Manage NuGet Packages..." menu.







Update the existing Microsoft.Azure.WebJobs.Extensions.OpenApi package version to 1.0.0.







Once updated, rebuild the project and run the function app by clicking the "Debug" button at the top.







Open a web browser and go to http://localhost:7071/api/swagger/ui, and you will see the Swagger UI page as expected.







Out-of-Process Worker



In Visual Studio 2022, you can also create a function app in .NET with the out-of-process worker. Since the updated Visual Studio project template for this extension is on the way, you need to the existing HTTP trigger and add the NuGet package for now.









You need to add the NuGet package, Microsoft.Azure.Functions.Worker.Extensions.OpenApi from the NuGet Package Manager.







Once installed, update Program.cs to activate the extension. Remove ConfigureFunctionsWorkerDefaults() (line #7) and add ConfigureFunctionsWorkerDefaults(worker => worker.UseNewtonsoftJson()) and ConfigureOpenApi() (line #10-11).





public class Program
{
    public static void Main()
    {
        var host = new HostBuilder()
            // Remove this line
            .ConfigureFunctionsWorkerDefaults()

            // Add these two lines
            .ConfigureFunctionsWorkerDefaults(worker => worker.UseNewtonsoftJson())
            .ConfigureOpenApi()

            .Build();

        host.Run();
    }
}




Then, add the OpenAPI related decorators to the function app endpoint (line #7-9).





public class Function1
{
    ...

    [Function("Function1")]

    [OpenApiOperation(operationId: "Run", tags: new[] { "greetings" })]
    [OpenApiSecurity("function_key", SecuritySchemeType.ApiKey, Name = "code", In = OpenApiSecurityLocationType.Query)]
    [OpenApiResponseWithBody(statusCode: HttpStatusCode.OK, contentType: "text/plain", bodyType: typeof(string), Description = "The OK response")]

    public HttpResponseData Run([HttpTrigger(AuthorizationLevel.Function, "get", "post")] HttpRequestData req)
    {
        ...
    }
}




Once updated two files like above, rebuild the project and run the function app by clicking the "Debug" button at the top.







Open a web browser and go to http://localhost:7071/api/swagger/ui, and you will see the Swagger UI page as expected.







Migration from .NET Core 3.1 to .NET 6



If you want to migrate your existing .NET Core 3.1 function app to .NET 6, all you need to do is to update the .csproj file and update the package version and target framework. Open your .csproj file (LegacyInProcApp.csproj in this example), and update TargetFramework node from netcoreapp3.1 to net6.0 and AzureFunctionsVersion from v3 to v4 (line #4-5, 8-9).





<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <!-- Change these values -->
    <TargetFramework>netcoreapp3.1</TargetFramework>
    <AzureFunctionsVersion>v3</AzureFunctionsVersion>

    <!-- To these values -->
    <TargetFramework>net6.0</TargetFramework>
    <AzureFunctionsVersion>v4</AzureFunctionsVersion>

    ...
  </PropertyGroup>
  ...
</Project>




Then, update all the Azure Functions related NuGet packages to the latest version, including the OpenAPI extension.







Rebuild the project, run the function app by clicking the "Debug" button at the top. Next, open a web browser and go to http://localhost:7071/api/swagger/ui, and you will see the Swagger UI page as expected.







Migration from .NET 5 to .NET 6



If you want to migrate your existing .NET 5 function app to .NET 6, all you need to do is to update the .csproj file and update the package version and target framework. Open your .csproj file (LegacyOutOfProcApp.csproj in this example), and update TargetFramework node from net5.0 to net6.0 and AzureFunctionsVersion from v3 to v4 (line #4-5, 8-9).





<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <!-- Change these values -->
    <TargetFramework>net5.0</TargetFramework>
    <AzureFunctionsVersion>v3</AzureFunctionsVersion>

    <!-- To these values -->
    <TargetFramework>net6.0</TargetFramework>
    <AzureFunctionsVersion>v4</AzureFunctionsVersion>

    ...
  </PropertyGroup>
  ...
</Project>




Then, update all the Azure Functions related to NuGet packages to the latest version, including the OpenAPI extension.







Rebuild the project, run the function app by clicking the "Debug" button at the top. Next, open a web browser and go to http://localhost:7071/api/swagger/ui, and you will see the Swagger UI page as expected.







Now, you are able to build a new function app in .NET 6, as well as migrate your existing function apps to .NET 6 with minimal effort.



Try It Today



If you want to know more about using this extension, visit this page. If you want to try even more about its advanced features, see this documentation page.



And don't miss out our session at .NET ConfBrand New! Azure Functions OpenAPI Extension on .NET 6 – live streaming on Nov 10, 9.30pm Pacific Time (Nov 11, 5.30am UTC) and on-demand available after the conference!



We're listening to your feedback while you are using this extension! So if you find something to suggest, improve or have any questions, please let us know.



You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.

%3CLINGO-SUB%20id%3D%22lingo-sub-2931231%22%20slang%3D%22en-US%22%3EGeneral%20Availability%20of%20Azure%20Functions%20OpenAPI%20Extension%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2931231%22%20slang%3D%22en-US%22%3E%3CP%3EExactly%20a%20year%20ago%2C%20the%20first%20public%20preview%20version%20of%20%3CA%20href%3D%22https%3A%2F%2Faka.ms%2Fazfunc-openapi%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3EAzure%20Functions%20OpenAPI%20Extension%3C%2FA%3E%20was%20released%2C%20which%20had%20been%20a%20long-waited%20feature%20from%20the%20dev%20communities%20for%20a%20long%20time.%20Today%2C%20we%20cannot%20be%20more%20excited%20to%20announce%20the%20general%20availability%20of%20%3CA%20href%3D%22https%3A%2F%2Faka.ms%2Fazfunc-openapi%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3EAzure%20Functions%20OpenAPI%20Extension%3C%2FA%3E.%20It%20was%20originally%20a%20community-driven%20project%2C%20and%20then%20it's%20now%20become%20the%20%22official%22%20extension.%20This%20extension%20supports%20.NET%20Core%202.1%20(LTS)%2C%203.1%20(LTS)%2C%20.NET%205%20and%20.NET%206%20(LTS).%20It%20also%20supports%20both%20in-process%20worker%20and%20out-of-process%20worker%20of%20Azure%20Functions%20runtime.%20Throughout%20this%20post%2C%20let's%20take%20a%20look%20at%20how%20to%20create%20a%20function%20app%20with%20the%20OpenAPI%20extension%20in%20.NET%206%2C%20in%20%3CA%20href%3D%22https%3A%2F%2Fvisualstudio.microsoft.com%2F%3FWT.mc_id%3Ddotnet-48656-juyoo%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3EVisual%20Studio%202022%3C%2FA%3E.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CBLOCKQUOTE%3E%0A%3CP%3E%3CSTRONG%3ENOTE%3C%2FSTRONG%3E%3A%20The%20updated%20Visual%20Studio%20project%20template%20for%20this%20extension%20supporting%20both%20in-process%20and%20out-of-process%20workers%20is%20on%20the%20way.%20Please%20stay%20tuned.%3C%2FP%3E%0A%3C%2FBLOCKQUOTE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH2%20id%3D%22in-process-worker%22%20id%3D%22toc-hId--297127125%22%20id%3D%22toc-hId--296884053%22%3EIn-Process%20Worker%3C%2FH2%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EIn%20Visual%20Studio%202022%2C%20you%20can%20create%20a%20function%20app%20in%20.NET%20with%20the%20in-process%20worker.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3COL%3E%0A%3CLI%3EChoose%20%22%3CSTRONG%3E.NET%206%3C%2FSTRONG%3E%22.%3C%2FLI%3E%0A%3CLI%3ESelect%20%22%3CSTRONG%3EHttp%20trigger%20with%20OpenAPI%3C%2FSTRONG%3E%22%20menu%20on%20the%20left-hand%20side.%3C%2FLI%3E%0A%3CLI%3ESelect%20%22%3CSTRONG%3EFunction%3C%2FSTRONG%3E%22%20for%20the%20Authorization%20level%20field.%3C%2FLI%3E%0A%3CLI%3EClick%20the%20%22%3CSTRONG%3ECreate%3C%2FSTRONG%3E%22%20button.%3C%2FLI%3E%0A%3C%2FOL%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CIMG%20src%3D%22https%3A%2F%2Fsa0blogs.blob.core.windows.net%2Fdevkimchi%2F2021%2F11%2Fgeneral-availability-of-azure-functions-openapi-extension-01.png%22%20border%3D%220%22%20alt%3D%22In-Proc%20Worker%3A%20New%20Azure%20Functions%20Application%20in%20.NET%206%22%20%2F%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EYou%20will%20see%20the%20code%20like%20below%2C%20with%20several%20decorators%20starting%20with%3CCODE%3EOpenApi%3C%2FCODE%3E(%3CEM%3Eline%20%237-10%3C%2FEM%3E).%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-csharp%22%3E%3CCODE%3Epublic%20class%20Function1%0A%7B%0A%20%20%20%20...%0A%0A%20%20%20%20%5BFunctionName(%22Function1%22)%5D%0A%0A%20%20%20%20%5BOpenApiOperation(operationId%3A%20%22Run%22%2C%20tags%3A%20new%5B%5D%20%7B%20%22name%22%20%7D)%5D%0A%20%20%20%20%5BOpenApiSecurity(%22function_key%22%2C%20SecuritySchemeType.ApiKey%2C%20Name%20%3D%20%22code%22%2C%20In%20%3D%20OpenApiSecurityLocationType.Query)%5D%0A%20%20%20%20%5BOpenApiParameter(name%3A%20%22name%22%2C%20In%20%3D%20ParameterLocation.Query%2C%20Required%20%3D%20true%2C%20Type%20%3D%20typeof(string)%2C%20Description%20%3D%20%22The%20**Name**%20parameter%22)%5D%0A%20%20%20%20%5BOpenApiResponseWithBody(statusCode%3A%20HttpStatusCode.OK%2C%20contentType%3A%20%22text%2Fplain%22%2C%20bodyType%3A%20typeof(string)%2C%20Description%20%3D%20%22The%20OK%20response%22)%5D%0A%0A%20%20%20%20public%20async%20Task%3CIACTIONRESULT%3E%20Run(%0A%20%20%20%20%20%20%20%20%5BHttpTrigger(AuthorizationLevel.Function%2C%20%22get%22%2C%20%22post%22%2C%20Route%20%3D%20null)%5D%20HttpRequest%20req)%0A%20%20%20%20%7B%0A%20%20%20%20%20%20%20%20...%0A%20%20%20%20%7D%0A%7D%0A%3C%2FIACTIONRESULT%3E%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3ESince%20the%20updated%20Visual%20Studio%20project%20template%20for%20this%20extension%20is%20on%20the%20way%2C%20the%20OpenApi%20extension%20needs%20to%20be%20updated%20for%20now.%20Right%20mouse%20click%20on%20the%20%22%3CSTRONG%3EDependencies%3C%2FSTRONG%3E%22%20menu%20in%20Solution%20Explorer%2C%20then%20click%20the%20%22%3CSTRONG%3EManage%20NuGet%20Packages...%3C%2FSTRONG%3E%22%20menu.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CIMG%20src%3D%22https%3A%2F%2Fsa0blogs.blob.core.windows.net%2Fdevkimchi%2F2021%2F11%2Fgeneral-availability-of-azure-functions-openapi-extension-02.png%22%20border%3D%220%22%20alt%3D%22In-Proc%20Worker%3A%20Manage%20NuGet%20Packages...%22%20%2F%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EUpdate%20the%20existing%20%3CA%20href%3D%22https%3A%2F%2Fwww.nuget.org%2Fpackages%2FMicrosoft.Azure.WebJobs.Extensions.OpenApi%22%20target%3D%22_blank%22%20rel%3D%22nofollow%20noopener%20noreferrer%22%3E%3CCODE%3EMicrosoft.Azure.WebJobs.Extensions.OpenApi%3C%2FCODE%3E%3C%2FA%3E%20package%20version%20to%3CCODE%3E1.0.0%3C%2FCODE%3E.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CIMG%20src%3D%22https%3A%2F%2Fsa0blogs.blob.core.windows.net%2Fdevkimchi%2F2021%2F11%2Fgeneral-availability-of-azure-functions-openapi-extension-03.png%22%20border%3D%220%22%20alt%3D%22In-Proc%20Worker%3A%20Update%20NuGet%20Package%22%20%2F%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EOnce%20updated%2C%20rebuild%20the%20project%20and%20run%20the%20function%20app%20by%20clicking%20the%20%22%3CSTRONG%3EDebug%3C%2FSTRONG%3E%22%20button%20at%20the%20top.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CIMG%20src%3D%22https%3A%2F%2Fsa0blogs.blob.core.windows.net%2Fdevkimchi%2F2021%2F11%2Fgeneral-availability-of-azure-functions-openapi-extension-04.png%22%20border%3D%220%22%20alt%3D%22In-Proc%20Worker%3A%20Run%20Function%20App%22%20%2F%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EOpen%20a%20web%20browser%20and%20go%20to%3CCODE%3E%3CA%20href%3D%22http%3A%2F%2Flocalhost%3A7071%2Fapi%2Fswagger%2Fui%22%20target%3D%22_blank%22%20rel%3D%22nofollow%20noopener%20noreferrer%22%3Ehttp%3A%2F%2Flocalhost%3A7071%2Fapi%2Fswagger%2Fui%3C%2FA%3E%3C%2FCODE%3E%2C%20and%20you%20will%20see%20the%20Swagger%20UI%20page%20as%20expected.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CIMG%20src%3D%22https%3A%2F%2Fsa0blogs.blob.core.windows.net%2Fdevkimchi%2F2021%2F11%2Fgeneral-availability-of-azure-functions-openapi-extension-05.png%22%20border%3D%220%22%20alt%3D%22In-Proc%20Worker%3A%20Swagger%20UI%22%20%2F%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH2%20id%3D%22out-of-process-worker%22%20id%3D%22toc-hId--2104581588%22%20id%3D%22toc-hId--2104338516%22%3EOut-of-Process%20Worker%3C%2FH2%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EIn%20Visual%20Studio%202022%2C%20you%20can%20also%20create%20a%20function%20app%20in%20.NET%20with%20the%20out-of-process%20worker.%20Since%20the%20updated%20Visual%20Studio%20project%20template%20for%20this%20extension%20is%20on%20the%20way%2C%20you%20need%20to%20the%20existing%20HTTP%20trigger%20and%20add%20the%20NuGet%20package%20for%20now.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3COL%3E%0A%3CLI%3EChoose%20%22%3CSTRONG%3E.NET%206%20Isolated%3C%2FSTRONG%3E%22.%3C%2FLI%3E%0A%3CLI%3ESelect%20%22%3CSTRONG%3EHttp%20trigger%3C%2FSTRONG%3E%22%20menu%20on%20the%20left-hand%20side.%3C%2FLI%3E%0A%3CLI%3ESelect%20%22%3CSTRONG%3EFunction%3C%2FSTRONG%3E%22%20for%20the%20Authorization%20level%20field.%3C%2FLI%3E%0A%3CLI%3EClick%20the%20%22%3CSTRONG%3ECreate%3C%2FSTRONG%3E%22%20button.%3C%2FLI%3E%0A%3C%2FOL%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CIMG%20src%3D%22https%3A%2F%2Fsa0blogs.blob.core.windows.net%2Fdevkimchi%2F2021%2F11%2Fgeneral-availability-of-azure-functions-openapi-extension-06.png%22%20border%3D%220%22%20alt%3D%22Out-of-Proc%20Worker%3A%20New%20Azure%20Functions%20Application%20in%20.NET%206%22%20%2F%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EYou%20need%20to%20add%20the%20NuGet%20package%2C%20%3CA%20href%3D%22https%3A%2F%2Fwww.nuget.org%2Fpackages%2FMicrosoft.Azure.Functions.Worker.Extensions.OpenApi%22%20target%3D%22_blank%22%20rel%3D%22nofollow%20noopener%20noreferrer%22%3E%3CCODE%3EMicrosoft.Azure.Functions.Worker.Extensions.OpenApi%3C%2FCODE%3E%3C%2FA%3E%20from%20the%20NuGet%20Package%20Manager.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CIMG%20src%3D%22https%3A%2F%2Fsa0blogs.blob.core.windows.net%2Fdevkimchi%2F2021%2F11%2Fgeneral-availability-of-azure-functions-openapi-extension-07.png%22%20border%3D%220%22%20alt%3D%22Out-of-Proc%20Worker%3A%20Manage%20NuGet%20Packages...%22%20%2F%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EOnce%20installed%2C%20update%3CCODE%3EProgram.cs%3C%2FCODE%3Eto%20activate%20the%20extension.%20Remove%3CCODE%3EConfigureFunctionsWorkerDefaults()%3C%2FCODE%3E(%3CEM%3Eline%20%237%3C%2FEM%3E)%20and%20add%3CCODE%3EConfigureFunctionsWorkerDefaults(worker%20%3D%26gt%3B%20worker.UseNewtonsoftJson())%3C%2FCODE%3Eand%3CCODE%3EConfigureOpenApi()%3C%2FCODE%3E(%3CEM%3Eline%20%2310-11%3C%2FEM%3E).%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-csharp%22%3E%3CCODE%3Epublic%20class%20Program%0A%7B%0A%20%20%20%20public%20static%20void%20Main()%0A%20%20%20%20%7B%0A%20%20%20%20%20%20%20%20var%20host%20%3D%20new%20HostBuilder()%0A%20%20%20%20%20%20%20%20%20%20%20%20%2F%2F%20Remove%20this%20line%0A%20%20%20%20%20%20%20%20%20%20%20%20.ConfigureFunctionsWorkerDefaults()%0A%0A%20%20%20%20%20%20%20%20%20%20%20%20%2F%2F%20Add%20these%20two%20lines%0A%20%20%20%20%20%20%20%20%20%20%20%20.ConfigureFunctionsWorkerDefaults(worker%20%3D%26gt%3B%20worker.UseNewtonsoftJson())%0A%20%20%20%20%20%20%20%20%20%20%20%20.ConfigureOpenApi()%0A%0A%20%20%20%20%20%20%20%20%20%20%20%20.Build()%3B%0A%0A%20%20%20%20%20%20%20%20host.Run()%3B%0A%20%20%20%20%7D%0A%7D%0A%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EThen%2C%20add%20the%20OpenAPI%20related%20decorators%20to%20the%20function%20app%20endpoint%20(%3CEM%3Eline%20%237-9%3C%2FEM%3E).%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-csharp%22%3E%3CCODE%3Epublic%20class%20Function1%0A%7B%0A%20%20%20%20...%0A%0A%20%20%20%20%5BFunction(%22Function1%22)%5D%0A%0A%20%20%20%20%5BOpenApiOperation(operationId%3A%20%22Run%22%2C%20tags%3A%20new%5B%5D%20%7B%20%22greetings%22%20%7D)%5D%0A%20%20%20%20%5BOpenApiSecurity(%22function_key%22%2C%20SecuritySchemeType.ApiKey%2C%20Name%20%3D%20%22code%22%2C%20In%20%3D%20OpenApiSecurityLocationType.Query)%5D%0A%20%20%20%20%5BOpenApiResponseWithBody(statusCode%3A%20HttpStatusCode.OK%2C%20contentType%3A%20%22text%2Fplain%22%2C%20bodyType%3A%20typeof(string)%2C%20Description%20%3D%20%22The%20OK%20response%22)%5D%0A%0A%20%20%20%20public%20HttpResponseData%20Run(%5BHttpTrigger(AuthorizationLevel.Function%2C%20%22get%22%2C%20%22post%22)%5D%20HttpRequestData%20req)%0A%20%20%20%20%7B%0A%20%20%20%20%20%20%20%20...%0A%20%20%20%20%7D%0A%7D%0A%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EOnce%20updated%20two%20files%20like%20above%2C%20rebuild%20the%20project%20and%20run%20the%20function%20app%20by%20clicking%20the%20%22%3CSTRONG%3EDebug%3C%2FSTRONG%3E%22%20button%20at%20the%20top.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CIMG%20src%3D%22https%3A%2F%2Fsa0blogs.blob.core.windows.net%2Fdevkimchi%2F2021%2F11%2Fgeneral-availability-of-azure-functions-openapi-extension-09.png%22%20border%3D%220%22%20alt%3D%22Out-of-Proc%20Worker%3A%20Run%20Function%20App%22%20%2F%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EOpen%20a%20web%20browser%20and%20go%20to%3CCODE%3E%3CA%20href%3D%22http%3A%2F%2Flocalhost%3A7071%2Fapi%2Fswagger%2Fui%22%20target%3D%22_blank%22%20rel%3D%22nofollow%20noopener%20noreferrer%22%3Ehttp%3A%2F%2Flocalhost%3A7071%2Fapi%2Fswagger%2Fui%3C%2FA%3E%3C%2FCODE%3E%2C%20and%20you%20will%20see%20the%20Swagger%20UI%20page%20as%20expected.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CIMG%20src%3D%22https%3A%2F%2Fsa0blogs.blob.core.windows.net%2Fdevkimchi%2F2021%2F11%2Fgeneral-availability-of-azure-functions-openapi-extension-10.png%22%20border%3D%220%22%20alt%3D%22Out-of-Proc%20Worker%3A%20Swagger%20UI%22%20%2F%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH2%20id%3D%22migration-from.net-core-3.1-to.net-6%22%20id%3D%22toc-hId-382931245%22%20id%3D%22toc-hId-383174317%22%3EMigration%20from%20.NET%20Core%203.1%20to%20.NET%206%3C%2FH2%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EIf%20you%20want%20to%20migrate%20your%20existing%20.NET%20Core%203.1%20function%20app%20to%20.NET%206%2C%20all%20you%20need%20to%20do%20is%20to%20update%20the%3CCODE%3E.csproj%3C%2FCODE%3Efile%20and%20update%20the%20package%20version%20and%20target%20framework.%20Open%20your%3CCODE%3E.csproj%3C%2FCODE%3Efile%20(%3CCODE%3ELegacyInProcApp.csproj%3C%2FCODE%3Ein%20this%20example)%2C%20and%20update%3CCODE%3ETargetFramework%3C%2FCODE%3Enode%20from%3CCODE%3Enetcoreapp3.1%3C%2FCODE%3Eto%3CCODE%3Enet6.0%3C%2FCODE%3Eand%3CCODE%3EAzureFunctionsVersion%3C%2FCODE%3Efrom%3CCODE%3Ev3%3C%2FCODE%3Eto%3CCODE%3Ev4%3C%2FCODE%3E(%3CEM%3Eline%20%234-5%2C%208-9%3C%2FEM%3E).%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-xml%22%3E%3CCODE%3E%3CPROJECT%20sdk%3D%22Microsoft.NET.Sdk%22%3E%0A%20%20%3CPROPERTYGROUP%3E%0A%20%20%20%20%3C!--%20Change%20these%20values%20--%3E%0A%20%20%20%20%3CTARGETFRAMEWORK%3Enetcoreapp3.1%3C%2FTARGETFRAMEWORK%3E%0A%20%20%20%20%3CAZUREFUNCTIONSVERSION%3Ev3%3C%2FAZUREFUNCTIONSVERSION%3E%0A%0A%20%20%20%20%3C!--%20To%20these%20values%20--%3E%0A%20%20%20%20%3CTARGETFRAMEWORK%3Enet6.0%3C%2FTARGETFRAMEWORK%3E%0A%20%20%20%20%3CAZUREFUNCTIONSVERSION%3Ev4%3C%2FAZUREFUNCTIONSVERSION%3E%0A%0A%20%20%20%20...%0A%20%20%3C%2FPROPERTYGROUP%3E%0A%20%20...%0A%3C%2FPROJECT%3E%0A%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EThen%2C%20update%20all%20the%20Azure%20Functions%20related%20NuGet%20packages%20to%20the%20latest%20version%2C%20including%20the%20OpenAPI%20extension.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CIMG%20src%3D%22https%3A%2F%2Fsa0blogs.blob.core.windows.net%2Fdevkimchi%2F2021%2F11%2Fgeneral-availability-of-azure-functions-openapi-extension-11.png%22%20border%3D%220%22%20alt%3D%22In-Proc%20Worker%3A%20Migration%22%20%2F%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3ERebuild%20the%20project%2C%20run%20the%20function%20app%20by%20clicking%20the%20%22%3CSTRONG%3EDebug%3C%2FSTRONG%3E%22%20button%20at%20the%20top.%20Next%2C%20open%20a%20web%20browser%20and%20go%20to%3CCODE%3E%3CA%20href%3D%22http%3A%2F%2Flocalhost%3A7071%2Fapi%2Fswagger%2Fui%22%20target%3D%22_blank%22%20rel%3D%22nofollow%20noopener%20noreferrer%22%3Ehttp%3A%2F%2Flocalhost%3A7071%2Fapi%2Fswagger%2Fui%3C%2FA%3E%3C%2FCODE%3E%2C%20and%20you%20will%20see%20the%20Swagger%20UI%20page%20as%20expected.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CIMG%20src%3D%22https%3A%2F%2Fsa0blogs.blob.core.windows.net%2Fdevkimchi%2F2021%2F11%2Fgeneral-availability-of-azure-functions-openapi-extension-12.png%22%20border%3D%220%22%20alt%3D%22In-Proc%20Worker%3A%20Swagger%20UI%20after%20Migration%22%20%2F%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH2%20id%3D%22migration-from.net-5-to.net-6%22%20id%3D%22toc-hId--1424523218%22%20id%3D%22toc-hId--1424280146%22%3EMigration%20from%20.NET%205%20to%20.NET%206%3C%2FH2%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EIf%20you%20want%20to%20migrate%20your%20existing%20.NET%205%20function%20app%20to%20.NET%206%2C%20all%20you%20need%20to%20do%20is%20to%20update%20the%3CCODE%3E.csproj%3C%2FCODE%3Efile%20and%20update%20the%20package%20version%20and%20target%20framework.%20Open%20your%3CCODE%3E.csproj%3C%2FCODE%3Efile%20(%3CCODE%3ELegacyOutOfProcApp.csproj%3C%2FCODE%3Ein%20this%20example)%2C%20and%20update%3CCODE%3ETargetFramework%3C%2FCODE%3Enode%20from%3CCODE%3Enet5.0%3C%2FCODE%3Eto%3CCODE%3Enet6.0%3C%2FCODE%3Eand%3CCODE%3EAzureFunctionsVersion%3C%2FCODE%3Efrom%3CCODE%3Ev3%3C%2FCODE%3Eto%3CCODE%3Ev4%3C%2FCODE%3E(%3CEM%3Eline%20%234-5%2C%208-9%3C%2FEM%3E).%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-xml%22%3E%3CCODE%3E%3CPROJECT%20sdk%3D%22Microsoft.NET.Sdk%22%3E%0A%20%20%3CPROPERTYGROUP%3E%0A%20%20%20%20%3C!--%20Change%20these%20values%20--%3E%0A%20%20%20%20%3CTARGETFRAMEWORK%3Enet5.0%3C%2FTARGETFRAMEWORK%3E%0A%20%20%20%20%3CAZUREFUNCTIONSVERSION%3Ev3%3C%2FAZUREFUNCTIONSVERSION%3E%0A%0A%20%20%20%20%3C!--%20To%20these%20values%20--%3E%0A%20%20%20%20%3CTARGETFRAMEWORK%3Enet6.0%3C%2FTARGETFRAMEWORK%3E%0A%20%20%20%20%3CAZUREFUNCTIONSVERSION%3Ev4%3C%2FAZUREFUNCTIONSVERSION%3E%0A%0A%20%20%20%20...%0A%20%20%3C%2FPROPERTYGROUP%3E%0A%20%20...%0A%3C%2FPROJECT%3E%0A%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EThen%2C%20update%20all%20the%20Azure%20Functions%20related%20to%20NuGet%20packages%20to%20the%20latest%20version%2C%20including%20the%20OpenAPI%20extension.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CIMG%20src%3D%22https%3A%2F%2Fsa0blogs.blob.core.windows.net%2Fdevkimchi%2F2021%2F11%2Fgeneral-availability-of-azure-functions-openapi-extension-13.png%22%20border%3D%220%22%20alt%3D%22Out-of-Proc%20Worker%3A%20Migration%22%20%2F%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3ERebuild%20the%20project%2C%20run%20the%20function%20app%20by%20clicking%20the%20%22%3CSTRONG%3EDebug%3C%2FSTRONG%3E%22%20button%20at%20the%20top.%20Next%2C%20open%20a%20web%20browser%20and%20go%20to%3CCODE%3E%3CA%20href%3D%22http%3A%2F%2Flocalhost%3A7071%2Fapi%2Fswagger%2Fui%22%20target%3D%22_blank%22%20rel%3D%22nofollow%20noopener%20noreferrer%22%3Ehttp%3A%2F%2Flocalhost%3A7071%2Fapi%2Fswagger%2Fui%3C%2FA%3E%3C%2FCODE%3E%2C%20and%20you%20will%20see%20the%20Swagger%20UI%20page%20as%20expected.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CIMG%20src%3D%22https%3A%2F%2Fsa0blogs.blob.core.windows.net%2Fdevkimchi%2F2021%2F11%2Fgeneral-availability-of-azure-functions-openapi-extension-14.png%22%20border%3D%220%22%20alt%3D%22Out-of-Proc%20Worker%3A%20Swagger%20UI%20after%20Migration%22%20%2F%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3ENow%2C%20you%20are%20able%20to%20build%20a%20new%20function%20app%20in%20.NET%206%2C%20as%20well%20as%20migrate%20your%20existing%20function%20apps%20to%20.NET%206%20with%20minimal%20effort.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH2%20id%3D%22try-it-today%22%20id%3D%22toc-hId-1062989615%22%20id%3D%22toc-hId-1063232687%22%3ETry%20It%20Today%3C%2FH2%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EIf%20you%20want%20to%20know%20more%20about%20using%20this%20extension%2C%20visit%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fazure%2Fazure-functions%2Fopenapi-apim-integrate-visual-studio%3FWT.mc_id%3Ddotnet-48656-juyoo%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3Ethis%20page%3C%2FA%3E.%20If%20you%20want%20to%20try%20even%20more%20about%20its%20advanced%20features%2C%20see%20this%20%3CA%20href%3D%22https%3A%2F%2Fgithub.com%2FAzure%2Fazure-functions-openapi-extension%2Fblob%2Fmain%2FREADME.md%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3Edocumentation%3C%2FA%3E%20page.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EAnd%20don't%20miss%20out%20our%20session%20at%20%3CA%20href%3D%22https%3A%2F%2Fwww.dotnetconf.net%2Fagenda%22%20target%3D%22_blank%22%20rel%3D%22nofollow%20noopener%20noreferrer%22%3E.NET%20Conf%3C%2FA%3E%20%E2%80%93%20%3CEM%3EBrand%20New!%20Azure%20Functions%20OpenAPI%20Extension%20on%20.NET%206%3C%2FEM%3E%20%E2%80%93%20live%20streaming%20on%20Nov%2010%2C%209.30pm%20Pacific%20Time%20(Nov%2011%2C%205.30am%20UTC)%20and%20on-demand%20available%20after%20the%20conference!%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EWe're%20listening%20to%20your%20feedback%20while%20you%20are%20using%20this%20extension!%20So%20if%20you%20find%20something%20to%20suggest%2C%20improve%20or%20have%20any%20questions%2C%20please%20%3CA%20href%3D%22https%3A%2F%2Faka.ms%2Fazfunc-openapi%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3Elet%20us%20know%3C%2FA%3E.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-TEASER%20id%3D%22lingo-teaser-2931231%22%20slang%3D%22en-US%22%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-center%22%20image-alt%3D%22general-availability-of-azure-functions-openapi-extension-00%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F324564iC92C61C577208A33%2Fimage-size%2Flarge%3Fv%3Dv2%26amp%3Bpx%3D999%22%20role%3D%22button%22%20title%3D%22general-availability-of-azure-functions-openapi-extension-00%22%20alt%3D%22general-availability-of-azure-functions-openapi-extension-00%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CDIV%3E%0A%3CDIV%3E%3CSPAN%3EWe%20are%20excited%20to%20announce%20the%20general%20availability%20of%20Azure%20Functions%20OpenAPI%20Extension.%3C%2FSPAN%3E%3C%2FDIV%3E%0A%3C%2FDIV%3E%3C%2FLINGO-TEASER%3E%3CLINGO-LABS%20id%3D%22lingo-labs-2931231%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EAzure%20Functions%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E

Co-Authors
Version history
Last update:

‎Nov 08 2021 08:04 AM

Updated by:
Labels

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK