The specified resource name contains invalid character
chandde opened this issue · comments
Chandler Deng commented
Which service(blob, file, queue, table) does this issue concern?
Blob
Which version of the SDK was used?
PackageReference Include="Azure.Storage.Blobs" Version="12.8.0"
Which platform are you using? (ex: .NET Core 2.1)
.NET Core 3.1
What problem was encountered?
Called the blob API to upload file, the given file name is a hash string from original file name, something like this, and the code throws expcetions, callstack and error are attached below.
F578CA54A381BE3C01B619B127E11BEA947296D0571CE58255F8C029A7FCA471
fail: Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddleware[1]
An unhandled exception has occurred while executing the request.
Azure.RequestFailedException: The specifed resource name contains invalid characters.
RequestId:4ba006a1-101e-0005-6da2-0b2a1e000000
Time:2021-02-25T18:14:57.1640443Z
Status: 400 (The specifed resource name contains invalid characters.)
ErrorCode: InvalidResourceName
Headers:
Server: Windows-Azure-Blob/1.0,Microsoft-HTTPAPI/2.0
x-ms-request-id: 4ba006a1-101e-0005-6da2-0b2a1e000000
x-ms-client-request-id: dc6bd837-0a23-404e-8995-f237add78ed0
x-ms-version: 2020-04-08
x-ms-error-code: InvalidResourceName
Date: Thu, 25 Feb 2021 18:14:56 GMT
Content-Length: 243
Content-Type: application/xml
at Azure.Storage.Blobs.BlobRestClient.BlockBlob.UploadAsync_CreateResponse(ClientDiagnostics clientDiagnostics, Response response)
at Azure.Storage.Blobs.BlobRestClient.BlockBlob.UploadAsync(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, Uri resourceUri, Stream body, Int64 contentLength, String version, Nullable`1 timeout, Byte[] transactionalContentHash, String blobContentType, String blobContentEncoding, String blobContentLanguage, Byte[] blobContentHash, String blobCacheControl, IDictionary`2 metadata, String leaseId, String blobContentDisposition, String encryptionKey, String encryptionKeySha256, Nullable`1 encryptionAlgorithm, String encryptionScope, Nullable`1 tier, Nullable`1 ifModifiedSince, Nullable`1 ifUnmodifiedSince, Nullable`1 ifMatch, Nullable`1 ifNoneMatch, String ifTags, String requestId, String blobTagsString, Boolean async, String operationName, CancellationToken cancellationToken)
at Azure.Storage.Blobs.Specialized.BlockBlobClient.UploadInternal(Stream content, BlobHttpHeaders blobHttpHeaders, IDictionary`2 metadata, IDictionary`2 tags, BlobRequestConditions conditions, Nullable`1 accessTier, IProgress`1 progressHandler, String operationName, Boolean async, CancellationToken cancellationToken)
at Azure.Storage.Blobs.Specialized.BlockBlobClient.<>c__DisplayClass54_0.<<GetPartitionedUploaderBehaviors>b__0>d.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at Azure.Storage.PartitionedUploader`2.UploadInternal(Stream content, TServiceSpecificArgs args, IProgress`1 progressHandler, Boolean async, CancellationToken cancellationToken)
at Azure.Storage.Blobs.BlobClient.StagedUploadInternal(Stream content, BlobUploadOptions options, Boolean async, CancellationToken cancellationToken)
at Azure.Core.Pipeline.TaskExtensions.EnsureCompleted[T](Task`1 task)
at Azure.Storage.Blobs.BlobClient.Upload(Stream content, BlobHttpHeaders httpHeaders, IDictionary`2 metadata, BlobRequestConditions conditions, IProgress`1 progressHandler, Nullable`1 accessTier, StorageTransferOptions transferOptions, CancellationToken cancellationToken)
at Azure.Storage.Blobs.BlobClient.Upload(Stream content, Boolean overwrite, CancellationToken cancellationToken)
at Azure.Storage.Blobs.BlobClient.Upload(Stream content, CancellationToken cancellationToken)
at Azure.Storage.Blobs.BlobContainerClient.UploadBlob(String blobName, Stream content, CancellationToken cancellationToken)
at MainService.AzureWorker.UploadFile(String filename, Stream content) in /home/dengydongn/misc/MyDrive/MyDrive/AzureWorker.cs:line 33
at MainService.MiddleTier.Repository.CreateFileAsync(HttpContext httpContext) in /home/dengydongn/misc/MyDrive/MyDrive/MiddleTier/Repository.cs:line 311
at MainService.Controllers.FileController.UploadFile() in /home/dengydongn/misc/MyDrive/MyDrive/Controllers/FileController.cs:line 91
at lambda_method(Closure , Object )
at Microsoft.Extensions.Internal.ObjectMethodExecutorAwaitable.Awaiter.GetResult()
at Microsoft.AspNetCore.Mvc.Infrastructure.ActionMethodExecutor.TaskOfActionResultExecutor.Execute(IActionResultTypeMapper mapper, ObjectMethodExecutor executor, Object controller, Object[] arguments)
at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.<InvokeActionMethodAsync>g__Awaited|12_0(ControllerActionInvoker invoker, ValueTask`1 actionResultValueTask)
at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.<InvokeNextActionFilterAsync>g__Awaited|10_0(ControllerActionInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Rethrow(ActionExecutedContextSealed context)
at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.<InvokeInnerFilterAsync>g__Awaited|13_0(ControllerActionInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeFilterPipelineAsync>g__Awaited|19_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeAsync>g__Awaited|17_0(ResourceInvoker invoker, Task task, IDisposable scope)
at Microsoft.AspNetCore.Routing.EndpointMiddleware.<Invoke>g__AwaitRequestTask|6_0(Endpoint endpoint, Task requestTask, ILogger logger)
at MainService.ContextMiddleware.Invoke(HttpContext httpContext, Authentication auth, MySqlContext db) in /home/dengydongn/misc/MyDrive/MyDrive/ContextMiddleware.cs:line 27
at Microsoft.AspNetCore.Authorization.AuthorizationMiddleware.Invoke(HttpContext context)
at Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddleware.<Invoke>g__Awaited|6_0(ExceptionHandlerMiddleware middleware, HttpContext context, Task task)
Azure.RequestFailedException: The specifed resource name contains invalid characters.
RequestId:4ba006a1-101e-0005-6da2-0b2a1e000000
Time:2021-02-25T18:14:57.1640443Z
Status: 400 (The specifed resource name contains invalid characters.)
ErrorCode: InvalidResourceName
How can we reproduce the problem in the simplest way?
use Blob SDK to upload a file with the sample file name I provided above
Have you found a mitigation/solution?
No
Chandler Deng commented
Closing this issue, I got my container name wrong...