Azure / Azure/azure-cli

ParentResourceNotFound during what-if operation when using Azure CLI 2.27

Open
#19,308 2 comments 1 reaction 0 assignees View on GitHub
act-identity-squad ARM Service Attention
Dominant language
Python
Stars
4.6k
Forks
3.5k
Avg merge
3d 2h
Merged PRs (30d)
60

Description

## Describe the bug

Azure CLI 2.27.0 and 2.27.1 appear to have a regression from 2.26.1 in how What-If analysis is performed.

Using Azure CLI 2.26.1, the Azure Bicep file **test.bicep** (which includes two modules, **key-vault.bicep** and **network.bicep** will succeed in performing a What-If analysis. However, using Azure CLI 2.27+ on the same files, the command will fail.

**Command Name**
`az deployment group what-if`

**Errors:**
```
ParentResourceNotFound - Can not perform requested operation on nested resource. Parent resource '/subscriptions/[SUBSCRIPTION-ID]/resourceGroups/[RESOURCE-GROUP-NAME]/providers/Microsoft.KeyVault/vaults/[KEY-VAULT-NAME]' not found.

```

## To Reproduce:
Steps to reproduce the behavior. Note that argument values have been redacted, as they may contain sensitive information.

```bash
RESOURCE_GROUP_NAME=rg-test-01
LOCATION=eastus

az group create --location $LOCATION --name $RESOURCE_GROUP_NAME

az deployment group what-if \
--resource-group $RESOURCE_GROUP_NAME \
--template-file test.bicep \
--parameters location=eastus
```

The command will fail with the following error if using Azure CLI 2.27.1:

```text
ParentResourceNotFound - Can not perform requested operation on nested resource. Parent resource '/subscriptions/[SUBSCRIPTION-ID]/resourceGroups/rg-test-01/providers/Microsoft.KeyVault/vaults/[KEY-VAULT-NAME]' not found.
```

The Bicep files are attached: [test.zip](https://github.com/Azure/azure-cli/files/7033147/test.zip)

## Expected Behavior

The command should exceed as it does if using Azure CLI version 2.26.1.

Additionally, an equivalent command will succeed if using Azure PowerShell 6.3.0.

```PowerShell
$RESOURCE_GROUP_NAME='rg-test-01'

New-AzResourceGroupDeployment `
-ResourceGroupName $RESOURCE_GROUP_NAME `
-TemplateFile ./test.bicep `
-WhatIf `
-location eastus
```

## Environment Summary
```
Azure Bicep 0.4.613
Linux-5.10.43.3-microsoft-standard-WSL2-x86_64-with-debian-10.10
Python 3.6.10
Installer: DEB

azure-cli 2.27.1

Extensions:
logic 0.1.4
application-insights 0.1.14
stream-analytics 0.1.0
azure-iot 0.10.15

```
## Additional Context

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.