After I create my Event Hub, I am applying rules. Am I able to apply, for example, and Send and a Listen rule to the same shared access policy?
The code I am trying to use seems to "overwrite" the previous rule. Is there a better way I should be doing this?
await eventHub.Update()
.WithNewSendRule(sendListenRuleNames)
.WithNewListenRule(sendListenRuleNames)
.ApplyAsync();
The code above will end up applying only the Listen rule to the Shared Access Policy.
UPDATE
After trying the above way, I tried to implement using Jay's comment like this:
List<AccessRights> accessRights = new List<AccessRights>();
accessRights.Add(AccessRights.Listen);
accessRights.Add(AccessRights.Manage);
foreach (var listenManageRuleNames in list)
{
await eventHub.Manager
.EventHubAuthorizationRules
.Inner
.CreateOrUpdateAuthorizationRuleWithHttpMessagesAsync(eventHubResource.ResourceGroup.Name, eventHubNamespace.Name, eventHubResource.Name, listenManageRuleNames, accessRights);
}
But it ends up giving me this error:
"{\"error\":{\"message\":\"Error setting value to 'Rights' on 'Microsoft.Cloud.ServiceBus.ResourceProvider.ArmVersionedEntities.ArmAuthorizationRuleDescription'. \",\"code\":\"BadRequest\"}}"
UPDATE 2 I just tried doing only AccessRights.Listen and it worked. Right after that I tried doing only AccessRights.Manage and it didn't work, and threw the same error.