Öncelikle Azure’da Depolama Hesabı açılır.
Ardından bu hesaba bağlanabilmek için ConnectionString bilgisini alıyoruz.
public void FileUpload(string fileName, HttpPostedFileBase file)
{
string strorageconn = "Aldığımız ConnectionString bilgisi”;
CloudStorageAccount storageacc = CloudStorageAccount.Parse(strorageconn);
//Create Reference to Azure Blob
CloudBlobClient blobClient = storageacc.CreateCloudBlobClient();
//The next 2 lines create if not exists a container named "democontainer”
CloudBlobContainer container = blobClient.GetContainerReference("Container Adı”);
container.CreateIfNotExists();
//The next 2 lines upload the file test.txt with the name DemoBlob on the container "democontainer”
CloudBlockBlob blockBlob = container.GetBlockBlobReference(fileName);
blockBlob.UploadFromStream(file.InputStream);
}
