Azure / Azure/azure-powershell

Object reference not set to an instance of an object when `New-AzServiceEndpointPolicyDefinition`

Open
#16,745 2 comments 0 reactions 0 assignees View on GitHub
act-quality-productivity-squad bug Network Service Attention
Dominant language
C#
Stars
4.8k
Forks
4.3k
Avg merge
2d 17h
Merged PRs (30d)
51

Description

### Description

The cmdlet `New-AzServiceEndpointPolicyDefinition` is supposed to run without error.

### Issue script & Debug output

```PowerShell
PS> New-AzServiceEndpointPolicyDefinition -Name sql -Service 'mocrosoft.sql'
DEBUG: Sought all Az modules and got latest version 0.0.0
DEBUG: 2:05:04 PM - NewAzureServiceEndpointPolicyDefinitionCommand begin processing with ParameterSet 'SetByResource'.
DEBUG: 2:05:04 PM - using account id ''...
New-AzServiceEndpointPolicyDefinition: Object reference not set to an instance of an object.
DEBUG: AzureQoSEvent: Module: Az.Network:4.13.0; CommandName: New-AzServiceEndpointPolicyDefinition; PSVersion: 7.2.1; IsSuccess: False; Duration: 00:00:00.2983287; Exception: Object reference not set to an instance of an object.;
DEBUG: Finish sending metric.
DEBUG: 2:05:05 PM - NewAzureServiceEndpointPolicyDefinitionCommand end processing.
```

### Environment data

```PowerShell
Name Value
---- -----
PSVersion 7.2.1
PSEdition Core
GitCommitId 7.2.1
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.0 Az.Accounts {Add-AzEnvironment, Clear-AzContext, Clear-AzDefault, Connect-AzAccount…}
Script 4.13.0 Az.Network
```

### Error output

```PowerShell
Message : Object reference not set to an instance of an object.
StackTrace : at Microsoft.Azure.Commands.Network.NewAzureServiceEndpointPolicyDefinitionCommand.Execute()
at Microsoft.Azure.Commands.Network.NetworkBaseCmdlet.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 : {New-AzServiceEndpointPolicyDefinition}
Line : New-AzServiceEndpointPolicyDefinition -Name sql -Service 'mocrosoft.sql'
Position : At line:1 char:1
+ New-AzServiceEndpointPolicyDefinition -Name sql -Service 'mocrosoft.s …
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
HistoryId : 2
```

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.