Using PS Module "Az.EventHub" V1.5.0 not possible for EventHubs with longer names
Description
I installed the PowerShell module Az V4.3.0 and with it I got the new Az EventHub V1.5.0 installed as well.
Now, EventHubs with names longer than 50 characters are no longer supported. Downgrading to Az EventHub V1.4.3 solves the problem.
This is either a bug or should at least be marked as a breaking change.
Steps to reproduce
Install-Module -Name "Az.EventHub" -RequiredVersion "1.5.0" -Force
Get-AzEventHub -ResourceGroupName "my-rg" -Namespace "my-ns" -EventHub "my-eventhub-with-at-least-fifty-characters-12345678"
# Error Message: Get-AzEventHub : 'eventHubName' exceeds maximum length of '50'.
Solving the problem
Uninstall-Module -Name "Az.EventHub" -RequiredVersion "1.5.0" -Force
Install-Module -Name "Az.EventHub" -RequiredVersion "1.4.3" -Force
Thanks for the feedback! We are routing this to the appropriate team for follow-up. cc @jfggdl.
@andreasschild , thanks for reporting. Could you share debug message after you set $DebugPreference="Continue"?
Sure:
PS C:\WINDOWS\system32> Get-AzEventHub -ResourceGroupName "xxx" -Namespace "xxx" -EventHub "xxx"
DEBUG: 2:18:16 PM - GetAzureRmEventHub begin processing with ParameterSet '__AllParameterSets'.
DEBUG: 2:18:16 PM - using account id 'xxx'...
DEBUG: [Common.Authentication]: Authenticating using Account: 'xxx', environment: 'AzureCloud', tenant: 'xxx'
DEBUG: [Common.Authentication]: Authenticating using configuration values: Domain: 'xxx', Endpoint: 'https://login.microsoftonline.com/', ClientId: 'xxx', ClientRedirect: 'urn:ietf:wg:oauth:2.0:oob',
ResourceClientUri: 'https://management.core.windows.net/', ValidateAuthority: 'True'
DEBUG: [Common.Authentication]: Acquiring token using context with Authority 'https://login.microsoftonline.com/xxxx/', CorrelationId: '00000000-0000-0000-0000-000000000000', ValidateAuthority: 'True'
DEBUG: [Common.Authentication]: Acquiring token using AdalConfiguration with Domain: 'xxxx', AdEndpoint: 'https://login.microsoftonline.com/', ClientId: 'xxxx', ClientRedirectUri: urn:ietf:wg:oauth:2.0:oob
DEBUG: [ADAL]: Information: 2020-07-06T12:18:16.1950922Z: xxx - LoggerBase.cs: ADAL PCL.Desktop with assembly version '3.19.2.6005', file version '3.19.50302.0130' and informational version '2a8bec6c4c76d0c1ef819b55bdc3cda2d2605056' is
running...
DEBUG: [ADAL]: Information: 2020-07-06T12:18:16.1950922Z: xxxx - LoggerBase.cs: ADAL PCL.Desktop with assembly version '3.19.2.6005', file version '3.19.50302.0130' and informational version '2a8bec6c4c76d0c1ef819b55bdc3cda2d2605056' is
running...
DEBUG: [ADAL]: Information: 2020-07-06T12:18:16.1950922Z: xxx - LoggerBase.cs: === Token Acquisition started:
CacheType: null
Authentication Target: User
, Authority Host: login.microsoftonline.com
DEBUG: [ADAL]: Information: 2020-07-06T12:18:16.1950922Z: xxx - LoggerBase.cs: === Token Acquisition started:
Authority: https://login.microsoftonline.com/xxx/
Resource: https://management.core.windows.net/
ClientId: xxx
CacheType: null
Authentication Target: User
DEBUG: [ADAL]: Verbose: 2020-07-06T12:18:16.1950922Z: xxx - LoggerBase.cs: Loading from cache.
DEBUG: [ADAL]: Verbose: 2020-07-06T12:18:16.1950922Z: xxx - LoggerBase.cs: Loading from cache.
DEBUG: [ADAL]: Information: 2020-07-06T12:18:16.3091158Z: 00000000-0000-0000-0000-000000000000 - LoggerBase.cs: Deserialized 26 items to token cache.
DEBUG: [ADAL]: Verbose: 2020-07-06T12:18:16.3091158Z: xxx - LoggerBase.cs: Looking up cache for a token...
DEBUG: [ADAL]: Verbose: 2020-07-06T12:18:16.3091158Z:xxx - LoggerBase.cs: Looking up cache for a token...
DEBUG: [ADAL]: Information: 2020-07-06T12:18:16.3091158Z: xxx - LoggerBase.cs: An item matching the requested resource was found in the cache
DEBUG: [ADAL]: Information: 2020-07-06T12:18:16.3091158Z: xxx - LoggerBase.cs: An item matching the requested resource was found in the cache
DEBUG: [ADAL]: Information: 2020-07-06T12:18:16.3091158Z: xxx - LoggerBase.cs: An expired or near expiry token was found in the cache
DEBUG: [ADAL]: Information: 2020-07-06T12:18:16.3091158Z: xxx - LoggerBase.cs: An expired or near expiry token was found in the cache
DEBUG: [ADAL]: Information: 2020-07-06T12:18:16.3091158Z: xxx - LoggerBase.cs: A matching item (access token or refresh token or both) was found in the cache
DEBUG: [ADAL]: Information: 2020-07-06T12:18:16.3091158Z: xxx - LoggerBase.cs: A matching item (access token or refresh token or both) was found in the cache
DEBUG: [ADAL]: Verbose: 2020-07-06T12:18:16.3121394Z: xxx - LoggerBase.cs: Refreshing access token...
DEBUG: [ADAL]: Verbose: 2020-07-06T12:18:16.3121394Z: xxx - LoggerBase.cs: Refreshing access token...
DEBUG: [ADAL]: Verbose: 2020-07-06T12:18:16.8245155Z: xxx - LoggerBase.cs: Storing token in the cache...
DEBUG: [ADAL]: Verbose: 2020-07-06T12:18:16.8245155Z: xxx - LoggerBase.cs: Storing token in the cache...
DEBUG: [ADAL]: Verbose: 2020-07-06T12:18:16.8245155Z: xxx - LoggerBase.cs: An item was stored in the cache
DEBUG: [ADAL]: Verbose: 2020-07-06T12:18:16.8245155Z: xxx - LoggerBase.cs: An item was stored in the cache
DEBUG: [ADAL]: Information: 2020-07-06T12:18:16.8265180Z: xxx - LoggerBase.cs: === Token Acquisition finished successfully. An access token was returned: Expiration Time: 06/07/2020 13:18:15 +00:00
DEBUG: [ADAL]: Information: 2020-07-06T12:18:16.8265180Z: xxx - LoggerBase.cs: === Token Acquisition finished successfully. An access token was returned: Expiration Time: 06/07/2020 13:18:15 +00:00Access Token Hash:
xxx8=
User id: xxx
DEBUG: [ADAL]: Information: 2020-07-06T12:18:16.8265180Z: 00000000-0000-0000-0000-000000000000 - LoggerBase.cs: Serializing token cache with 26 items.
Get-AzEventHub : 'eventHubName' exceeds maximum length of '50'.
At line:1 char:1
+ Get-AzEventHub -ResourceGroupName "xxx" -Namespace "xxx...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : CloseError: (:) [Get-AzEventHub], ValidationException
+ FullyQualifiedErrorId : Microsoft.Azure.Commands.EventHub.Commands.EventHub.GetAzureRmEventHub
DEBUG: AzureQoSEvent: CommandName - Get-AzEventHub; IsSuccess - False; Duration - 00:00:00.7686982;; Exception - Microsoft.Rest.ValidationException: 'eventHubName' exceeds maximum length of '50'.
at Microsoft.Azure.Management.EventHub.EventHubsOperations.<GetWithHttpMessagesAsync>d__14.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.Azure.Management.EventHub.EventHubsOperationsExtensions.<GetAsync>d__19.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.Azure.Management.EventHub.EventHubsOperationsExtensions.Get(IEventHubsOperations operations, String resourceGroupName, String namespaceName, String eventHubName)
at Microsoft.Azure.Commands.Eventhub.EventHubsClient.GetEventHub(String resourceGroupName, String namespaceName, String eventHubName)
at Microsoft.Azure.Commands.EventHub.Commands.EventHub.GetAzureRmEventHub.ExecuteCmdlet()
at Microsoft.WindowsAzure.Commands.Utilities.Common.AzurePSCmdlet.ProcessRecord();
DEBUG: Finish sending metric.
DEBUG: 2:18:17 PM - GetAzureRmEventHub end processing.
A colleague has the same issue.
Hey guys, having the same issue here. Now the new module Az.EventHub is also rolled out on Azure DevOps agents and blocks us obtaining the PrimaryConString to configure our microservices accessing the EH.
Any fix in progress or update available on this? Thx
I just found the resource naming restriction and it says, that there is a limitation of 50 characters: https://docs.microsoft.com/en-us/azure/azure-resource-manager/management/resource-name-rules#microsofteventhub
In portal, there is a error message:

