Azure / Azure/azure-cli-extensions

application-insights: list operation uses old API version, missing workspaceResourceId field

Open
#9,613 1 comment 0 reactions 1 assignee Claimed by @NoriZC View on GitHub
Auto-Assign Azure CLI Team customer-reported Monitor question
Dominant language
Python
Stars
454
Forks
1.7k
Avg merge
2d 19h
Merged PRs (30d)
64

Description

## Description

`az monitor app-insights component show` (list all components) uses API version `2018-05-01-preview`, which does not return the `workspaceResourceId` field. This makes all workspace-based Application Insights resources appear to be classic (non-workspace-based) when listed.

The same command with `--app` and `--resource-group` (get single component) correctly uses API version `2020-02-02-preview`, which does return the `workspaceResourceId` field.

## Reproduction

```bash
# List all - uses api-version=2018-05-01-preview - workspaceResourceId is MISSING
az monitor app-insights component show --debug 2>&1 | grep api-version
# Output: api-version=2018-05-01-preview

az monitor app-insights component show --query "[0].workspaceResourceId" -o json
# Output: null (even for workspace-based resources)

# Get single - uses api-version=2020-02-02-preview - workspaceResourceId is PRESENT
az monitor app-insights component show --app MyAppInsights --resource-group MyRG --debug 2>&1 | grep api-version
# Output: api-version=2020-02-02-preview

az monitor app-insights component show --app MyAppInsights --resource-group MyRG --query "workspaceResourceId" -o json
# Output: "/subscriptions/.../workspaces/my-workspace" (correct)
```

## Workaround

Use `az rest` with the correct API version:

```bash
az rest --method get \
--url "https://management.azure.com/subscriptions/{subscriptionId}/providers/Microsoft.Insights/components?api-version=2020-02-02"
```

This returns the full resource properties including `WorkspaceResourceId` for all components.

## Impact

- Auditing scripts that list all App Insights resources to check workspace-based migration status will incorrectly report all resources as classic
- AI-assisted infrastructure audits are misled by the missing field, leading to incorrect recommendations
- The `ingestionMode` field shows `LogAnalytics` in the list output (suggesting workspace-based), but the actual workspace reference is absent, creating a contradictory response

## Environment

- Azure CLI: 2.83.0
- application-insights extension: 2.0.0b1 (also reproduced on 1.2.3)
- OS: macOS (darwin 25.2.0)

## Expected Fix

Update the list operation in the `application-insights` extension to use `api-version=2020-02-02` (or later) instead of `2018-05-01-preview`, matching the API version already used by the single-resource get operation.

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.