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.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Yateesha G110 reputationPosted Jun 25, 2021, 6:15 AM EDT
Radhika B19 reputationPosted Jun 25, 2021, 8:00 AM EDT
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
?
Yateesha G110 reputationPosted Jun 25, 2021, 11:06 AM EDT
Radhika B19 reputationPosted Jun 28, 2021, 4:54 AM EDT
Radhika B19 reputationPosted Jun 28, 2021, 6:53 AM EDT
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=*"
Yateesha G110 reputationPosted Jun 28, 2021, 10:46 PM EDT
Yateesha G110 reputationPosted Jun 28, 2021, 11:08 PM EDT
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);
}