Azure / Azure/azure-powershell
Set-AzDiagnistingSetting does not work with valid inputObject parameter
- Dominant language
- C#
- Stars
- 4.8k
- Forks
- 4.3k
- Avg merge
- 2d 17h
- Merged PRs (30d)
- 51
Description
### Description
### Get the existing diagnostic settings
$diagSettings = Get-AzDiagnosticSetting -ResourceId ""
### Remove existing settings
Remove-AzDiagnosticSetting -ResourceId ""
### Update the settings object
$diagSettings.StorageAccountId = ""
### Attempt to update the settings and you will observe the following error.
Set-AzDiagnosticSetting -InputObject $diagSettings
DEBUG: 9:58:36 AM - SetAzureRmDiagnosticSettingCommand begin processing with ParameterSet 'NewSetDiagnosticSetting'.
DEBUG: 9:58:36 AM - using account id ''...
WARNING: 9:58:36 AM - *** The namespace for all the model classes will change from Microsoft.Azure.Management.Monitor.Management.Models to Microsoft.Azure.Management.Monitor.Models in future releases.
WARNING: 9:58:36 AM - *** The namespace for output classes will be uniform for all classes in future releases to make it independent of modifications in the model classes.
DEBUG: 9:58:36 AM - Processing using InputObject
Set-AzDiagnosticSetting: Exception type: ArgumentException, Message: System.ArgumentException: InputObject is inconsistent: Id is incomplete or malformed, Id: '', Name: ''
at Microsoft.Azure.Commands.Insights.Diagnostics.SetAzureRmDiagnosticSettingCommand.ProcessRecordInternal()
at Microsoft.Azure.Commands.Insights.MonitorCmdletBase.ExecuteCmdlet(), Code: Null, Status code:Null, Reason phrase: Null
DEBUG: AzureQoSEvent: Module: Az.Monitor:3.0.1; CommandName: Set-AzDiagnosticSetting; PSVersion: 7.2.2; IsSuccess: False; Duration: 00:00:00.0439658; Exception: Exception type: ArgumentException, Message: System.ArgumentException: InputObject is inconsistent: Id is incomplete or malformed, Id: '', Name: ''
at Microsoft.Azure.Commands.Insights.Diagnostics.SetAzureRmDiagnosticSettingCommand.ProcessRecordInternal()
at Microsoft.Azure.Commands.Insights.MonitorCmdletBase.ExecuteCmdlet(), Code: Null, Status code:Null, Reason phrase: Null;
DEBUG: Finish sending metric.
DEBUG: 9:58:37 AM - SetAzureRmDiagnosticSettingCommand end processing.
DEBUG: 9:58:37 AM - GetAzureRMContextCommand end processing.
### Issue script & Debug output
```PowerShell
$diagSettings = Get-AzDiagnosticSetting -ResourceId ""
Remove-AzDiagnosticSetting -ResourceId ""
$diagSettings.StorageAccountId = ""
Set-AzDiagnosticSetting -InputObject $diagSettings
```
### Environment data
```PowerShell
PSVersion 7.2.2
PSEdition Core
GitCommitId 7.2.2
OS Microsoft Windows 10.0.19044
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 ExportedCommands
---------- ------- ---------- ---- ----------------
Script 2.7.4 Az.Accounts {Add-AzEnvironment, Clear-AzContext, Clear-AzDefault, Connect-AzAccount…}
Script 3.0.1 Az.Monitor {Add-AzAutoscaleSetting, Add-AzLogProfile, Add-AzMetricAlertRule, Add-AzMetricAlertRuleV2…}
```
### Error output
```PowerShell
Message : Exception type: ArgumentException, Message: System.ArgumentException: InputObject is inconsistent: Id is incomplete or malformed, Id: '', Name:
''
at Microsoft.Azure.Commands.Insights.Diagnostics.SetAzureRmDiagnosticSettingCommand.ProcessRecordInternal()
at Microsoft.Azure.Commands.Insights.MonitorCmdletBase.ExecuteCmdlet(), Code: Null, Status code:Null, Reason phrase: Null
StackTrace : at Microsoft.Azure.Commands.Insights.MonitorCmdletBase.ExecuteCmdlet()
at Microsoft.WindowsAzure.Commands.Utilities.Common.AzurePSCmdlet.ProcessRecord()
Exception : System.Management.Automation.PSInvalidOperationException
InvocationInfo : {Set-AzDiagnosticSetting}
Line : Set-AzDiagnosticSetting -InputObject $diagSettings
Position : At line:1 char:1
+ Set-AzDiagnosticSetting -InputObject $diagSettings
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
HistoryId : 158
Message : InputObject is inconsistent: Id is incomplete or malformed, Id: '', Name: ''
StackTrace : at Microsoft.Azure.Commands.Insights.Diagnostics.SetAzureRmDiagnosticSettingCommand.ProcessRecordInternal()
at Microsoft.Azure.Commands.Insights.MonitorCmdletBase.ExecuteCmdlet()
Exception : System.ArgumentException
InvocationInfo : {Set-AzDiagnosticSetting}
Line : Set-AzDiagnosticSetting -InputObject $diagSettings
Position : At line:1 char:1
+ Set-AzDiagnosticSetting -InputObject $diagSettings
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
HistoryId : 158
```
Contributor guide
Research direction
Start by reproducing the failure with Get-AzDiagnosticSetting, Remove-AzDiagnosticSetting, and Set-AzDiagnosticSetting -InputObject using the reported Az.Monitor 3.0.1 environment. Trace the Set-AzDiagnosticSetting InputObject validation that reports an incomplete or malformed Id; done means a valid object returned by Get-AzDiagnosticSetting can be updated and submitted successfully.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- azure, csharp, powershell
- Domain
- backend-api-design, cli
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100