Home > Net >  Failed to create the task hub: DurableTask.AzureStorage.Storage.DurableTaskStorageException
Failed to create the task hub: DurableTask.AzureStorage.Storage.DurableTaskStorageException

Time:03-30

I have migrated my Azure functions project from .Net Core 2.2 to .Net Core 3.1. So, I have also updated other nuget packages to support .Net Core 3.1. After that, when I run my functions project it loads all the functions and after loading it fails continuously with below error.

General error: Failed to create the task hub: DurableTask.AzureStorage.Storage.DurableTaskStorageException: The response ended prematurely, with at least 93 additional bytes expected.
[2022-03-28T14:37:38.222Z] ---> Microsoft.WindowsAzure.Storage.StorageException: The response ended prematurely, with at least 93 additional bytes expected.
[2022-03-28T14:37:38.225Z] ---> System.IO.IOException: The response ended prematurely, with at least 93 additional bytes expected.
[2022-03-28T14:37:38.226Z] at System.Net.Http.HttpConnection.ContentLengthReadStream.ReadAsync(Memory1 buffer, CancellationToken cancellationToken) [2022-03-28T14:37:38.228Z] at Microsoft.WindowsAzure.Storage.Core.Util.StreamExtensions.WriteToAsync[T](Stream stream, Stream toStream, IBufferManager bufferManager, Nullable1 copyLength, Nullable1 maxLength, Boolean calculateMd5, ExecutionState1 executionState, StreamDescriptor streamCopyState, CancellationToken token)
[2022-03-28T14:37:38.230Z] at Microsoft.WindowsAzure.Storage.Core.Executor.Executor.ExecuteAsyncInternal[T](RESTCommand1 cmd, IRetryPolicy policy, OperationContext operationContext, CancellationToken token) [2022-03-28T14:37:38.232Z] --- End of inner exception stack trace --- [2022-03-28T14:37:38.233Z] at Microsoft.WindowsAzure.Storage.Core.Executor.Executor.ExecuteAsyncInternal[T](RESTCommand1 cmd, IRetryPolicy policy, OperationContext operationContext, CancellationToken token)
[2022-03-28T14:37:38.235Z] at Microsoft.WindowsAzure.Storage.Blob.CloudBlob.DownloadRangeToStreamAsync(Stream target, Nullable1 offset, Nullable1 length, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, IProgress1 progressHandler, CancellationToken cancellationToken) [2022-03-28T14:37:38.237Z] at Microsoft.WindowsAzure.Storage.Blob.CloudBlockBlob.DownloadTextAsync(Encoding encoding, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, IProgress1 progressHandler, CancellationToken cancellationToken)
[2022-03-28T14:37:38.241Z] at DurableTask.AzureStorage.TimeoutHandler.ExecuteWithTimeout[T](String operationName, String account, AzureStorageOrchestrationServiceSettings settings, Func3 operation, AzureStorageOrchestrationServiceStats stats, String clientRequestId) [2022-03-28T14:37:38.243Z] at DurableTask.AzureStorage.Storage.AzureStorageClient.MakeStorageRequest[T](Func3 storageRequest, String accountName, String operationName, String clientRequestId) in //src/DurableTask.AzureStorage/Storage/AzureStorageClient.cs:line 133
[2022-03-28T14:37:38.245Z] Request Information
[2022-03-28T14:37:38.246Z] RequestID:e48ed975-d669-4f3e-a24e-bee26fe21569
[2022-03-28T14:37:38.248Z] RequestDate:Mon, 28 Mar 2022 10:37:33 GMT
[2022-03-28T14:37:38.249Z] StatusMessage:InternalServerError
[2022-03-28T14:37:38.250Z] ErrorCode:
[2022-03-28T14:37:38.252Z]
[2022-03-28T14:37:38.253Z] --- End of inner exception stack trace ---
[2022-03-28T14:37:38.256Z] at DurableTask.AzureStorage.Storage.AzureStorageClient.MakeStorageRequest[T](Func`3 storageRequest, String accountName, String operationName, String clientRequestId) in //src/DurableTask.AzureStorage/Storage/AzureStorageClient.cs:line 137
[2022-03-28T14:37:38.258Z] at DurableTask.AzureStorage.Storage.Blob.DownloadTextAsync() in //src/DurableTask.AzureStorage/Storage/Blob.cs:line 91
[2022-03-28T14:37:38.260Z] at DurableTask.AzureStorage.Partitioning.BlobLeaseManager.GetTaskHubInfoAsync() in //src/DurableTask.AzureStorage/Partitioning/BlobLeaseManager.cs:line 315
[2022-03-28T14:37:38.262Z] at DurableTask.AzureStorage.Partitioning.BlobLeaseManager.GetOrCreateTaskHubInfoAsync(TaskHubInfo newTaskHubInfo, Boolean checkIfStale) in //src/DurableTask.AzureStorage/Partitioning/BlobLeaseManager.cs:line 266
[2022-03-28T14:37:38.263Z] at DurableTask.AzureStorage.Partitioning.BlobLeaseManager.CreateLeaseStoreIfNotExistsAsync(TaskHubInfo eventHubInfo, Boolean checkIfStale) in //src/DurableTask.AzureStorage/Partitioning/BlobLeaseManager.cs:line 70
[2022-03-28T14:37:38.265Z] at DurableTask.AzureStorage.AzureStorageOrchestrationService.GetTaskHubCreatorTask() in //src/DurableTask.AzureStorage/AzureStorageOrchestrationService.cs:line 308
[2022-03-28T14:37:38.267Z] at DurableTask.AzureStorage.AzureStorageOrchestrationService.EnsureTaskHubAsync() in //src/DurableTask.AzureStorage/AzureStorageOrchestrationService.cs:line 285
[2022-03-28T14:37:38.425Z] Starting task hub worker. InstanceId: . Function: . HubName: CdpRefreshHub. AppName: . SlotName: . ExtensionVersion: 2.6.1. SequenceNumber: 1.
[2022-03-28T14:37:38.441Z] The listener for function 'ExecuteGetCommissioningAsync' was unable to start.
[2022-03-28T14:37:38.443Z] The listener for function 'ExecuteGetCommissioningAsync' was unable to start. DurableTask.AzureStorage: The response ended prematurely, with at least 93 additional bytes expected. Microsoft.WindowsAzure.Storage: The response ended prematurely, with at least 93 additional bytes expected. System.Net.Http: The response ended prematurely, with at least 93 additional bytes expected.
[2022-03-28T14:37:40.458Z] Retrying to start listener for function 'ExecuteGetCommissioningAsync' (Attempt 1)

.csproj file (Before)

<PropertyGroup>
    <TargetFramework>netcoreapp2.2</TargetFramework>
    <AzureFunctionsVersion>v2</AzureFunctionsVersion>
  </PropertyGroup>
  <ItemGroup>
    <PackageReference Include="Common1" Version="1.0.21" />
    <PackageReference Include="Common2" Version="3.12.0.1" />
    <PackageReference Include="Microsoft.Azure.Functions.Extensions" Version="1.0.0" />
    <PackageReference Include="Microsoft.Azure.WebJobs.Extensions.DurableTask" Version="1.8.7" />
    <PackageReference Include="Microsoft.Extensions.Configuration.AzureKeyVault" Version="2.2.0" />
    <PackageReference Include="Microsoft.Extensions.Http" Version="2.2.0" />
    <PackageReference Include="Microsoft.Extensions.Logging.Console" Version="2.2.0" />
    <PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="2.2.0" />
    <PackageReference Include="Microsoft.NET.Sdk.Functions" Version="1.0.29" />
  </ItemGroup>

.csproj file(after)

<PropertyGroup>
    <TargetFramework>netcoreapp3.1</TargetFramework>
    <AzureFunctionsVersion>v3</AzureFunctionsVersion>
  </PropertyGroup>
  <ItemGroup>
    <PackageReference Include="Common1" Version="1.0.33.3" />
    <PackageReference Include="Common2" Version="3.12.1.4" />
    <PackageReference Include="Microsoft.Azure.Functions.Extensions" Version="1.1.0" />
    <PackageReference Include="Microsoft.Azure.WebJobs.Extensions.DurableTask" Version="2.5.1" />
    <PackageReference Include="Microsoft.Extensions.Configuration.AzureKeyVault" Version="3.1.18" />
    <PackageReference Include="Microsoft.Extensions.Http" Version="3.1.18" />
    <PackageReference Include="Microsoft.Extensions.Logging.Console" Version="3.1.18" />
    <PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="3.1.18" />
    <PackageReference Include="Microsoft.NET.Sdk.Functions" Version="3.0.13" />
  </ItemGroup>

CodePudding user response:

I have created .NET Core 2.2 Azure Functions Project (Http Trigger) and added the same NuGet Packages along with the same versions provided.

And migrated to .NET Core 3.1 with the same NuGet versioned Packages provided but in the local.settings.json file, replaced the AzureWebJobsStorage value from local storage to Azure Storage Account Connection String.

With the local storage emulator ("AzureWebJobsStorage": "UseDevelopmentStorage=true"), it didn't work.

I believe that the error is due to storage connection string mismatch from the given error details.

Result:

enter image description here

  • Related