Creating a new Event Hub by PowerShell Az Module also throw an error:

But, we are creating the Event Hub via ARM and there the limitation is 256 characters: https://docs.microsoft.com/en-us/azure/event-hubs/event-hubs-quotas
Long story short: In the docus, there are two limitations of the event hub name defined. Is one of the documentation wrong?
BR
We are investigating this issue, and will report back with an update by 11/4/2020.
@serkantkaraca @JamesBirdsall @samuelkoppes Do you have any updates on this issue. @andreasschild Apologies for the delayed response. I see that this issue is opened long time ago and no further activity had taken place. So wanted to check if you are still looking for assistance on this query? Please let us know .
@SaurabhSharma-MSFT: Thanks for comming back to me. I shorten the name of the event hub to 50 characters. With that, the issue was solved. But it would be good if this is documented anywhere.
Hi @andreasschild , Apologies for delay in response here.
I had been reviewing the issue and could conduct some tests, I was able to set the event hub name to be within limit of 256 characters (using Azure Portal, ARM template and PS as well). Below is the snip:
ARM Template:

Portal:
PS:

Portal indeed prompts when we surpass the naming limit during validation phase, here is the snip:
Thus, the limits enforced on all client experiences look to be in the same (1-256 characters long), I would work with the team internally to get the documentation updated.
Please feel free to respond if you observe any discrepant results at your end.
@andreasschild When I used the most recent version of the Az.EventHub I didn't face this issue. This article talks about name limit being 256 characters. Could you please test the behavior with the most recent version of the Az.EventHub? Awaiting your reply.
@andreasschild This docs has been updated with the right character length for the event hub name. see PR #87316 Please let us know if you need any further assistance on this issue.
@navba-MSFT: I tested the method 'Get-AzEventHub' with Az.EventHub Version 1.8.0 and the error message about the limitation of 50 characters are no showing up. With this, I am going to close this issue