Skip to content

[Issue] Cannot run azd down when using conditional deployment #553

@KSchlobohm

Description

@KSchlobohm

Output from azd version

azd version 0.1.0-beta.5 (commit 7bd25dd6f1b1899abf63b5f6f36d268a465183e4)

Output from az version

{
  "azure-cli": "2.38.0",
  "azure-cli-core": "2.38.0",
  "azure-cli-telemetry": "1.0.6",
  "extensions": {
    "containerapp": "0.3.5",
    "log-analytics": "0.2.2",
    "rdbms-connect": "1.0.2"
  }
}

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.

Error: listing resource group rg-azd-conditional2: failed running az resource list: exit code: 3, stdout: , stderr: ERROR: (ResourceGroupNotFound) Resource group 'rg-azd-conditional2' could not be found.
Code: ResourceGroupNotFound
Message: Resource group 'rg-azd-conditional2' could not be found.
: exit status 3

To Reproduce

  1. azd init
  2. Choose a template (I chose todo-csharp-cosmos-sql)
  3. Open main.bicep and add the following
resource resourceGroup2 'Microsoft.Resources/resourceGroups@2021-04-01' = if (false) {
  name: '${abbrs.resourcesResourceGroups}${name}2'
  location: location
  tags: tags
}

module secondaryResources 'resources.bicep' = if (false) {
  name: 'resources2'
  scope: resourceGroup2
  params: {
    location: location
    principalId: principalId
    resourceToken: resourceToken
    tags: tags
  }
}
  1. Run azd provision
  2. Observe - Verify the 2nd resource group was not deployed
  3. Run azd down --no-prompt --force
  4. Observe - The command will fail with error message shown above
  5. Run az deployment sub show -n {name}
  6. Observe - The 2nd resource group was not deployed because the conditional is false but the deployment included it in the description. This causes the azd command to fail because it thinks 2 resource groups were deployed.

Expected behavior
Expected azd down to delete resources

Environment
Information on your environment:
* Ran from PowerShell

Metadata

Metadata

Assignees

Labels

area/core-cliCLI commands, cmd/, internal/cmd/area/provisioningBicep/Terraform/ADE provisioningenhancementNew feature or improvement

Type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions