↓ Ir para o conteúdo principal

← todas as notas

📎 Webclip

How To Configure Swagger In Azure Functions APIs

The article explains how to integrate Swagger for Azure Function HTTP APIs so the endpoints can be documented and tested through Swagger UI. It walks through package installation, adding Swagger and Swagger UI functions, configuring Swashbuckle in startup, and creating a sample HTTP trigger to appear in the generated API definition.

It also shows how to run the function locally at http://localhost:7071/api/swagger/ui, then publish the function to Azure and use the deployed Swagger URL to test requests. The article notes that the examples use AuthorizationLevel.Anonymous for simplicity and says a Bearer token should be used for better security.

Reading notes
#

  • Install AzureExtensions.Swashbuckle and Microsoft.NET.Sdk.Functions in a new Azure Functions project.
  • Add HTTP trigger functions for swagger/json and swagger/ui, marked with SwaggerIgnore.
  • Configure Swashbuckle in startup with AddSwashBuckle, document metadata, and custom operation IDs.
  • Add a sample HTTP trigger function with request and response models to show up in Swagger.
  • Run locally and open http://localhost:7071/api/swagger/ui to test the UI.
  • Publish the function to Azure, then copy the Swagger URL and test the deployed API.
  • The article uses anonymous access for simplicity and says Bearer token authorization is the secure option.