Integrating Azure Key Vault in .NET MAUI Application

Vaibhav Methuku 80 Reputation points
2025-02-12T13:28:32.89+00:00

I want to integrate Azure Key Vault into my .NET MAUI application to store secrets. Can you suggest the best way to do this.?
Additionally, we are also utilizing REST APIs in the app. Please guide me on how to securely integrate Key Vault and manage secrets in this context.

FYI - We are using MSAL authentication in the application?. Update


I want to retrieve the secrets that are stored in the Key Vault in the MAUI Application.

Azure Key Vault
Azure Key Vault
An Azure service that is used to manage and protect cryptographic keys and other secrets used by cloud apps and services.
1,372 questions
.NET MAUI
.NET MAUI
A Microsoft open-source framework for building native device applications spanning mobile, tablet, and desktop.
3,925 questions
{count} votes

2 answers

Sort by: Most helpful
  1. Bruce (SqlWork.com) 71,506 Reputation points
    2025-02-12T16:55:38.3733333+00:00

    you can not safely use Azure Key Vault directly from a Maui app (as you can not include the keys with distribution). Your REST API should access the key vault on the behalf of the Maui user. while the REST API can return the access secret and the app could store, the RST api might as well return the secrets directly.

    note: the mobile O/S have local encryption services used to store secrets the user generates or fetches.

    https://learn.microsoft.com/en-us/dotnet/maui/platform-integration/storage/secure-storage?view=net-maui-9.0&tabs=android

    1 person found this answer helpful.
    0 comments No comments

  2. Martin Brandl 470 Reputation points MVP
    2025-02-12T13:58:42.7166667+00:00

    Do you want to store secrets or do you want to retrieve them? If later, you should rely on environment variables as described here (https://12factor.net/config).

    If you want to save secrets from your .NET backend to Azure Key Vault, you should use the Azure Key Vault client library for .NET. Here is an example.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.