https://github.com/heaths/dotazure.net
Load environment variables from Azure Developer CLI environment
https://github.com/heaths/dotazure.net
azd azure-dev dotenv
Last synced: 3 months ago
JSON representation
Load environment variables from Azure Developer CLI environment
- Host: GitHub
- URL: https://github.com/heaths/dotazure.net
- Owner: heaths
- License: mit
- Created: 2025-08-28T10:34:28.000Z (9 months ago)
- Default Branch: main
- Last Pushed: 2025-08-30T08:00:05.000Z (9 months ago)
- Last Synced: 2025-08-30T09:18:40.856Z (9 months ago)
- Topics: azd, azure-dev, dotenv
- Language: C#
- Homepage:
- Size: 18.6 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# Dotazure
[](https://github.com/heaths/dotazure.net/releases/latest)
[](https://github.com/heaths/dotazure.net/actions/workflows/ci.yml)
Locate and load environment variables defined when provisioning an [Azure Developer CLI] project.
## Getting Started
If you do not already have an [Azure Developer CLI] (azd) project, you can create one:
```sh
azd init
```
Add a package reference to [`dotazure`](https://www.nuget.org/packages/DotAzure) to your project:
```sh
dotnet add package DotAzure
```
After you define some resources e.g., an [Azure Key Vault](https://github.com/heaths/dotazure-rs/blob/main/infra/resources.bicep),
you can provision those resources which will create a `.env` file with any `output` parameters:
```sh
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.,
```csharp
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](https://github.com/heaths/dotazure/blob/refactor/LICENSE.txt) license.
[Azure Developer CLI]: https://aka.ms/azd