question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

AppendBlock from azure-sdk-for-go v50.1.0 doesn't work

See original GitHub issue

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

Blob

Which version of the Azurite was used?

Latest (v3.10.0)

Where do you get Azurite? (npm, DockerHub, NuGet, Visual Studio Code Extension)

DockerHub (mcr.microsoft.com/azure-storage/azurite:3.10.0)

What’s the Node.js version?

Whatever the mcr.microsoft.com/azure-storage/azurite:3.10.0 docker container is running

What problem was encountered?

Blob. AppendBlock from github.com/Azure/azure-sdk-for-go v3.10.0 fails with error: Content-Length must be 0 for Create Append Blob request.

Steps to reproduce the issue?

Run the following code:

package main

import (
	"log"
	"time"

	"github.com/Azure/azure-sdk-for-go/storage"
	"github.com/ory/dockertest/v3"
	"github.com/ory/dockertest/v3/docker"
)

// RunAzurite starts an azurite container
func RunAzurite(pool *dockertest.Pool) (*dockertest.Resource, error) {
	opts := dockertest.RunOptions{
		Repository:   "mcr.microsoft.com/azure-storage/azurite",
		Tag:          "3.10.0",
		ExposedPorts: []string{"10000"},
		PortBindings: map[docker.Port][]docker.PortBinding{
			"10000": {{HostIP: "0.0.0.0", HostPort: "10000"}},
		},
	}
	azurite, err := pool.RunWithOptions(&opts)
	if err != nil {
		return nil, err
	}
	if eerr := azurite.Expire(10); eerr != nil {
		return nil, eerr
	}
	pool.MaxWait = 10 * time.Second
	rerr := pool.Retry(func() error {
		client, eerr := storage.NewEmulatorClient()
		if eerr != nil {
			return eerr
		}
		s := client.GetBlobService()
		c := s.GetContainerReference("cont")
		if _, err = c.Exists(); err != nil {
			return err
		}
		return nil
	})
	return azurite, rerr
}

func main() {
	pool, err := dockertest.NewPool("")
	if err != nil {
		log.Fatalf("Failed to create dockertest pool: %s", err)
	}

	azurite, err := RunAzurite(pool)
	defer pool.Purge(azurite)

	if err != nil {
		log.Fatalf("Failed to start Azurite: %s", err)
	}

	client, err := storage.NewEmulatorClient()
	if err != nil {
		log.Fatalf("Failed to create storage client: %s", err)
	}

	blobClient := client.GetBlobService()
	dummyContainer := "foobar"
	containerRef := blobClient.GetContainerReference(dummyContainer)

	err = containerRef.Create(nil)
	if err != nil {
		log.Fatalf("Failed to create container: %s", err)
	}

	blobRef := containerRef.GetBlobReference("test.txt")

	err = blobRef.PutAppendBlob(nil)
	if err != nil {
		log.Fatalf("Failed to create append blob: %s", err)
	}

	dummyData := "deadbeef"
	err = blobRef.AppendBlock([]byte(dummyData), nil)
	if err != nil {
		log.Fatalf("Failed to write to append blob: %s", err)
	}

	log.Print("That's all folks!")
}

This check seems to be the root cause.

Have you found a mitigation/solution?

I guess it works with github.com/azure/azure-storage-blob-go but I can’t use it because it doesn’t yet come with support for connection strings (see Azure/azure-storage-blob-go#211 and Azure/azure-storage-blob-go#244).

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
bluewwcommented, Feb 10, 2021

The fix is already released in v3.11.0.

0reactions
mihaitodorcommented, Feb 5, 2021

@blueww Thanks for the feedback! Unfortunately, as mentioned before, it’s not (yet) feasible to upgrade to the new Go SDK because it doesn’t have support for connection strings

I have opened #698 to skip this check when the --loose flag is set.

Read more comments on GitHub >

github_iconTop Results From Across the Web

No results found

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found