title: Downloading files to Azure function app to manipulate
body: <p><strong>Edited</strong> Thank you @Marco</p>
  
  <p>I'm trying to write a function app that grabs an SVG from a URL and converts it to PNG.  I know there are existing API's that do this like <a href="https://cloudconvert.com/" rel="noreferrer">CloudConvert</a>, but they don't work nicely with embedded fonts, which is a requirement for me.</p>
  
  <p>Anyway, I wrote a very basic function app that simply downloads a file at this point.  Everything works perfectly fine locally, but when I publish to Azure, I get <code>An exception occurred during a WebClient request.</code>  </p>
  
  <p>Thanks to @Marco's suggestion, I switched from WebClient to HTTPWebRequest to get more detailed error handling, and as a result, I see the following:</p>
  
  <blockquote>
    <p>2018-10-11T13:53:53.558 [Info] Function started (Id=e3cbda04-140e-4ef7-ad6c-c871ffe179dd)<br>
    2018-10-11T13:53:53.590 [Info] C# HTTP trigger function processed a request.
    2018-10-11T13:53:53.752 [Info] Download Fail<br>
    2018-10-11T13:53:53.752 [Info] Access to the path<br>
    'D:\Windows\system32\734e16961fc276df.svg' is denied.</p>
  </blockquote>
  
  <p>Am I trying to do something that isn't possible, or is there a fix for this?  Is there a way to configure permissions in an Azure function?  I need to pull the file down to edit and not just work with the byte array.</p>
  
  <p>Many thanks!</p>
  
  <pre><code>public static async Task&lt;HttpResponseMessage&gt; Run([HttpTrigger(AuthorizationLevel.Anonymous, "get", "post", Route = null)]HttpRequestMessage req, 
          TraceWriter log, ExecutionContext context)
  {
      log.Info("C# HTTP trigger function processed a request.");
  
      // parse query parameter
      string svgURL = req.GetQueryNameValuePairs()
          .FirstOrDefault(q =&gt; string.Compare(q.Key, "l", true) == 0)
          .Value;
  
      if (svgURL == null)
      {
          // Get request body
          dynamic data = await req.Content.ReadAsAsync&lt;object&gt;();
          svgURL = data?.svgURL;
      }
      // download file from URL
      var uniqueName = GenerateId() ;
      try 
      { 
          using (var client = new WebClient())
          {
             client.DownloadFile(svgURL, uniqueName + ".svg" );
          }
      }
      catch (Exception e)
      {
          log.Info("Download Fail");
          log.Info(e.Message);
      }
  }
  </code></pre>