azure-powershell icon indicating copy to clipboard operation
azure-powershell copied to clipboard

Shared Access Policy's Needed

Open ronbok opened this issue 11 years ago • 5 comments

There does not seem to be an ‘EventHub’ object to set the Shared Access Policy on an Event Hub??
eventhubsap

ronbok avatar Apr 16 '15 12:04 ronbok

:+1:

damienpontifex avatar May 30 '15 16:05 damienpontifex

This will resolve the problem till they implement it

$NamespaceManager = [Microsoft.ServiceBus.NamespaceManager]::CreateFromConnectionString("your-namespace-connection-string");
$EventHubDescription = New-Object -TypeName Microsoft.ServiceBus.Messaging.EventHubDescription -ArgumentList $Path
$EventHubDescription.PartitionCount = $PartitionCount
$EventHubDescription.MessageRetentionInDays = $MessageRetentionInDays

$SharedAccessPolicyName = "your-policy-name"
$Permissions = [Microsoft.ServiceBus.Messaging.AccessRights[]]([Microsoft.ServiceBus.Messaging.AccessRights]::Manage,[Microsoft.ServiceBus.Messaging.AccessRights]::Listen,[Microsoft.ServiceBus.Messaging.AccessRights]::Send)
$SharedAccessAuthorizationRule=new-object Microsoft.ServiceBus.Messaging.SharedAccessAuthorizationRule($SharedAccessPolicyName,$Permissions)

$EventHubDescription.Authorization.Add($SharedAccessAuthorizationRule);
$NamespaceManager.CreateEventHubIfNotExists($EventHubDescription);

ammaroff avatar Jul 01 '15 06:07 ammaroff

This does not work! Gives the below error, Cannot find an overload for "Add" and the argument count: "1".

rajaprad avatar Jul 14 '15 05:07 rajaprad

@Pradebban This because you are using old version of Microsoft.ServiceBus.dll

make sure that you've loaded the latest version of Microsoft.ServiceBus.dll 2.7.5 https://www.nuget.org/packages/WindowsAzure.ServiceBus

$assembly =   get-item -path  "path/to/latest/version/Microsoft.ServiceBus.dll"
Add-Type -Path $assembly.FullName

and you've to notice that Authorization.Add is accepting 1 parameter: https://msdn.microsoft.com/en-us/library/microsoft.servicebus.messaging.authorizationrules.add.aspx

ammaroff avatar Jul 15 '15 06:07 ammaroff

@twitchax: "Azure PowerShell continues to maintain RDFE support on a legacy basis: new functionality and bug fixes are addressed sparingly. This issue does not meet the current threshold for consideration."

cormacpayne avatar Sep 02 '17 00:09 cormacpayne