Skip to content

Instantly share code, notes, and snippets.

@sredman
Created August 19, 2020 18:07
Show Gist options
  • Save sredman/94add364905d8d312faaaf49893e4e45 to your computer and use it in GitHub Desktop.
Save sredman/94add364905d8d312faaaf49893e4e45 to your computer and use it in GitHub Desktop.
A minimum-viable-reproduction of a StackOverflowException in Microsoft.Azure.Storage.Blob's CloudBlockBlob.UploadFromStream
using Microsoft.Azure.Storage;
using Microsoft.Azure.Storage.Auth;
using Microsoft.Azure.Storage.Blob;
using System;
using System.IO;
namespace DotNetFrameworkStorageStackOverflow
{
class Program
{
static void Main(string[] args)
{
string bacpacName = @"7GB-urandom.junk";
string filePath = @"E:\" + bacpacName;
string accountName = "sqlfunctionaltest";
string storageKey = "";
StorageUri storageUri = new StorageUri(new Uri($"https://{accountName}.blob.core.windows.net/"));
string containerName = "container";
StorageCredentials credentials = new StorageCredentials(accountName, storageKey);
CloudBlobClient blobClient = new CloudBlobClient(storageUri, credentials);
CloudBlobContainer container = blobClient.GetContainerReference(containerName);
CloudBlockBlob targetBlob = container.GetBlockBlobReference(bacpacName);
using (Stream content = new FileStream(filePath, FileMode.Open, FileAccess.Read))
{
long size = content.Length;
targetBlob.UploadFromStream(content);
}
Console.WriteLine("Blob uploaded successfully, press enter to continue");
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment