microsoft / microsoft/aspire

Ability to set ASPNETCORE_ENVIRONMENT while executing azd up / azd deploy

Open
#5,178 16 comments 1 reaction 0 assignees View on GitHub
area-deployment azure
Dominant language
C#
Stars
6.3k
Forks
991
Avg merge
2d 15h
Merged PRs (30d)
196

Description

### Is there an existing issue for this?

- [X] I have searched the existing issues

### Describe the bug

If we set the ASPNETCORE_ENVIRONMENT environment variable manually, it gets overridden in the subsequent deployments (versions). Is there a way to make it sticky without involving `infra synth` (Bicep)?

![image](https://github.com/user-attachments/assets/f0fe583a-181e-4716-9323-c1cfb495ac65)

**PS:** We tried using a custom build-configuration (e.g. to STAGING_RELEASE) to set this environment-var dynamically using `.WithEnvironment()` approach, but it looks like `azd up`/`azd deploy` doesn't accept any argument to specify the build-configuration (similar to `dotnet build -c|--configuration`) and it looks like it's [hardcoded](https://github.com/Azure/azure-dev/pull/3443/files) to [`Release`](https://github.com/Azure/azure-dev/issues/3436#issuecomment-1965170718).

### Expected Behavior

Static/Sticky ASPNETCORE_ENVIRONMENT (we want to maintain `staging` vs. `production` apps similar to deployment-slots in AzWebApps/AzFunctions) that doesn't get removed/overridden with every deployment.

### Steps To Reproduce

_No response_

### Exceptions (if any)

_No response_

### .NET Version info

_No response_

### Anything else?

_No response_

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.