Hi Team,
I have to build .net console application in such a way that i need to pick file from source and push to Microsoft Storage Explorer(BLOB).
Could you please provide sample console applications to achieve this task.
Regards,
Radhika
Hi Team,
I have to build .net console application in such a way that i need to pick file from source and push to Microsoft Storage Explorer(BLOB).
Could you please provide sample console applications to achieve this task.
Regards,
Radhika
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Yateesha GPosted Jun 25, 2021, 10:15 AM
Yateesha GPosted Jun 29, 2021, 3:08 AM
If you are already having IFormFile then no need of file location
you can try with one of the overload method of blob.Upload(@"D:\" + systemFileName); to upload stream insead of file location.
using (var data = files.OpenReadStream())
{
blob.Upload(data);
}
Yateesha GPosted Jun 29, 2021, 2:46 AM
Radhika BPosted Jun 28, 2021, 10:53 AM
I have changed c drive to D drive i am getting below error @ -- blob.Upload(@"D:\" + systemFileName); //File location
FileController.cs
public IActionResult UploadFile(IFormFile files)
{
string systemFileName = files.FileName;
Uri url = new Uri("https://abcdef.blob.core.windows.net/fsdfsdf"); // SAS Connection String
var storageSharedKeyCredential = new StorageSharedKeyCredential("RRR", "CCdfsfrgrgghrh="); //AccountName, AccountKey
BlobContainerClient container = new BlobContainerClient(url, storageSharedKeyCredential);
BlobClient blob = container.GetBlobClient(systemFileName);
blob.Upload(@"D:\" + systemFileName); //File location
return Ok("File Uploaded Successfully");
}
appsettings.json:
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft": "Warning",
"Microsoft.Hosting.Lifetime": "Information"
}
},
"AllowedHosts": "*",
"BlobConnectionString": "*BlobEndpoint=https://abcdef.blob.core.windows.net/fsdfsdf*",
"BlobContainerName": "*rertwet-import*",
"AccountName": "*RRR*",
"AccountKey": "*CCdfsfrgrgghrh=*"
Radhika BPosted Jun 28, 2021, 8:54 AM
Yateesha GPosted Jun 25, 2021, 3:06 PM
Radhika BPosted Jun 25, 2021, 12:00 PM
HI Yateesha, Thank you for the reply.
?
I am using SAS Connection String in Microsoft Azure Storage Explorer and Visual Studio ASP.Net Core Web API .Net 5 framework
Connection string:
"BlobConnectionString": "*https://storagesample.blob.core.windows.net/*",
"BlobContainerName": "*import*"
When i tried to upload csv file it is throwing error at below line:
CloudStorageAccount cloudStorageAccount = CloudStorageAccount.Parse(blobstorageconnection);
Could you please let me know which File Location we need to give either local path OR blob
?