Create and Publish OpenAPI enabled Azure Functions with Visual Studio and .NET

Published 05-25-2021 05:49 AM 4,604 Views
Microsoft

Today, we are announcing a preview NuGet package, template, and Visual Studio v16.10 publishing support for creating OpenAPI enabled Azure Functions.

The OpenAPI Specification is an API description format for REST APIs and has become the leading convention for describing HTTP APIs. An OpenAPI description effectively describes your API surface; endpoints, operation parameters for each, authentication methods, and other metadata. As a part of the ecosystem already rich with tools and open-source packages for .NET, we wanted to extend this capability to Azure Functions.

In the early days of Azure Functions, there was a preview feature that allow you to use the OpenAPI specification to document your functions or endpoints. This feature experience was built into the Azure Portal, but never realized in the GA version of the product.

 

Brady Gaster showed the benefit of a well-designed API using ASP.NET Core and OpenAPI in this post on the ASP.NET Blog.

 

Getting Started

Using Visual Studio 16.10 or later, create a new Azure Functions project and choose the HttpTrigger template – “Http Trigger with OpenAPI”.

spboyer_0-1621528108312.png


The new function is bootstrapped with the necessary implementation for OpenAPI support. When running the application, notice not only does the function emit the “Function1” endpoint as expected but also additional routes for a dynamic endpoint for OpenAPI document, Swagger document in JSON or YAML, Authentication redirects and the Swagger UI interactive app.

spboyer_1-1621528172363.png

 

The additional routes are encapsulated when the function app is deployed, meaning that they are there but not exposed as public viewable routes.

 

Browsing to the `/api/swagger/ui` endpoint show the Swagger UI page which can be thought of as interactive documentation

spboyer_2-1621528214013.png

 

The dynamic endpoint for the OpenAPI document accepts the version (v2 or v3) of the specification and the extension preferred (json or yaml). In the following example /api/openapi/v2.json returns the appropriate version of the specification in JSON. Note that the emitted JSON includes the operationId, an attribute used to provide a unique string-based identifier for each operation in the API. See more about generating HTTP API clients using Visual Studio Connected Services.

 

spboyer_3-1621528250281.png

 

Publish and CI/CD support

As you can imagine, yes right click publish support is here for you. Using the known publishing dialog, pushing your OpenAPI enable function to AppService or Containers and provisioning the needed Azure resources are all handled.

spboyer_4-1621528465090.png

 

Nothing has changed with the publishing of a new Azure Function, unless you want to also want to use this as a custom connector for your Power Apps. In Visual Studio 16.9 we added support for publishing to an existing Azure API Management service instances and creating new Consumption-mode instances of Azure API Management so you can use the monitoring, security, and integration capabilities of API Management.

 

In Visual Studio 16.10, the functionality is extended to support the Azure Function project that includes OpenAPI capabilities. When you are publishing an Azure Function with OpenAPI, the API Management tab allowing for selecting an existing instance or creating a new one.

 

spboyer_5-1621528548348.png

 

Once the publish operation completes, you’ll be able to view and test the API operations within the API Management portal blade.

 

As an additional option, the provisioning and deployment of the Azure Function and related resources is now also available as a GitHub Action if your code in committed to a repository.

 

spboyer_6-1621528607002.png

 

On finishing the publish dialog, a GitHub Action is created and committed to the repository triggered by a push of any change.

 

spboyer_7-1621528702524.png

 

Using either method publishes or updates your Azure Function, creates or updates the API Management instance AND imports the function for you.

 

Azure API Management

Typically when adding a new API to the API Management instance you would have to manually define names, operations, parameters, endpoints and other metadata. When using the OpenAPI Extension, this is all done for you and any subsequent updates are also handled automatically. The following image shows the “Run” operation from the Azure Function along with all the configuration complete.

spboyer_8-1621528752477.png

 

Add OpenAPI support to existing projects

For adding OpenAPI support to your existing Azure Functions, the Microsoft.Azure.WebJobs.Extensions.OpenApi package is available for .NET functions using the HttpTrigger. With just a few method decorators, the package makes your existing functions endpoints optimized for discovery.

 

 

 

 

 

 

 

