AzureEventProvider - SubscriptionName exceeds 50 characters

Vote:
 

Hello!

I am getting an issue when using AzureEventProvider due to SubscriptionName is longer than 50 characters. After some investigation with ILSpy i found out that the SubscriptionName as following:

Environment.MachineName.Replace('/', '_').Replace(':', '_') + Guid.NewGuid().ToString("N");

This makes so the machine name can only be 14 characters long. A suggestion could be to have a SubscriptionName Setter in AzureEventProviderOptions.

or maybe there is another way to set that I havent found?

#265186
Oct 16, 2021 20:12
Vote:
 

The AzureEventProvider is a public class and quite a few of the methods of overridable. As that value is set in the constructor you could create a custom version inheriting it and inject it in as the default.

#265220
Oct 17, 2021 11:56
Vote:
 

The problem is that SubscriptionName only has a Getter, which uses the private variable _uniqueName which is set in the DefaultServiceBusEventProvider constructor. 
So there is no way to set _uniqueName without duplicating DefaultServiceBusEventProvider or maybe using Reflection to set _uniqueName in a inherited class.


#265265
Oct 18, 2021 13:23
Vote:
 

I don't see any code relating to DefaultServiceBusEventProvider in any projects I've got on DXP/Azure.

There's an AzureEventProvider which you mentioned in your post and the one I was looking at which has

    public AzureEventProvider(
      AzureEventClientFactory clientFactory,
      EventsServiceKnownTypesLookup knownTypesLookup,
      IServiceBusSetup setup)
    {
      this._clientFactory = clientFactory;
      this._knownTypesLookup = knownTypesLookup;
      this._uniqueName = Environment.MachineName.Replace('/', '_').Replace(':', '_') + Guid.NewGuid().ToString("N");
      this._serviceBusSetup = setup;
    }

To which as this is a public non sealed class I woud just

public CustomAzureEventProvider : AzureEventProvider
{
    public AzureEventProvider(AzureEventClientFactory clientFactory,
      EventsServiceKnownTypesLookup knownTypesLookup,
      IServiceBusSetup setup)
{
      this._clientFactory = clientFactory;
      this._knownTypesLookup = knownTypesLookup;
      this._uniqueName = WHATEVER YOU LIKE
      this._serviceBusSetup = setup;
}
}

Then just configure structuremap to use this instead

#265273
Oct 18, 2021 15:14
Vote:
 

This actually might be a bug that needs to be fixed by Opti. What if I take my site and host it in AKS (for example). They have pretty long pod names that sometimes exceed 50 chars.

#265806
Oct 28, 2021 8:03
Vote:
 

I have created an implementation over AzureServiceBusProiver which resolves this issue by using reflection. Actually the way i found this bug was when using Kubernetes and a Pod in a Deployment, which gets a hash suffix appended to its MachineName. I have created a issue in Customer suggestions aswell, so hopefully Optimizely will see the error and fix it
 
The implementation can be found here along with some self promotion to my post 😁 https://dev.to/stoffe/optimizely-on-kubernetes-4k9n

#265807
Oct 28, 2021 8:07
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.