Azure / Azure/azure-powershell
Update-AzEventGridPartnerTopic does not work when trying to add managed identities.
- Dominant language
- C#
- Stars
- 4.8k
- Forks
- 4.3k
- Avg merge
- 3d 14h
- Merged PRs (30d)
- 54
Description
### Description
Update-AzEventGridPartnerTopic does not work when trying to add managed identities.
Error is here: https://github.com/Azure/azure-powershell/blob/7407fb00a5c87de5dcc5725a737561049d08a967/src/EventGrid/EventGrid/Utilities/EventGridClient.cs#L2875C21-L2875C21
### Issue script & Debug output
```PowerShell
PS> [string[]]$identities = "/subscriptions/..."
PS> Update-AzEventGridPartnerTopic -ResourceGroupName "rg" -Name "topic" -IdentityId $identities -IdentityType UserAssigned
PS> Update-AzEventGridPartnerTopic: Object reference not set to an instance of an object.
```
### Environment data
```PowerShell
Name Value
---- -----
PSVersion 7.3.5
PSEdition Core
GitCommitId 7.3.5
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 PSEdition ExportedCommands
---------- ------- ---------- ---- --------- ----------------
Script 10.1.0 Az Core,Desk
ModuleType Version PreRelease Name PSEdition ExportedCommands
---------- ------- ---------- ---- --------- ----------------
Script 10.1.0 Az Core,Desk
ModuleType Version PreRelease Name PSEdition ExportedCommands
---------- ------- ---------- ---- --------- ----------------
Script 2.12.4 Az.Accounts {Add-AzEnvironment, Clear-AzConfig, Clear-AzContext, Clear-AzDefault…}
Script 1.6.0 Az.EventGrid {Enable-AzEventGridPartnerTopic, Get-AzEventGridChannel, Get-AzEventGridDomain, Get-AzEventGridDomainKey…}
```
### Error output
```PowerShell
Message : Object reference not set to an instance of an object.
StackTrace : at Microsoft.Azure.Commands.EventGrid.EventGridClient.UpdatePartnerTopic(String resourceGroupName, String partnerTopicName, String identityType, IDictionary`2 userAssignedIdentities, Dictionary`2 tags)
at Microsoft.Azure.Commands.EventGrid.UpdateAzureEventGridPartnerTopic.ExecuteCmdlet()
at Microsoft.WindowsAzure.Commands.Utilities.Common.CmdletExtensions.<>c__3`1.b__3_0(T c)
at Microsoft.WindowsAzure.Commands.Utilities.Common.CmdletExtensions.ExecuteSynchronouslyOrAsJob[T](T cmdlet, Action`1 executor)
at Microsoft.WindowsAzure.Commands.Utilities.Common.CmdletExtensions.ExecuteSynchronouslyOrAsJob[T](T cmdlet)
at Microsoft.WindowsAzure.Commands.Utilities.Common.AzurePSCmdlet.ProcessRecord()
Exception : System.NullReferenceException
InvocationInfo : {Update-AzEventGridPartnerTopic}
Line : Update-AzEventGridPartnerTopic -InputObject $topic -IdentityId $identityIds -IdentityType UserAssigned -Verbose
Position : At line:1 char:1
+ Update-AzEventGridPartnerTopic -InputObject $topic -IdentityId $ident …
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
HistoryId : 15
```
Contributor guide
Research direction
Start with src/EventGrid/EventGrid/Utilities/EventGridClient.cs at the reported error near line 2875, then follow UpdatePartnerTopic from the stack trace. Reproduce the Update-AzEventGridPartnerTopic command with IdentityType UserAssigned and the supplied IdentityId value. Done means the command no longer raises a NullReferenceException when adding managed identities.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- azure, csharp, powershell
- Domain
- backend-api-design, cloud
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 55/100