XmlException when uploading file
See original GitHub issueWhich service(blob, file, queue, table) does this issue concern?
blob
Which version of the Azurite was used?
3.10
Where do you get Azurite? (npm, DockerHub, NuGet, Visual Studio Code Extension)
DockerHub, npm
What’s the Node.js version?
15.8.0 with npm, in docker the same as in the image
What problem was encountered?
When calling BlobContainerClient.UploadBlobAsync() the following exception is thrown:
System.Xml.XmlException
Root element is missing.
at System.Xml.XmlTextReaderImpl.Throw(Exception e)
at System.Xml.XmlTextReaderImpl.ParseDocumentContent()
at System.Xml.XmlTextReaderImpl.Read()
at System.Xml.Linq.XDocument.Load(XmlReader reader, LoadOptions options)
at System.Xml.Linq.XDocument.Load(Stream stream, LoadOptions options)
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 ---
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.Storage.Blobs.BlobContainerClient.UploadBlobAsync(String blobName, Stream content, CancellationToken cancellationToken)
at BimVisualizer.Server.Tests.AzuriteTests.CanUploadFile() in D:\bimvisualizer\BimVisualizer.Server.Tests\AzuriteTests.cs:line 59
at Xunit.Sdk.TestInvoker`1.<>c__DisplayClass48_1.<<InvokeTestMethodAsync>b__1>d.MoveNext() in C:\Dev\xunit\xunit\src\xunit.execution\Sdk\Frameworks\Runners\TestInvoker.cs:line 264
--- End of stack trace from previous location ---
at Xunit.Sdk.ExecutionTimer.AggregateAsync(Func`1 asyncAction) in C:\Dev\xunit\xunit\src\xunit.execution\Sdk\Frameworks\ExecutionTimer.cs:line 48
at Xunit.Sdk.ExceptionAggregator.RunAsync(Func`1 code) in C:\Dev\xunit\xunit\src\xunit.core\Sdk\ExceptionAggregator.cs:line 90
Steps to reproduce the issue?
I did this while testing if I can use azurite in a unit testing environment. I tried both with setting up azurite with npm and with a nuget which spins up a docker container for each test case, with a custom port, then discards it. Both of them resulted in the same exception
[Fact]
public async Task CanUploadFile()
{
// Arrange
// this is the default connection string
var connectionString = Sp.GetRequiredService<IOptions<AzureStorageOptions>>().Value.ConnectionString;
var blobServiceClient = new BlobServiceClient(connectionString);
const string testContainerName = "TestBlob";
var containerResponse = await blobServiceClient.CreateBlobContainerAsync(testContainerName);
// Act
var client = containerResponse.Value;
var message = new MemoryStream(Encoding.Default.GetBytes("Hello"));
// Exception is thrown here
await client.UploadBlobAsync("HelloFile.txt", message);
await message.DisposeAsync();
// Assert
await using var result = new MemoryStream();
using var reader = new StreamReader(result);
await client.GetBlobClient("HelloFile.txt").DownloadToAsync(result);
(await reader.ReadToEndAsync()).Should().Be("Hello");
}
connection string:
DefaultEndpointsProtocol=http;AccountName=devstoreaccount1;AccountKey=Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw==;BlobEndpoint=http://localhost:12000/devstoreaccount1;
Azurite is using the correct port
Have you found a mitigation/solution?
No
Issue Analytics
- State:
- Created 3 years ago
- Comments:6 (2 by maintainers)
Top Results From Across the Web
xml - C# XmlException because of file name - Stack Overflow
I am working on a launcher/updater for a game. the updater get's it's data from an xml file on a server. Up til...
Read more >MONO System.Xml.XmlException: Data at the root level is invalid ...
I have written an application that the user can upload an excel file through angular to my c# web API, I then save...
Read more >XmlException / InvalidOperationException Issue - Google Groups
I am trying to use the AdWords API to upload some images stored locally on ... I was originally working from a web.config...
Read more >An error occurred while parsing EntityName in TMS
XmlException : An error occurred while parsing EntityName in TMS ... There are two possible fixes depending on the root cause: 1.) Invalid...
Read more >400 when uploading a maven pom file - Visual Studio Feedback
400 Bad Request - System.Xml.XmlException: Invalid character in the given encoding. Line 1, position 1. This only started happening in the last 24h....
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Close this issue per @KuraiAndras suggestion. @z77ma You can still attach the debug is if it still can repro on the latest Azurite version. And we will still look at it.
Sadly, no. We ended up not using Azurite and manually testing every major functionality of our project (Luckily it was jut a server with 5-10 endpoints). We created a storage account for all of our teammates, and everyone set up their own account for running the server locally. Not an ideal solution for bigger projects, but in our case it was feasible.