title: Azure function not working "Cannot declare namespace in script code"
body: <p>I am a java microservices person - not much into .NET.</p>
  <p>With the help from StackOverflow community .. I was able to get a working code for my problem.</p>
  <p>The code is working perfectly locally ..</p>
  <p>But when I tried to move it to Azure as a function . I am getting an error ..</p>
  <p>Please guide.</p>
  <p><strong>Code</strong> <em>working fine locally</em></p>
  <pre><code>using Azure.Storage.Blobs;
  using Azure.Storage.Blobs.Models;
  using Microsoft.Azure.Storage.Blob;
  using System;
  using System.IO;
  using System.Threading.Tasks;
  
  namespace whizlabblob
  {
      class Program
      {
          static string storageconnstring = &quot;DefaultEndpoint*******************************&quot;;
          static string containerName = &quot;demo&quot;;
          static string filename = &quot;sample.txt&quot;;
          static string filepath=&quot;C:\\Work\\sample.txt&quot;;
          static string downloadpath = &quot;C:\\Work\\sample2.txt&quot;;
          static async Task Main(string[] args)
          {
              //Container().Wait();
              //CreateBlob().Wait();
              //GetBlobs().Wait();
              // GetBlob().Wait();
              CopyBlob().Wait();
              Console.WriteLine(&quot;Complete&quot;);
              Console.ReadKey();
          }
  
          static async Task CopyBlob()
          {
              BlobServiceClient blobServiceClient = new BlobServiceClient(storageconnstring);
  
              BlobContainerClient containerClient = blobServiceClient.GetBlobContainerClient(containerName);
  
              BlobClient blobClient = containerClient.GetBlobClient(filename);
              var blobUri = blobClient.Uri;
  
              BlobContainerClient targetContainerClient = blobServiceClient.GetBlobContainerClient(&quot;demo-copy&quot;);//This is the container where we want to copy the blob
              BlobClient targetBlobClient = targetContainerClient.GetBlobClient(filename);
              await targetBlobClient.StartCopyFromUriAsync(blobUri);
          }
  
  }
  }
  </code></pre>
  <p><strong>Error</strong> <em>on Azure</em></p>
  <pre><code>Connected!
  2020-06-26T13:57:05Z   [Information]   Executing 'Functions.HttpTrigger1' (Reason='This function was programmatically called via the host APIs.', Id=a6869c88-b1ba-4c55-9671-9be26feb66ba)
  2020-06-26T13:57:05Z   [Error]   Function compilation error
  2020-06-26T13:57:05Z   [Error]   run.csx(8,1): error CS7021: Cannot declare namespace in script code
  2020-06-26T13:57:05Z   [Error]   run.csx(1,7): error CS0246: The type or namespace name 'Azure' could not be found (are you missing a using directive or an assembly reference?)
  2020-06-26T13:57:05Z   [Error]   run.csx(2,7): error CS0246: The type or namespace name 'Azure' could not be found (are you missing a using directive or an assembly reference?)
  2020-06-26T13:57:05Z   [Error]   run.csx(3,23): error CS0234: The type or namespace name 'Storage' does not exist in the namespace 'Microsoft.Azure' (are you missing an assembly reference?)
  2020-06-26T13:57:05Z   [Warning]   run.csx(17,27): warning CS7022: The entry point of the program is global script code; ignoring 'Program.Main(string[])' entry point.
  2020-06-26T13:57:05Z   [Warning]   run.csx(17,27): warning CS1998: This async method lacks 'await' operators and will run synchronously. Consider using the 'await' operator to await non-blocking API calls, or 'await Task.Run(...)' to do CPU-bound work on a background thread.
  2020-06-26T13:57:05Z   [Error]   run.csx(27,13): error CS0246: The type or namespace name 'BlobServiceClient' could not be found (are you missing a using directive or an assembly reference?)
  2020-06-26T13:57:06Z   [Error]   run.csx(27,55): error CS0246: The type or namespace name 'BlobServiceClient' could not be found (are you missing a using directive or an assembly reference?)
  2020-06-26T13:57:06Z   [Error]   run.csx(29,13): error CS0246: The type or namespace name 'BlobContainerClient' could not be found (are you missing a using directive or an assembly reference?)
  2020-06-26T13:57:06Z   [Error]   run.csx(31,13): error CS0246: The type or namespace name 'BlobClient' could not be found (are you missing a using directive or an assembly reference?)
  2020-06-26T13:57:06Z   [Error]   run.csx(34,13): error CS0246: The type or namespace name 'BlobContainerClient' could not be found (are you missing a using directive or an assembly reference?)
  2020-06-26T13:57:06Z   [Error]   run.csx(35,13): error CS0246: The type or namespace name 'BlobClient' could not be found (are you missing a using directive or an assembly reference?)
  2020-06-26T13:57:06Z   [Warning]   run.csx(15,23): warning CS0414: The field 'Program.filepath' is assigned but its value is never used
  2020-06-26T13:57:06Z   [Warning]   run.csx(16,23): warning CS0414: The field 'Program.downloadpath' is assigned but its value is never used
  2020-06-26T13:57:06Z   [Error]   Executed 'Functions.HttpTrigger1' (Failed, Id=a6869c88-b1ba-4c55-9671-9be26feb66ba)
  </code></pre>