+
Skip to content

heaths/dotazure.net

Repository files navigation

Dotazure

releases ci

Locate and load environment variables defined when provisioning an Azure Developer CLI project.

Getting Started

Add a package reference to DotAzure for .NET SDK-style projects:

dotnet add package DotAzure

If you do not already have an Azure Developer CLI (azd) project, you can create one:

azd init

After you define some resources e.g., an Azure Key Vault, you can provision those resources which will create a .env file with any output parameters:

azd up

Example

After azd up provisions resources and creates a .env file, you can call Loader.Load() to load those environment variables from the default environment e.g.,

using DotAzure;

Loader.Load();

// Assumes bicep contains e.g.
//
// output AZURE_KEYVAULT_URL string = kv.properties.vaultUri
Console.WriteLine($"AZURE_KEYVAULT_URL={Environment.GetEnvironmentVariable("AZURE_KEYVAULT_URL")}");

If you want to customize behavior, you can call Loader.Load() with LoadOptions to set a builder-like AzdContext object.

License

Licensed under the MIT license.

About

Load environment variables from Azure Developer CLI environment

Topics

Resources

License

Stars

Watchers

Forks

点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载