public static class SayHello 
{ 
    [FunctionName("SayHello")] 
    [OpenApiOperation(operationId: "Run", tags: new[] { "name" })] 
    [OpenApiParameter(name: "name", In = ParameterLocation.Query, Required = true, Type = typeof(string), Description = "Who do you want to say hello to?")] 
    [OpenApiResponseWithBody(statusCode: HttpStatusCode.OK, contentType: "text/plain", bodyType: typeof(string), Description = "The OK response")] 
    public static async Task<IActionResult> Run( 
        [HttpTrigger(AuthorizationLevel.Anonymous, "get", "post", Route = null)] HttpRequest req, 
        ILogger log) 
    { 
        log.LogInformation("C# HTTP trigger function processed a request."); 
        string name = req.Query["name"]; 
        … 
        return new OkObjectResult(responseMessage); 
        } 
    } 
} 

 

 

 

 

 

 

 

In this example, the AuthorizationLevel is set to “Anonymous”, however with the OpenApiSecurity decorator, using either "code" through querystring or "x-functions-key" through headers; additional security can be applied.

 

Summary 

To learn more about the Azure Functions OpenAPI extension, visit the project on GitHub and checkout the preview documentation. As always. We’re interested in your feedback, please comment below and/or provide more in the issues tab on the repository. 

We can’t wait to see what you build.  

1 Comment
Regular Visitor

Is there plans to allow this to be built in azure devops pipeline as well?

