Azure / Azure/azure-powershell

Get-AzApplicationInsights returns a subscription ID null error when not authenticated

Open
#26,183 2 comments 0 reactions 0 assignees View on GitHub
act-observability-squad Azure PS Team bug Monitor - ApplicationInsights
Dominant language
C#
Stars
4.8k
Forks
4.3k
Avg merge
3d 14h
Merged PRs (30d)
54

Description

### Description

`Get-AzApplicationInsights` returns a subscription ID null error when you're not authenticated. It should return an error like `Get-AzResource`.

Current behavior:
```powershell
PS C:\> Get-AzApplicationInsights
Get-AzApplicationInsights_List: C:\Program Files\PowerShell\Modules\Az.ApplicationInsights\2.2.5\ApplicationInsights.Autorest\internal\ProxyCmdletDefinitions.ps1:1528
Line |
1528 | $scriptCmd = {& $wrappedCmd @PSBoundParameters}
| ~~~~~~~~~~~~~~~~~~
| Cannot bind argument to parameter 'SubscriptionId' because it is null.
PS C:\>
```

Expected behavior:
```powershell
PS C:\> Get-AzApplicationInsights
Get-AzApplicationInsights: Run Connect-AzAccount to login.
PS C:\>
```

### Issue script & Debug output

```PowerShell
PS C:\> Get-AzApplicationInsights
DEBUG: 10:59:54 AM - [ConfigManager] Got nothing from [DisplaySecretsWarning], Module = [], Cmdlet = []. Returning default value [True].
DEBUG: 10:59:54 AM - GetAzureRMContextCommand begin processing with ParameterSet 'GetSingleContext'.
DEBUG: 10:59:54 AM - [ConfigManager] Got nothing from [DisplayBreakingChangeWarning], Module = [], Cmdlet = []. Returning default value [True].
DEBUG: 10:59:54 AM - [ConfigManager] Got nothing from [DisplayRegionIdentified], Module = [], Cmdlet = []. Returning default value [True].
DEBUG: 10:59:54 AM - [ConfigManager] Got nothing from [CheckForUpgrade], Module = [], Cmdlet = []. Returning default value [True].
DEBUG: 10:59:54 AM - GetAzureRMContextCommand end processing.
Get-AzApplicationInsights_List: C:\Program Files\PowerShell\Modules\Az.ApplicationInsights\2.2.5\ApplicationInsights.Autorest\internal\ProxyCmdletDefinitions.ps1:1528
Line |
1528 | $scriptCmd = {& $wrappedCmd @PSBoundParameters}
| ~~~~~~~~~~~~~~~~~~
| Cannot bind argument to parameter 'SubscriptionId' because it is null.
PS C:\>
```

### Environment data

```PowerShell
Name Value
---- -----
PSVersion 7.4.5
PSEdition Core
GitCommitId 7.4.5
OS Microsoft Windows 10.0.26100
Platform Win32NT
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0
```

### Module versions

```PowerShell
ModuleType Version PreRelease Name PSEdition ExportedCommands
---------- ------- ---------- ---- --------- ----------------
Script 12.3.0 AzPreview Core,Desk
```

### Error output

```PowerShell
HistoryId: 2

Message : Cannot bind argument to parameter 'SubscriptionId' because it is null.
StackTrace : at System.Management.Automation.Runspaces.PipelineBase.Invoke(IEnumerable input)
at Microsoft.PowerShell.Executor.ExecuteCommandHelper(Pipeline tempPipeline, Exception&
exceptionThrown, ExecutionOptions options)
Exception : System.Management.Automation.ParameterBindingValidationException
InvocationInfo : {Get-AzApplicationInsights_List}
Line : $scriptCmd = {& $wrappedCmd @PSBoundParameters}

Position : At C:\Program Files\PowerShell\Modules\Az.ApplicationInsights\2.2.5\ApplicationInsights.Autorest\inter
nal\ProxyCmdletDefinitions.ps1:1528 char:37
+ $scriptCmd = {& $wrappedCmd @PSBoundParameters}
+ ~~~~~~~~~~~~~~~~~~
HistoryId : 2
```

Contributor guide

Open the contributing guide

Research direction

Start by tracing Get-AzApplicationInsights and comparing its unauthenticated path with Get-AzResource. The report points to ApplicationInsights.Autorest/internal/ProxyCmdletDefinitions.ps1:1528 in version 2.2.5. Reproduce without Connect-AzAccount and verify that the command reports “Run Connect-AzAccount to login.” instead of a null SubscriptionId binding error.

Written by the indexing model from the issue text.

Assessment

Tech stack
azure, powershell
Domain
cloud
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.