Skip to content

New-AzEventGridSubscription Advance filters Unsupported operator StringNotBeginsWith, StringNotEndsWith, StringNotContains #19336

@aromanrod

Description

@aromanrod

Description

Hi all!
I have been trying to create event subscription using powershell but Im getting following error message:

New-AzEventGridSubscription -ResourceId $storageaccountId -EventSubsc …
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| Invalid Advanced Filter parameter. Unsupported operator for advanced filter #2.

I'm trying to create an advance filter with operator = StringNotContains.
I noticed some of the operators does not work as StringNotBeginsWith, StringNotEndsWith, StringNotContains

Reference documentation:
https://docs.microsoft.com/en-us/powershell/module/az.eventgrid/new-azeventgridsubscription?view=azps-8.2.0#parameters

https://docs.microsoft.com/en-us/azure/event-grid/event-filtering#stringnotcontains

Issue script & Debug output

[CmdletBinding()]
param (
    [Parameter()]
    [string]$storageaccountId="",
    [string]$SBendpoint="",
    [string]$evenSubName="DataretMlstorage",
    [string]$subjectBegins ="/blobServices/default/containers/mldataretention/blobs/"


)

$Eventtypes=("Microsoft.Storage.BlobCreated", "Microsoft.Storage.BlobDeleted", "Microsoft.Storage.DirectoryRenamed")
$AdvFilter1=@{operator="StringNotBeginsWith"; key="Data.Key1"; Values=@("1","2")}
$AdvFilter2=@{operator="StringNotContains"; key="Subject"; Values=@("SubjectPrefix1","SubjectPrefix2")}
$AdvancedFilters=@($AdvFilter1, $AdvFilter2)

New-AzEventGridSubscription -ResourceId $storageaccountId -EventSubscriptionName $evenSubName -Endpoint $SBendpoint -EndpointType servicebusqueue -IncludedEventType $Eventtypes -SubjectBeginsWith $subjectBegins -AdvancedFilter $AdvancedFilters -EventTtl 1440 -MaxDeliveryAttempt 30
New-AzEventGridSubscription: /home/armandoroman/Documents/Repositories/PrivateDevopsSub/Azure Architect Project/eventSub.ps1:17:1
Line |
  17 |  New-AzEventGridSubscription -ResourceId $storageaccountId -EventSubsc …
     |  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     | Invalid Advanced Filter parameter. Unsupported operator for advanced filter #1.

DEBUG: 9:19:03 AM - [ConfigManager] Got nothing from [DisplayBreakingChangeWarning], Module = [], Cmdlet = []. Returning default value [True].
DEBUG: AzureQoSEvent: Module: Az.EventGrid:1.3.0; CommandName: New-AzEventGridSubscription; PSVersion: 7.2.5; IsSuccess: False; Duration: 00:00:00.0720085; Exception: Invalid Advanced Filter parameter. Unsupported operator for advanced filter #1.;
DEBUG: Finish sending metric.
DEBUG: 9:19:03 AM - NewAzureEventGridSubscription end processing.

Environment data

Name                           Value
----                           -----
PSVersion                      7.2.5
PSEdition                      Core
GitCommitId                    7.2.5
OS                             Linux 5.18.16-200.fc36.x86_64 #1 SMP PREEMPT_DYNAMIC Wed Aug 3 15:44:49 UTC 2022
Platform                       Unix
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

Module versions

ModuleType Version    PreRelease Name                                ExportedCommands
---------- -------    ---------- ----                                ----------------
Script     2.9.1                 Az.Accounts                         {Add-AzEnvironment, Clear-AzConfig, Clear-AzContext, Cle…
Script     1.1.4                 Az.AnalysisServices                 {Add-AzAnalysisServicesAccount, Export-AzAnalysisService…
Script     1.3.0                 Az.EventGrid                        {Get-AzEventGridDomain, Get-AzEventGridDomainKey, Get-Az

Error output

HistoryId: 10

Message        : Invalid Advanced Filter parameter. Unsupported operator for advanced filter #1.
StackTrace     :    at Microsoft.Azure.Commands.EventGrid.EventGridClient.UpdatedAdvancedFilterParameters(Hashtable[] 
                 advancedFilter, EventSubscriptionFilter filter)
                    at Microsoft.Azure.Commands.EventGrid.EventGridClient.CreateEventSubscription(String scope, String 
                 eventSubscriptionName, String endpoint, String endpointType, String subjectBeginsWith, String 
                 subjectEndsWith, Boolean isSubjectCaseSensitive, String[] includedEventTypes, String[] labels, RetryPolicy 
                 retryPolicy, String deliverySchema, String deadLetterEndpoint, DateTime expirationDate, Hashtable[] 
                 advancedFilter, Int32 maxEventsPerBatch, Int32 preferredBatchSizeInKiloByte, String aadTenantId, String 
                 aadAppIdOrUri)
                    at Microsoft.Azure.Commands.EventGrid.NewAzureEventGridSubscription.ExecuteCmdlet()
                    at Microsoft.WindowsAzure.Commands.Utilities.Common.CmdletExtensions.<>c__3`1.<ExecuteSynchronouslyOrAsJob
                 >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.Exception
InvocationInfo : {New-AzEventGridSubscription}
Line           : New-AzEventGridSubscription -ResourceId $storageaccountId -EventSubscriptionName $evenSubName -Endpoint 
                 $SBendpoint -EndpointType servicebusqueue -IncludedEventType $Eventtypes -SubjectBeginsWith $subjectBegins 
                 -AdvancedFilter $AdvancedFilters -EventTtl 1440 -MaxDeliveryAttempt 30
Position       : At /home/armandoroman/Documents/Repositories/PrivateDevopsSub/Azure Architect Project/eventSub.ps1:17 char:1
                 + New-AzEventGridSubscription -ResourceId $storageaccountId -EventSubsc …
                 + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
HistoryId      : 10

Metadata

Metadata

Labels

CXP Attention[Deprecated] The Azure CXP Support Team is responsible for this issue.Event GridbugThis issue requires a change to an existing behavior in the product in order to be resolved.customer-reported

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions