Skip to content

Instantly share code, notes, and snippets.

Last active Nov 27, 2020
What would you like to do?
Automatically download files to Azure Blob Storage using Copy From URL API with C#
using Azure.Storage.Blobs;
using System;
using System.IO;
using System.Threading.Tasks;
namespace ConsoleApp2
class Program
// Required .NET Package: Azure.Storage.Blobs version >=12
// API Docs:
static async Task Main(string[] args)
string connectionString = Environment.GetEnvironmentVariable("AZURE_CONNECTION_STRING", EnvironmentVariableTarget.Process);
var filesToProcess = new[] {
"", // ~200MB
"", // ~295MB
"" // ~3GB
Console.WriteLine("Copying Blob from URL (size limited to 250MB (?) )");
BlobServiceClient blobServiceClient = new BlobServiceClient(connectionString);
string containerName = $"data-{DateTime.UtcNow:yyyyMMddHHmm}";
BlobContainerClient containerClient = await blobServiceClient.CreateBlobContainerAsync(containerName);
await containerClient.CreateIfNotExistsAsync();
foreach (var fileToProcess in filesToProcess)
string fileName = Path.GetFileName(fileToProcess);
var blobClient = containerClient.GetBlobClient(fileName);
blobClient.StartCopyFromUri(new Uri(fileToProcess));
Console.WriteLine($"Operation started. Closing application.");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment