Azure / azure-storage-net

Microsoft Azure Storage Libraries for .NET
Apache License 2.0
446 stars 371 forks source link

Append Blob throws "The remote server returned an error: (400) Bad Request." #938

Open bmukes opened 5 years ago

bmukes commented 5 years ago

Which service(blob, file, queue, table) does this issue concern?

Append Blob using Storage Emulator 5.9.0.0

Which version of the SDK was used?

WindowsAzure.Stroage 9.3.3

Which platform are you using? (ex: .NET Core 2.1)

.Net framework 4.7.2 Console Application using HostBuilder

What problem was encountered?

` String customDateTime = String.Format("{0:MM_dd_yyyy_H_mm}", DateTime.Now);

_cloudAppendBlob = container.GetAppendBlobReference($"{customDateTime}{_blobTable.BlobFileName}");

//The resulting name of the blob would be 09_24_2019_12_28_ProcessedCase.csv

AsyncHelper.RunSync(() => _cloudAppendBlob.CreateOrReplaceAsync()); `

All code runs successfully when using Azure cloud storage container.

Regardless of the file name used the call to CreateOrReplaceAsync throws

Exception Message

"The remote server returned an error: (400) Bad Request."

Stack Trace at Microsoft.WindowsAzure.Storage.Core.Executor.Executor.EndExecuteAsync[T](IAsyncResult result) in c:\Program Files (x86)\Jenkins\workspace\release_dotnet_master\Lib\ClassLibraryCommon\Core\Executor\Executor.cs:line 51 at Microsoft.WindowsAzure.Storage.Blob.CloudAppendBlob.EndCreateOrReplace(IAsyncResult asyncResult) in c:\Program Files (x86)\Jenkins\workspace\release_dotnet_master\Lib\ClassLibraryCommon\Blob\CloudAppendBlob.cs:line 2491 at Microsoft.WindowsAzure.Storage.Core.Util.AsyncExtensions.<>cDisplayClass7.b5(IAsyncResult ar) in c:\Program Files (x86)\Jenkins\workspace\release_dotnet_master\Lib\ClassLibraryCommon\Core\Util\AsyncExtensions.cs:line 120 --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Runtime.CompilerServices.TaskAwaiter.GetResult() at InsTech.ForeSight.Azure.Shared.AsyncHelper.RunSync(Func`1 func) at InsTech.Metrics.AzureStorageProcessors.Internal.OutputProcessorCSV.WriteBufferInternalInitialize() at InsTech.Metrics.AzureStorageProcessors.Internal.OutputProcessorCSV.WriteBuffer() at InsTech.Metrics.Extensions.BaseOutputProcessor.ProcessDataTable(IMetricsEntity entity, TableDefinition tabledef, XDocument dataXDocument, ITableBufferProcessor tableBuffer, String tableName) at InsTech.Metrics.Extensions.BaseOutputProcessor.ProcessDataTablesForMetricsEntity(IMetricsEntity entity, TableDefinitions tabledef, XDocument illustrationDataXDocument, XDocument quickViewDataXDocument, ITableBufferProcessor tableBuffer) at InsTech.Metrics.Extensions.BaseOutputProcessor.ProcessMetricsEntity(IMetricsEntity entity, CancellationToken cancellationToken, Int32& recordsProcessed, Int32& errorsDetected, Int32& warningsDetected) at InsTech.Metrics.AzureStorageProcessors.Internal.OutputProcessorBlobStorageCSV.InsTech.Metrics.Extensions.IOutputProcessor.ProcessMetricsEntity(IMetricsEntity entity, CancellationToken cancellationToken, Int32& recordsProcessed, Int32& errorsDetected, Int32& warningsDetected) at MetricsHost.ProcessorFunction.ProcessMetricsEntity(IMetricsEntity entity) in D:\BHF\BHF6\DevB\ForeSight.Services\Metrics\MetricsHost\ProcessorFunction.cs:line 147 at MetricsHost.ProcessorFunction.StartAsync(CancellationToken cancellationToken) in D:\BHF\BHF6\DevB\ForeSight.Services\Metrics\MetricsHost\ProcessorFunction.cs:line 105

Inner Exception

   The remote server returned an error: (400) Bad Request.

Stack Trace at Microsoft.WindowsAzure.Storage.Shared.Protocol.HttpResponseParsers.ProcessExpectedStatusCodeNoException[T](HttpStatusCode expectedStatusCode, HttpStatusCode actualStatusCode, T retVal, StorageCommandBase1 cmd, Exception ex) in c:\Program Files (x86)\Jenkins\workspace\release_dotnet_master\Lib\Common\Shared\Protocol\HttpResponseParsers.Common.cs:line 54 at Microsoft.WindowsAzure.Storage.Blob.CloudAppendBlob.<CreateImpl>b__8f(RESTCommand1 cmd, HttpWebResponse resp, Exception ex, OperationContext ctx) in c:\Program Files (x86)\Jenkins\workspace\release_dotnet_master\Lib\ClassLibraryCommon\Blob\CloudAppendBlob.cs:line 3356 at Microsoft.WindowsAzure.Storage.Core.Executor.Executor.EndGetResponse[T](IAsyncResult getResponseResult) in c:\Program Files (x86)\Jenkins\workspace\release_dotnet_master\Lib\ClassLibraryCommon\Core\Executor\Executor.cs:line 300

pemari-msft commented 5 years ago

Append blobs are not supported by the storage emulator. Please see the emulator docs for the full list of differences between the service and emulator.

XiaoningLiu commented 4 years ago

@bmukes Check Azurite http://github.com/azure/azurite which with Append Blob supports.