Azure / Azure/arm-template-whatif

What-If Fails to Detect Unregistered Resource Provider

Open
#396 2 comments 0 reactions 0 assignees View on GitHub
Dominant language
HTML
Stars
101
Forks
21
Avg merge
3h 35m
Merged PRs (30d)
1

Description

## Description
The What-If operation does not detect when the a resource provider is not registered in the target subscription (tested it with Microsoft.KeyVault). This results in a successful What-If output (all green), indicating that the deployment will succeed, but the actual deployment fails with a MissingSubscriptionRegistration error. This issue can lead to unexpected deployment failures, as users rely on What-If to validate templates before deployment.

**Resource type**: Tested with: Microsoft.KeyVault/vaults

**apiVersion**: 2024-12-01-preview and 2022-07-01

**Client**: Azure CLI

## Expected Response

I expected the What-If operation to produce a warning or error indicating that the `Microsoft.KeyVault` resource provider is not registered in the subscription, as this would prevent a successful deployment.

## Current (Noisy) Response

The What-If output incorrectly shows a successful deployment with no warnings about the unregistered resource provider.

### Example What-If Output

```json
{
"status": "Succeeded",
"changes": [
{
"resourceId": "/subscriptions//resourceGroups/my-rg/providers/Microsoft.KeyVault/vaults/my-kv",
"changeType": "Create",
"before": null,
"after": {
"type": "Microsoft.KeyVault/vaults",
"apiVersion": "2024-12-01-preview",
"name": "my-kv",
"location": "eastus",
"properties": {
"sku": {
"family": "A",
"name": "standard"
},
"enabledForDeployment": true,
"enabledForTemplateDeployment": true,
"publicNetworkAccess": "Disabled"
}
}
}
]
}
```

> **Note:** This output is marked as `Succeeded` with green status and no errors, even though the deployment will actually fail due to the resource provider not being registered.

## Additional Context

When the actual deployment is attempted, it fails with the following error due to the unregistered `Microsoft.KeyVault` resource provider:

```json
{
"status": "Failed",
"error": {
"code": "DeploymentFailed",
"message": "At least one resource deployment operation failed. Please list deployment operations for details.",
"details": [
{
"code": "MissingSubscriptionRegistration",
"message": "The subscription is not registered to use namespace 'Microsoft.KeyVault'. See https://aka.ms/rps-not-found for how to register subscriptions.",
"details": [
{
"code": "MissingSubscriptionRegistration",
"target": "Microsoft.KeyVault",
"message": "The subscription is not registered to use namespace 'Microsoft.KeyVault'. See https://aka.ms/rps-not-found for how to register subscriptions."
}
]
}
]
}
}
```

## Workaround

Manually verify and register the provider using the following command before deploying the affected resource type(s):

```bash
az provider register --namespace Microsoft.KeyVault
```

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by reproducing What-If for a Microsoft.KeyVault/vaults resource in a subscription where Microsoft.KeyVault is unregistered, then compare the What-If result with the actual deployment error. Use the Azure CLI scenario and the 2024-12-01-preview or 2022-07-01 API versions mentioned in the issue. Done means What-If reports a warning or error for the missing provider registration.

Written by the indexing model from the issue text.

Assessment

Tech stack
azure
Domain
cloud
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.