I’m struggling to create shared access policies using PowerShell on Service Bus Queues. It works at the Service Bus level but NOT the queue level unless anyone can help?
I have tried:
New-AzureSBAuthorizationRule -Name "Manage" -Namespace $servicebusNamespace -Permission $("Manage", "Listen", "Send") -EntityName $queue -EntityType Queue
and it returns:
New-AzureSBAuthorizationRule : Object reference not set to an instance of an object.
I have also tried various utilising various code snippets calling the .Net assembly Microsoft.ServiceBus.dll e.g.
$CurrentNamespace = Get-AzureSBNamespace -Name $servicebusNamespace
$NamespaceManager = [Microsoft.ServiceBus.NamespaceManager]::CreateFromConnectionString($CurrentNamespace.ConnectionString);
$newkey = [Microsoft.ServiceBus.Messaging.SharedAccessAuthorizationRule]::GenerateRandomKey()
[Microsoft.ServiceBus.Messaging.AccessRights[]] $AccessRights = [Microsoft.ServiceBus.Messaging.AccessRights]::Send
$AuthorizationRule = [Microsoft.ServiceBus.Messaging.SharedAccessAuthorizationRule]::new("myRule",$newkey, $AccessRights)
$queue = $NamespaceManager.GetQueue($queue)
$queue.Authorization.Add($AuthorizationRule)
Whilst the code executes with no errors, I also don't get any authorization rules!
Can anyone help? Many thanks
Robert