public async Task EventhubCreateGetUpdateDeleteAuthorizationRule() { //create eventhub string eventhubName = Recording.GenerateAssetName("eventhub"); EventHub eventHub = (await _eventHubCollection.CreateOrUpdateAsync(true, eventhubName, new EventHubData())).Value; //create an authorization rule string ruleName = Recording.GenerateAssetName("authorizationrule"); EventHubAuthorizationRuleCollection ruleCollection = eventHub.GetEventHubAuthorizationRules(); AuthorizationRuleData parameter = new AuthorizationRuleData() { Rights = { AccessRights.Listen, AccessRights.Send } }; EventHubAuthorizationRule authorizationRule = (await ruleCollection.CreateOrUpdateAsync(true, ruleName, parameter)).Value; Assert.NotNull(authorizationRule); Assert.AreEqual(authorizationRule.Data.Rights.Count, parameter.Rights.Count); //get authorization rule authorizationRule = await ruleCollection.GetAsync(ruleName); Assert.AreEqual(authorizationRule.Id.Name, ruleName); Assert.NotNull(authorizationRule); Assert.AreEqual(authorizationRule.Data.Rights.Count, parameter.Rights.Count); //get all authorization rules List <EventHubAuthorizationRule> rules = await ruleCollection.GetAllAsync().ToEnumerableAsync(); //validate Assert.True(rules.Count == 1); bool isContainAuthorizationRuleName = false; foreach (EventHubAuthorizationRule rule in rules) { if (rule.Id.Name == ruleName) { isContainAuthorizationRuleName = true; } } Assert.True(isContainAuthorizationRuleName); //update authorization rule parameter.Rights.Add(AccessRights.Manage); authorizationRule = (await ruleCollection.CreateOrUpdateAsync(true, ruleName, parameter)).Value; Assert.NotNull(authorizationRule); Assert.AreEqual(authorizationRule.Data.Rights.Count, parameter.Rights.Count); //delete authorization rule await authorizationRule.DeleteAsync(true); //validate if deleted Assert.IsFalse(await ruleCollection.ExistsAsync(ruleName)); rules = await ruleCollection.GetAllAsync().ToEnumerableAsync(); Assert.True(rules.Count == 0); }