%3CLINGO-SUB%20id%3D%22lingo-sub-2381067%22%20slang%3D%22en-US%22%3ECreate%20and%20Publish%20OpenAPI%20enabled%20Azure%20Functions%20with%20Visual%20Studio%20and%20.NET%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2381067%22%20slang%3D%22en-US%22%3E%3CP%3EToday%2C%20we%20are%20announcing%20a%20%3CA%20href%3D%22https%3A%2F%2Fwww.nuget.org%2Fpackages%2FMicrosoft.Azure.WebJobs.Extensions.OpenApi%22%20target%3D%22_self%22%20rel%3D%22nofollow%20noopener%20noreferrer%22%3Epreview%20NuGet%20package%3C%2FA%3E%2C%20template%2C%20and%20Visual%20Studio%20v16.10%20publishing%20support%20for%20creating%20OpenAPI%20enabled%20Azure%20Functions.%3CBR%20%2F%3E%3CBR%20%2F%3E%3C%2FP%3E%0A%3CP%3EThe%20OpenAPI%20Specification%20is%20an%20API%20description%20format%20for%20REST%20APIs%20and%20has%20become%20the%20leading%20convention%20for%20describing%20HTTP%20APIs.%20An%20OpenAPI%20description%20effectively%20describes%20your%20API%20surface%3B%20endpoints%2C%20operation%20parameters%20for%20each%2C%20authentication%20methods%2C%20and%20other%20metadata.%20As%20a%20part%20of%20the%20ecosystem%20already%20rich%20with%20tools%20and%20open-source%20packages%20for%20.NET%2C%20we%20wanted%20to%20extend%20this%20capability%20to%20Azure%20Functions.%3CBR%20%2F%3E%3CBR%20%2F%3E%3C%2FP%3E%0A%3CP%3EIn%20the%20early%20days%20of%20Azure%20Functions%2C%20there%20was%20a%20preview%20feature%20that%20allow%20you%20to%20use%20the%20OpenAPI%20specification%20to%20document%20your%20functions%20or%20endpoints.%20This%20feature%20experience%20was%20built%20into%20the%20Azure%20Portal%2C%20but%20never%20realized%20in%20the%20GA%20version%20of%20the%20product.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%20class%3D%22lia-align-center%22%3E%3CEM%3EBrady%20Gaster%20showed%20the%20benefit%20of%20a%20well-designed%20API%20using%20ASP.NET%20Core%20and%20OpenAPI%3CA%20href%3D%22https%3A%2F%2Fdevblogs.microsoft.com%2Faspnet%2Fcreating-discoverable-http-apis-with-asp-net-core-5-web-api%2F%3FWT.mc_id%3Ddotnet-13135-bradyg%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3E%20in%20this%20post%20on%20the%20ASP.NET%20Blog%3C%2FA%3E.%3CBR%20%2F%3E%3CBR%20%2F%3E%3C%2FEM%3E%3C%2FP%3E%0A%3CP%20class%3D%22lia-align-left%22%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CFONT%20size%3D%225%22%3EGetting%20Started%3C%2FFONT%3E%3C%2FP%3E%0A%3CP%3EUsing%20Visual%20Studio%2016.10%20or%20later%2C%20create%20a%20new%20Azure%20Functions%20project%20and%20choose%20the%20HttpTrigger%20template%20%E2%80%93%20%E2%80%9CHttp%20Trigger%20with%20OpenAPI%E2%80%9D.%3CBR%20%2F%3E%3CBR%20%2F%3E%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-center%22%20image-alt%3D%22spboyer_0-1621528108312.png%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F282216i2DDCFEBFC7C24522%2Fimage-size%2Flarge%3Fv%3Dv2%26amp%3Bpx%3D999%22%20role%3D%22button%22%20title%3D%22spboyer_0-1621528108312.png%22%20alt%3D%22spboyer_0-1621528108312.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%3CBR%20%2F%3EThe%20new%20function%20is%20bootstrapped%20with%20the%20necessary%20implementation%20for%20OpenAPI%20support.%20When%20running%20the%20application%2C%20notice%20not%20only%20does%20the%20function%20emit%20the%20%E2%80%9CFunction1%E2%80%9D%20endpoint%20as%20expected%20but%20also%20additional%20routes%20for%20a%20dynamic%20endpoint%20for%20OpenAPI%20document%2C%20Swagger%20document%20in%20JSON%20or%20YAML%2C%20Authentication%20redirects%20and%20the%20Swagger%20UI%20interactive%20app.%3CBR%20%2F%3E%3CBR%20%2F%3E%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-center%22%20image-alt%3D%22spboyer_1-1621528172363.png%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F282217i3B3ABC5ED8B1B034%2Fimage-size%2Flarge%3Fv%3Dv2%26amp%3Bpx%3D999%22%20role%3D%22button%22%20title%3D%22spboyer_1-1621528172363.png%22%20alt%3D%22spboyer_1-1621528172363.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EThe%20additional%20routes%20are%20encapsulated%20when%20the%20function%20app%20is%20deployed%2C%20meaning%20that%20they%20are%20there%20but%20not%20exposed%20as%20public%20viewable%20routes.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EBrowsing%20to%20the%20%60%2Fapi%2Fswagger%2Fui%60%20endpoint%20show%20the%20Swagger%20UI%20page%20which%20can%20be%20thought%20of%20as%20interactive%20documentation%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-center%22%20image-alt%3D%22spboyer_2-1621528214013.png%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F282219iDC49AB9F7630A40A%2Fimage-size%2Flarge%3Fv%3Dv2%26amp%3Bpx%3D999%22%20role%3D%22button%22%20title%3D%22spboyer_2-1621528214013.png%22%20alt%3D%22spboyer_2-1621528214013.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EThe%20dynamic%20endpoint%20for%20the%20OpenAPI%20document%20accepts%20the%20version%20(v2%20or%20v3)%20of%20the%20specification%20and%20the%20extension%20preferred%20(json%20or%20yaml).%20In%20the%20following%20example%20%2Fapi%2Fopenapi%2Fv2.json%20returns%20the%20appropriate%20version%20of%20the%20specification%20in%20JSON.%20Note%20that%20the%20emitted%20JSON%20includes%20the%20operationId%2C%20an%20attribute%20used%20to%20provide%20a%20unique%20string-based%20identifier%20for%20each%20operation%20in%20the%20API.%20See%20more%20about%20generating%20HTTP%20API%20clients%20using%20Visual%20Studio%20Connected%20Services.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-center%22%20image-alt%3D%22spboyer_3-1621528250281.png%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F282220i09FADD34E3C5D73B%2Fimage-size%2Flarge%3Fv%3Dv2%26amp%3Bpx%3D999%22%20role%3D%22button%22%20title%3D%22spboyer_3-1621528250281.png%22%20alt%3D%22spboyer_3-1621528250281.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CFONT%20size%3D%225%22%3EPublish%20and%20CI%2FCD%20support%3C%2FFONT%3E%3C%2FP%3E%0A%3CP%3EAs%20you%20can%20imagine%2C%20yes%20right%20click%20publish%20support%20is%20here%20for%20you.%20Using%20the%20known%20publishing%20dialog%2C%20pushing%20your%20OpenAPI%20enable%20function%20to%20AppService%20or%20Containers%20and%20provisioning%20the%20needed%20Azure%20resources%20are%20all%20handled.%3CBR%20%2F%3E%3CBR%20%2F%3E%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-center%22%20image-alt%3D%22spboyer_4-1621528465090.png%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F282222iC43EF6F1E15E496A%2Fimage-size%2Flarge%3Fv%3Dv2%26amp%3Bpx%3D999%22%20role%3D%22button%22%20title%3D%22spboyer_4-1621528465090.png%22%20alt%3D%22spboyer_4-1621528465090.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3ENothing%20has%20changed%20with%20the%20publishing%20of%20a%20new%20Azure%20Function%2C%20unless%20you%20want%20to%20also%20want%20to%20use%20this%20as%20a%20custom%20connector%20for%20your%20Power%20Apps.%20In%20Visual%20Studio%2016.9%20we%20added%20support%20for%20publishing%20to%20an%20existing%3CA%20href%3D%22https%3A%2F%2Fazure.microsoft.com%2Fservices%2Fapi-management%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3E%20Azure%20API%20Management%3C%2FA%3E%20service%20instances%20and%20creating%20new%20Consumption-mode%20instances%20of%20Azure%20API%20Management%20so%20you%20can%20use%20the%20monitoring%2C%20security%2C%20and%20integration%20capabilities%20of%20API%20Management.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EIn%20Visual%20Studio%2016.10%2C%20the%20functionality%20is%20extended%20to%20support%20the%20Azure%20Function%20project%20that%20includes%20OpenAPI%20capabilities.%20When%20you%20are%20publishing%20an%20Azure%20Function%20with%20OpenAPI%2C%20the%20API%20Management%20tab%20allowing%20for%20selecting%20an%20existing%20instance%20or%20creating%20a%20new%20one.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-center%22%20image-alt%3D%22spboyer_5-1621528548348.png%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F282223i8D3E5EE488FAF4C1%2Fimage-size%2Flarge%3Fv%3Dv2%26amp%3Bpx%3D999%22%20role%3D%22button%22%20title%3D%22spboyer_5-1621528548348.png%22%20alt%3D%22spboyer_5-1621528548348.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EOnce%20the%20publish%20operation%20completes%2C%20you%E2%80%99ll%20be%20able%20to%20view%20and%20test%20the%20API%20operations%20within%20the%20API%20Management%20portal%20blade.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EAs%20an%20additional%20option%2C%20the%20provisioning%20and%20deployment%20of%20the%20Azure%20Function%20and%20related%20resources%20is%20now%20also%20available%20as%20a%20GitHub%20Action%20if%20your%20code%20in%20committed%20to%20a%20repository.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-center%22%20image-alt%3D%22spboyer_6-1621528607002.png%22%20style%3D%22width%3A%20809px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F282224iE8F3783C1CB23359%2Fimage-size%2Flarge%3Fv%3Dv2%26amp%3Bpx%3D999%22%20role%3D%22button%22%20title%3D%22spboyer_6-1621528607002.png%22%20alt%3D%22spboyer_6-1621528607002.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EOn%20finishing%20the%20publish%20dialog%2C%20a%20GitHub%20Action%20is%20created%20and%20committed%20to%20the%20repository%20triggered%20by%20a%20push%20of%20any%20change.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-center%22%20image-alt%3D%22spboyer_7-1621528702524.png%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F282225iB48FA2998971D1BE%2Fimage-size%2Flarge%3Fv%3Dv2%26amp%3Bpx%3D999%22%20role%3D%22button%22%20title%3D%22spboyer_7-1621528702524.png%22%20alt%3D%22spboyer_7-1621528702524.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EUsing%20either%20method%20publishes%20or%20updates%20your%20Azure%20Function%2C%20creates%20or%20updates%20the%20API%20Management%20instance%20AND%20imports%20the%20function%20for%20you.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CFONT%20size%3D%225%22%3EAzure%20API%20Management%3C%2FFONT%3E%3C%2FP%3E%0A%3CP%3ETypically%20when%20adding%20a%20new%20API%20to%20the%20API%20Management%20instance%20you%20would%20have%20to%20manually%20define%20names%2C%20operations%2C%20parameters%2C%20endpoints%20and%20other%20metadata.%20When%20using%20the%20OpenAPI%20Extension%2C%20this%20is%20all%20done%20for%20you%20and%20any%20subsequent%20updates%20are%20also%20handled%20automatically.%20The%20following%20image%20shows%20the%20%E2%80%9CRun%E2%80%9D%20operation%20from%20the%20Azure%20Function%20along%20with%20all%20the%20configuration%20complete.%3CBR%20%2F%3E%3CBR%20%2F%3E%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22spboyer_8-1621528752477.png%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F282226iA2FBBA8F143D1A83%2Fimage-size%2Flarge%3Fv%3Dv2%26amp%3Bpx%3D999%22%20role%3D%22button%22%20title%3D%22spboyer_8-1621528752477.png%22%20alt%3D%22spboyer_8-1621528752477.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CFONT%20size%3D%225%22%3EAdd%20OpenAPI%20support%20to%20existing%20projects%3C%2FFONT%3E%3C%2FP%3E%0A%3CP%3EFor%20adding%20OpenAPI%20support%20to%20your%20existing%20Azure%20Functions%2C%20the%20Microsoft.Azure.WebJobs.Extensions.OpenApi%20package%20is%20available%20for%20.NET%20functions%20using%20the%20HttpTrigger.%20With%20just%20a%20few%20method%20decorators%2C%20the%20package%20makes%20your%20existing%20functions%20endpoints%20optimized%20for%20discovery.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%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%20static%20class%20SayHello%20%0A%7B%20%0A%20%20%20%20%5BFunctionName(%22SayHello%22)%5D%20%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%20%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%22Who%20do%20you%20want%20to%20say%20hello%20to%3F%22)%5D%20%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%20%0A%20%20%20%20public%20static%20async%20Task%3CIACTIONRESULT%3E%20Run(%20%0A%20%20%20%20%20%20%20%20%5BHttpTrigger(AuthorizationLevel.Anonymous%2C%20%22get%22%2C%20%22post%22%2C%20Route%20%3D%20null)%5D%20HttpRequest%20req%2C%20%0A%20%20%20%20%20%20%20%20ILogger%20log)%20%0A%20%20%20%20%7B%20%0A%20%20%20%20%20%20%20%20log.LogInformation(%22C%23%20HTTP%20trigger%20function%20processed%20a%20request.%22)%3B%20%0A%20%20%20%20%20%20%20%20string%20name%20%3D%20req.Query%5B%22name%22%5D%3B%20%0A%20%20%20%20%20%20%20%20%E2%80%A6%20%0A%20%20%20%20%20%20%20%20return%20new%20OkObjectResult(responseMessage)%3B%20%0A%20%20%20%20%20%20%20%20%7D%20%0A%20%20%20%20%7D%20%0A%7D%20%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%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EIn%20this%20example%2C%20the%20AuthorizationLevel%20is%20set%20to%20%E2%80%9CAnonymous%E2%80%9D%2C%20however%20with%20the%20OpenApiSecurity%20decorator%2C%20using%20either%20%22code%22%20through%20querystring%20or%20%22x-functions-key%22%20through%20headers%3B%20additional%20security%20can%20be%20applied.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%20aria-level%3D%222%22%3E%3CFONT%20size%3D%225%22%3E%3CSPAN%20data-contrast%3D%22none%22%3ESummary%3C%2FSPAN%3E%3CSPAN%20data-ccp-props%3D%22%7B%26quot%3B201341983%26quot%3B%3A0%2C%26quot%3B335559738%26quot%3B%3A40%2C%26quot%3B335559739%26quot%3B%3A0%2C%26quot%3B335559740%26quot%3B%3A259%7D%22%3E%26nbsp%3B%3C%2FSPAN%3E%3C%2FFONT%3E%3C%2FP%3E%0A%3CP%3E%3CSPAN%20data-contrast%3D%22auto%22%3ETo%20learn%20more%20about%20the%26nbsp%3BAzure%20Functions%26nbsp%3BOpenAPI%26nbsp%3Bextension%2C%20visit%20the%26nbsp%3B%3C%2FSPAN%3E%3CA%20href%3D%22https%3A%2F%2Fgithub.com%2FAzure%2Fazure-functions-openapi-extension%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3E%3CSPAN%20data-contrast%3D%22none%22%3Eproject%20on%26nbsp%3BGitHub%3C%2FSPAN%3E%3C%2FA%3E%3CSPAN%20data-contrast%3D%22auto%22%3E%26nbsp%3Band%20checkout%20the%26nbsp%3B%3C%2FSPAN%3E%3CA%20href%3D%22https%3A%2F%2Faka.ms%2Fopenapiextension_qs%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3E%3CSPAN%20data-contrast%3D%22none%22%3Epreview%20documentation%3C%2FSPAN%3E%3C%2FA%3E%3CSPAN%20data-contrast%3D%22auto%22%3E.%26nbsp%3BAs%20always.%20We%E2%80%99re%20interested%20in%20your%20feedback%2C%20please%20comment%20below%20and%2For%20provide%26nbsp%3Bmore%20in%20the%3C%2FSPAN%3E%3CA%20href%3D%22https%3A%2F%2Fgithub.com%2FAzure%2Fazure-functions-openapi-extension%2Fissues%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3E%3CSPAN%20data-contrast%3D%22none%22%3E%26nbsp%3Bissues%20tab%3C%2FSPAN%3E%3C%2FA%3E%3CSPAN%20data-contrast%3D%22auto%22%3E%26nbsp%3Bon%20the%20repository.%3C%2FSPAN%3E%3CSPAN%20data-ccp-props%3D%22%7B%26quot%3B201341983%26quot%3B%3A0%2C%26quot%3B335559739%26quot%3B%3A160%2C%26quot%3B335559740%26quot%3B%3A259%7D%22%3E%26nbsp%3B%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%3CSPAN%20data-contrast%3D%22auto%22%3EWe%20can%E2%80%99t%20wait%20to%20see%26nbsp%3Bwhat%20you%20build.%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%20data-ccp-props%3D%22%7B%26quot%3B201341983%26quot%3B%3A0%2C%26quot%3B335559739%26quot%3B%3A160%2C%26quot%3B335559740%26quot%3B%3A259%7D%22%3E%26nbsp%3B%3C%2FSPAN%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-TEASER%20id%3D%22lingo-teaser-2381067%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%22OpenAPI_Image.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F282215i453A4D0B53CED78E%2Fimage-size%2Fmedium%3Fv%3Dv2%26amp%3Bpx%3D400%22%20role%3D%22button%22%20title%3D%22OpenAPI_Image.png%22%20alt%3D%22OpenAPI_Image.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3BToday%2C%20we%20are%20announcing%20a%20%3CA%20href%3D%22https%3A%2F%2Fwww.nuget.org%2Fpackages%2FMicrosoft.Azure.WebJobs.Extensions.OpenApi%22%20target%3D%22_self%22%20rel%3D%22nofollow%20noopener%20noreferrer%22%3Epreview%20NuGet%20package%3C%2FA%3E%2C%20template%2C%20and%20Visual%20Studio%20v16.10%20publishing%20support%20for%20creating%20OpenAPI%20enabled%20Azure%20Functions.%3C%2FP%3E%3C%2FLINGO-TEASER%3E%3CLINGO-LABS%20id%3D%22lingo-labs-2381067%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3E.%20NET%20Core%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3E.NET%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EPower%20Apps%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EPower%20Automate%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EPower%20BI%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EPower%20Platform%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EServerless%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2383661%22%20slang%3D%22en-US%22%3ERe%3A%20Create%20and%20Publish%20OpenAPI%20enabled%20Azure%20Functions%20with%20Visual%20Studio%20and%20.NET%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2383661%22%20slang%3D%22en-US%22%3E%3CP%3EIs%20there%20plans%20to%20allow%20this%20to%20be%20built%20in%20azure%20devops%20pipeline%20as%20well%3F%3C%2FP%3E%3C%2FLINGO-BODY%3E
Co-Authors
Version history
Last update:
‎May 25 2021 05:49 AM
Updated by: