Open KSchlobohm opened 2 years ago
This is a very interesting issue, and something I hadn't considered before. The implementation of azd down
works by fetching the most recently deployment and collecting all resource groups from it, which it then deletes. This is logic that is 100% implemented by azd
(since Azure has no related concept).
We should look at what the deployment object looks like in this case and see if there's a better way for us to gather this information.
One thing to ponder (I'm not sure what the answer is here): Imagine that secondaryResources
was conditional on some parameter, which you configured via the environment value DEPLOY_SECONDARY_RESOURCES
. Then you do something like this:
azd env set DEPLOY_SECONDARY_RESOURCES true
azd provision # this creates the secondary resources
azd env set DEPLOY_SECONDARY_RESOURCES false
azd provision # this doesn't create the secondary resources (but they don't get deleted, since ARM doesn't work that way)
azd down --no-prompt --force # does this delete the secondary resource group?
In the above, the most recently deployment won't show anything about the second resource group, and so when we fix this issue azd down
would not delete it. Is that behavior going to be surprising? @KSchlobohm what would you expect here?
Note that the story here would be different for Terraform and Pulumi, in both cases the down
operation translates to destory
and these tools use the state file to ensure they only destroy tracked resources.
@ellismg we're using an environment parameter of SECONDARY_AZURE_LOCATION to trigger this behavior. We expect that parameter to be an empty string for non-prod environments and it should be the name of an azure region when we deploy the multiregional production scenario.
In the non-prod scenario, when the condition is false, I still get this error but I'd like azd
to delete the 1 resource group.
In the prod scenario, when the condition is true I'd like it to delete both resource groups (and it does).
The challenge with deploying code in the prod scenario is explored in #328 where having the same code deployed twice (conditionally) requires me to use the azd env set AZURE_RESOURCE_GROUP {myname}
to tell azd which resource group to target. It's not currently a requirement to use 2 resource groups to target two regions, that's just how I discovered it.
Output from
azd version
Output from
az version
Describe the bug Cannot run
azd down
because AZD reads resourceGroup names from deployment groups and finds a group name that has not been deployed.To Reproduce
azd init
main.bicep
and add the followingazd provision
azd down --no-prompt --force
az deployment sub show -n {name}
azd
command to fail because it thinks 2 resource groups were deployed.Expected behavior Expected
azd down
to delete resourcesEnvironment Information on your environment: