Export from data base to browser can be done very easily without any database using below method
In you asp.net web api project, in the method
a- import data into local DTO List
b- Convert that to CSV string
c- Return with mime type CSV
To export files to Azure Blob Storage from your .NET web application, you will need to use the Azure Blob Storage client library for .NET.
You can install this library by adding the "Azure.Storage.Blobs" NuGet package to your project.
Here is some sample code that shows how to create a Blob container, upload a file to it, and generate a shared access signature (SAS) URI for the uploaded file. This sample code assumes that you have already obtained the file to upload and have its file path in a variable called filePath
. You will also need to replace the connection string and container and file names with the appropriate values for your storage account.
using Azure.Storage.Blobs;
using Azure.Storage.Blobs.Models;
using Azure.Storage.Sas;
// Get a reference to your storage account
string connectionString = "DefaultEndpointsProtocol=https;AccountName=myaccount;AccountKey=mykey;EndpointSuffix=core.windows.net";
BlobServiceClient blobServiceClient = new BlobServiceClient(connectionString);
// Create a Blob container to store your files
string containerName = "mycontainer";
BlobContainerClient containerClient = await blobServiceClient.CreateBlobContainerAsync(containerName);
// Upload a file to the container
string fileName = "myfile.xlsx";
BlobClient blobClient = containerClient.GetBlobClient(fileName);
using (var fileStream = File.OpenRead(filePath))
{
await blobClient.UploadAsync(fileStream, new BlobUploadOptions { HttpHeaders = new BlobHttpHeaders { ContentType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" } });
}
// Generate a SAS URI for the uploaded file
var sasBuilder = new BlobSasBuilder
{
BlobContainerName = containerName,
BlobName = fileName,
Resource = "b",
ExpiresOn = DateTimeOffset.UtcNow.AddHours(1)
};
sasBuilder.SetPermissions(BlobSasPermissions.Read);
string sasUri = blobClient.GenerateSasUri(sasBuilder);