Reputation: 2097
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...
Upvotes: 0
Views: 528
Reputation: 6816
As Andy
mentioned in the comments, you can use azcopy
to accomplish it.
You can refer to this official documentation:
https://learn.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);
Upvotes: 1