I'm building my first .NET Aspire application and was trialing out the deployment features provided by the Azure Developer CLI.
I initialized my AppHost project with azd init
, naming my environment dev
.
Next, I executed the azd up
command, which provisioned the resources in Azure and deployed my app. I didn't like the name of the resource group though (rg-dev), so I deleted the resource group in Azure, since this documentation states there's no built-in way in Aspire to clean up resources.
I then modified the azure.yaml
file to set a different resource group. The modified YAML now looks like:
# yaml-language-server: $schema=https://raw.githubusercontent.com/Azure/azure-dev/main/schemas/v1.0/azure.yaml.json
name: ProjectName.AppHost
resourceGroup: rg-projectname-${AZURE_ENV_NAME}
services:
app:
language: dotnet
project: ./ProjectName.AppHost.csproj
host: containerapp
When next I executed azd up
, I get the following error:
ERROR: error executing step command 'deploy --all': failed deploying service 'webui': logging in to registry: failed logging into container registry, token: failed getting ACR token: Post "https://resourcename.azurecr.io/oauth2/exchange": dial tcp: lookup resourcename.azurecr.io: no such host, admin: cannot find registry with name 'resourcename' and subscriptionId 'subscriptionid'
I removed the resourceGroup
property from azure.yaml
, getting back to my original deploy state. The azd up
command then resulted in this error:
ERROR: error executing step command 'deploy --all': getting resource group name: getting default resource groups for environment: dev: resource not found: 0 resource groups with prefix or suffix with value: 'dev'
This leads me to believe that azd
is somehow caching the previous deployment and attempting to redeploy the app to the same resources. I deleted all the files & folders created by azd init
. Specifically, the following:
.azure directory .gitignore file azure.yaml file next-steps.md file
I reran the azd init
command, followed by azd up
but the same errors appear.
How do I get azd
to "forget" its previous deployments and do a fresh deployment of the app? Also, is there a different way that resources should be cleaned up in order to not run into this issue?
Any help or advice would be greatly appreciated.
I managed to resolve this issue by modifying the AppHost that would necessitate a reprovisioning operation. Specifically, I removed the SQL Server resource, along with the web app reference to it.
Executing the azd up
command seemed to force a new deployment, provisioning & deploying the application as expected.
I found the azd down
command in the help documentation for the Azure Developer CLI. This appears to be the way to clean up resources instead of manually deleting the Resource Group from Azure.