0
votes

So right now I have a requirement to upload files directly to Azure Blob from a file server instead of using a stream in a background job. Is there anyway to upload directly to azure from a remote location given a url? Everything I see in the SDK requires the use of some form of a stream. I want to remove the service application as the middleman and let azure upload the file automatically. I couldn't find anyway to do this, nor a stack overflow answer.

Alternative Solutions Using powershell to upload directly to azure blob. Having a specific directory act as like a queue, and any files placed there will be uploaded to azure blob from the file server. Then the background job will do what it needs to from there...

1
AZCopy does it: docs.microsoft.com/en-us/azure/storage/common/… so there has to be a way.Andy
Is the URL of the file publicly available?Gaurav Mantri
It is a Url that is only routable from within our network but azure has access through VPN.Grim

1 Answers

1
votes

As Andy mentioned in the comments, you can use azcopy to accomplish it.

You can refer to this official documentation:

https://docs.microsoft.com/en-us/azure/storage/common/storage-ref-azcopy-copy

The grammatical form is like this:

azcopy cp [source] [destination] [flags]

Update:

I am using the Azure.Storage.Blobs SDK.

            BlobServiceClient blobServiceClient = new BlobServiceClient(connectionString);

            BlobContainerClient containerClient = blobServiceClient.GetBlobContainerClient(containerName);
            BlobClient blobClient = containerClient.GetBlobClient(fileName);
            var sourceUri = new Uri("<your-uri>");
            blobClient.StartCopyFromUri(sourceUri);