I try to configure my .net Aspire Project that it can scale to zero. I added a scale section to my azure.yaml:
name: Project.AppHost
services:
app:
language: dotnet
project: ./Project.AppHost.csproj
host: containerapp
scale:
minReplicas: 0
maxReplicas: 5
And updated it in the azure portal manually to reflect this. But every time I deploy via azd up
it reverts back to minReplicas: 1 and maxReplicas: 10.
Where would I have to set that option so that it survives deployments?
EDIT:
I found the azd infra synth
command. Turns out here it overrides my scaling settings:
template:
containers:
- image: {{ .Image }}
name: apiservice
env:
- name: AZURE_CLIENT_ID
value: {{ .Env.MANAGED_IDENTITY_CLIENT_ID }}
- name: ASPNETCORE_FORWARDEDHEADERS_ENABLED
value: "true"
- name: HTTP_PORTS
value: '{{ targetPortOrDefault 0 }}'
- name: OTEL_DOTNET_EXPERIMENTAL_OTLP_EMIT_EVENT_LOG_ATTRIBUTES
value: "true"
- name: OTEL_DOTNET_EXPERIMENTAL_OTLP_EMIT_EXCEPTION_LOG_ATTRIBUTES
value: "true"
- name: OTEL_DOTNET_EXPERIMENTAL_OTLP_RETRY
value: in_memory
scale:
minReplicas: 1
When I set infra synth on true, I can update it here and the value is set as expected. But with that I a) have to manually update the template every time when I change something on the infrastructure and then go and update the scale settings again since that is overriden then aswell. So I hope someone found a better solution how to do this aspire ^^
EDIT 2:
It seems this is not supported yet:
https://github.com/dotnet/aspire/discussions/4831