<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Alexander-Cojti</title>
    <description>The latest articles on DEV Community by Alexander-Cojti (@alexandercojti).</description>
    <link>https://dev.to/alexandercojti</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F278372%2F95bf265e-8c96-47d4-8001-a0d87155c4ec.png</url>
      <title>DEV Community: Alexander-Cojti</title>
      <link>https://dev.to/alexandercojti</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/alexandercojti"/>
    <language>en</language>
    <item>
      <title>Download File from Blob-Storage .net core Azure Function C#</title>
      <dc:creator>Alexander-Cojti</dc:creator>
      <pubDate>Sat, 23 Nov 2019 21:28:56 +0000</pubDate>
      <link>https://dev.to/alexandercojti/download-file-from-blob-storage-net-core-azure-function-c-200a</link>
      <guid>https://dev.to/alexandercojti/download-file-from-blob-storage-net-core-azure-function-c-200a</guid>
      <description>&lt;p&gt;Couple days ago I tried to use Azure Function to build an API manipulating "blob storage operations CRUD", I having investigated a solution to solve the download operation, since the majority internet solutions I found work it locally but while deploy my function the Web server needs the grant permission path to Create File and download locally which generated the error:"Access to path is denied". Then I Solved download via HTTP response whit Azure function V2, C# .net core 2.1 This is the basic code it works me, I hope it helps you...&lt;/p&gt;

&lt;p&gt;using System.Threading.Tasks;&lt;br&gt;
using Microsoft.Azure.WebJobs;&lt;br&gt;
using Microsoft.Azure.WebJobs.Extensions.Http;&lt;br&gt;
using Microsoft.AspNetCore.Http;&lt;br&gt;
using Microsoft.WindowsAzure.Storage;&lt;br&gt;
using Microsoft.WindowsAzure.Storage.Blob;&lt;br&gt;
using Microsoft.WindowsAzure.Storage.Auth;&lt;br&gt;
using System.IO;&lt;br&gt;
using System.Net.Http.Headers;&lt;br&gt;
using System.Net.Http;&lt;br&gt;
using System.Net;&lt;/p&gt;

&lt;p&gt;namespace BloApi&lt;br&gt;
{&lt;br&gt;
    public static class BlobOperations&lt;br&gt;
    {&lt;br&gt;
        [FunctionName("DownloadBlob")]&lt;br&gt;
        public static async Task DownloadBlob(&lt;br&gt;
          [HttpTrigger(AuthorizationLevel.Anonymous, "get", Route = "DownloadBlob/{name}")] HttpRequest req, string name)&lt;br&gt;
        {&lt;br&gt;
            StorageCredentials storageCredentials = new StorageCredentials("Storage",&lt;br&gt;
                "CamEKgqVaylmQ.....ow2VHlyCww==");&lt;br&gt;
            CloudStorageAccount storageAccount = new CloudStorageAccount(storageCredentials, true);&lt;br&gt;
            CloudBlobContainer container = storageAccount.CreateCloudBlobClient().GetContainerReference("BlobContainer");&lt;br&gt;
            var blobName = name;&lt;br&gt;
            CloudBlockBlob block = container.GetBlockBlobReference(blobName);&lt;br&gt;
            HttpResponseMessage message = new HttpResponseMessage(HttpStatusCode.OK);&lt;br&gt;
            Stream blobStream = await block.OpenReadAsync();&lt;br&gt;
            message.Content = new StreamContent(blobStream);&lt;br&gt;
            message.Content.Headers.ContentLength = block.Properties.Length;&lt;br&gt;
            message.StatusCode = HttpStatusCode.OK;&lt;br&gt;
            message.Content.Headers.ContentType = new MediaTypeHeaderValue(block.Properties.ContentType);&lt;br&gt;
            message.Content.Headers.ContentDisposition = new ContentDispositionHeaderValue("attachment")&lt;br&gt;
            {&lt;br&gt;
                FileName = $"CopyOf_{block.Name}",&lt;br&gt;
                Size = block.Properties.Length&lt;br&gt;
            };&lt;br&gt;
            return message;&lt;br&gt;
        }&lt;br&gt;
    }&lt;br&gt;
}&lt;/p&gt;

</description>
      <category>blobstorage</category>
      <category>azurefunctions</category>
      <category>netcore</category>
      <category>webapi</category>
    </item>
  </channel>
</rss>
