question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

EventHubs.Define does not create all rules

See original GitHub issue

Describe the bug I’m using EventHub.Define to create a new EventHub with both SendRule and ListenRule. After creating the hub I’m using eventHub.ListAuthorizationRulesAsync to get all rules. Since Monday eventHub.ListAuthorizationRulesAsync does not return the correct count of Rules. Even a retry strategy using Polly does not fix that problem.

Exception or Stack Trace There is no exception. The API returns not all rules.

To Reproduce Steps to reproduce the behavior:

Code Snippet

var eventHubs = await azure.EventHubNamespaces.ListByResourceGroupAsync(resourceGroupName);
var eventHubNamespace = eventHubs.FirstOrDefault(x => x.Name == eventHubNamespaceName);

if (eventHubNamespace == null)
{
	eventHubNamespace = await azure.EventHubNamespaces.Define(eventHubNamespaceName)
		.WithRegion(Region.EuropeWest)
		.WithExistingResourceGroup(resourceGroupName)
		.CreateAsync();
}

var eventHub = await azure.EventHubs.Define(eventHubName)
	.WithExistingNamespace(eventHubNamespace)
	.WithPartitionCount(1) // Use only 1 partition, to avoid that event order is destroyed. 
	.WithNewSendRule(Names.EventHubNamespace.SendRule)
	.WithNewListenRule(Names.EventHubNamespace.ListenRule)
	.CreateAsync();

// Retry 8 times because sometimes the keys are not there  
var rules = await Policy
	.Handle<InvalidOperationException>()
	.WaitAndRetryAsync(9, retryAttempt => TimeSpan.FromSeconds(Math.Pow(2, retryAttempt)))
	.ExecuteAsync(
		async () =>
		{
			await eventHub.RefreshAsync();
			var result = await eventHub.ListAuthorizationRulesAsync();
			
			if (result.Count() < 2) // Count should be 2, because WithNewSendRule & WithNewListenRule is set
			{
				throw new InvalidOperationException("Not all AuthorizationRules where created!");
			}

			return result;
		});

Expected behavior SendRule and ListenRule should be created and can be Listed correctly.

Screenshots

Setup (please complete the following information):

  • OS: Windows 10

  • IDE : Rider, VS, Azure DevOps Hosted Build Agent, .NET Core 2.2

  • Version of the Library used:

    • Microsoft.Azure.Management.Fluent Version="1.27.2
    • Microsoft.Azure.Management.ResourceManager.Fluent Version=“1.27.2”

Additional context The problem starts on Monday (2019.11.14) and was detected by our system tests, which runs on an Azure DevOps HostedAgent (Image: windows-2019). Before Monday everything was fine.

Information Checklist Kindly make sure that you have added all the following information above and checkoff the required fields otherwise we will treat the issuer as an incomplete report

  • Bug Description Added
  • Repro Steps Added
  • Setup information Added

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:1
  • Comments:8 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
nickzhumscommented, Jan 15, 2020

@MariuszKogut Closing this issue as it is resolved

1reaction
weidongxu-microsoftcommented, Nov 18, 2019

@MariuszKogut It appears to be intermittent. A possible cause under investigation is concurrent call to create SendRule and ListenRule in parellel. Service might not like this.

Before this issue got triaged and fixed, separate SendRule and ListenRule should help:

var eventHub = await azure.EventHubs.Define(eventHubName)
	.WithExistingNamespace(eventHubNamespace)
	.WithPartitionCount(1) // Use only 1 partition, to avoid that event order is destroyed. 
	.WithNewSendRule(Names.EventHubNamespace.SendRule)
	.CreateAsync();

await eventHub.Update()
	.WithNewListenRule(Names.EventHubNamespace.ListenRule)
	.ApplyAsync();
Read more comments on GitHub >

github_iconTop Results From Across the Web

Built-in policy definitions for Azure Event Hubs
Name (Azure portal) Effect(s) Version (GitHub) Event Hub namespaces should use private link AuditIfNotExists, Disabled 1.0.0 Resource logs in Event Hub should be enabled AuditIfNotExists,...
Read more >
Frequently asked questions - Azure Event Hubs
This article provides a list of frequently asked questions (FAQ) for Azure Event Hubs and their answers.
Read more >
Unable to create EventHub Authorization Rule in Azure ...
While trying to create EventHub Authorization Rule, getting the below error message. Not able to really get through this. ... Had the issue...
Read more >
Can I associate a single shared access policy to more than ...
My use case is that I have 4 event hubs 'A', 'B', 'C' and 'D' (Kafka API). To my service clients I need...
Read more >
Azure Event Hubs
Azure Event Hubs uses a binary protocol over TCP. It does not support HTTP proxies, so Cribl Edge must send events directly to...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found