title: Uploading a photo stream from camera into azure blob in WP7
body: <p>I have the following simple application page that uses the phone camera to upload the taken photo to azure blob:</p>
  
  <pre><code>public partial class AddReport : PhoneApplicationPage
  {
      // blobs stuff
      string storageAccount = "MYACCOUNT";
      string storageKey = "MYKEY";
      string blobServiceUri = "http://MYACCOUNT.blob.core.windows.net";
      CloudBlobClient blobClient;
  
      private Report newReport;
      public AddReport()
      {
          InitializeComponent();   
      }
  
      protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e)
      {
          //base.OnNavigatedTo(e);
  
          newReport = new Report();
          var credentials = new StorageCredentialsAccountAndKey(storageAccount, storageKey);
          blobClient = new CloudBlobClient(blobServiceUri, credentials);
      }
  
      private void TakePhotoClick(object sender, EventArgs eventArgs)
      {
          //The camera chooser used to capture a picture.
          CameraCaptureTask ctask;
  
          //Create new instance of CameraCaptureClass
          ctask = new CameraCaptureTask();
  
          //Create new event handler for capturing a photo
          ctask.Completed += new EventHandler&lt;PhotoResult&gt;(ctask_Completed);
  
          //Show the camera.
          ctask.Show();
  
      }
  
      void ctask_Completed(object sender, PhotoResult e)
      {
  
          if (e.TaskResult == TaskResult.OK &amp;&amp; e.ChosenPhoto != null)
          {
  
              WriteableBitmap CapturedImage = PictureDecoder.DecodeJpeg(e.ChosenPhoto);
              UploadToBlobContainer(e.ChosenPhoto);
          }
          else
          {
              //user decided not to take a picture
          }
      }
      private void UploadToBlobContainer(System.IO.Stream stream)
      {
          string containerName = "reportsPhotos";
          var container = blobClient.GetContainerReference(containerName);
  
          container.CreateIfNotExist(true, r =&gt;
              Dispatcher.BeginInvoke(() =&gt;
              {
                  var blobName = "report" + newReport.ReportId.ToString();
                  var blob = container.GetBlobReference(blobName);
                  blob.Metadata["ReportId"] = newReport.ReportId.ToString();
                  blob.UploadFromStream(stream, r2 =&gt;
                      Dispatcher.BeginInvoke(() =&gt;
                      {
                           newReport.Photo = container.Uri + "/" + blobName;
                      }));
              }));
  
      }
  }
  </code></pre>
  
  <p>This is a simple case and I am not using SAS to authenticate, instead I save the key in the app itself (this is only for testing purposes) and also my blobs are publicly available. </p>
  
  <p>when I run in debug mode it seems that everything is working, but the photo doesn't get uploaded to the blob. Also, I don't know how I can debug this to see if there was any error from the blob service.</p>
  
  <p>Can anyone tell me what might be wrong ?</p>
  
  <p>EDIT1: it seems that the container is not being created either. i've confirmed this using <a href="http://blobexplorer.codeplex.com/" rel="nofollow">azure blob explorer</a></p>
  
  <p>EDIT2: I am getting a <code>System.Net.WebException : "The remote server returned an error: NotFound."</code></p>