Ask Your Question

How can I create a Swagger file using the Swagger command in Azure DevOps with .Net6 and KeyVault?

asked 2021-05-08 11:00:00 +0000

devzero gravatar image

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2022-10-19 13:00:00 +0000

djk gravatar image

To create a Swagger file using the Swagger command in Azure DevOps with .Net6 and KeyVault, you can follow these steps:

  1. Create a new .Net6 web API project in Visual Studio.
  2. Install the Swagger library by running the following command in the Package Manager Console:

    Install-Package Swashbuckle.AspNetCore

  3. Add the following code to the ConfigureServices method in the Startup.cs file:

    services.AddSwaggerGen(c =>
       c.SwaggerDoc("v1", new OpenApiInfo { Title = "My API", Version = "v1" });
  4. Add the following code to the Configure method in the Startup.cs file:

    app.UseSwaggerUI(c =>
       c.SwaggerEndpoint("/swagger/v1/swagger.json", "My API V1");
  5. Build and run the project to ensure that the Swagger documentation is generated correctly.

  6. Add the Swagger CLI task to your Azure DevOps pipeline, and configure it as follows:

    • Select the .Net6 SDK version.
    • Specify the path to your Swagger file.
    • Enable the AzureRM Key Vault option and provide the necessary information to connect to your key vault.
  7. Run the pipeline to generate the Swagger file and store it securely in your key vault.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss

Add Answer

Question Tools


Asked: 2021-05-08 11:00:00 +0000

Seen: 12 times

Last updated: Oct 19 '22