public async Task <ActionResult> Upload(HttpPostedFileBase file)
        {
            if (file.ContentLength > 0)
            {
                var apiService = new FaceApiService("9444c937d213494facbea9a862cedf86");

                //byte[] resultImage = await apiService.UploadAndDetectFace(file);
                byte[] resultImageBytes;

                //Detect Faces
                using (var imageStream = new MemoryStream())
                {
                    file.InputStream.CopyTo(imageStream);
                    imageStream.Position = 0;
                    //Call DetectFaces method from Face API service file
                    var faces = await apiService.DetectFaces(imageStream);

                    var attr = new List <string>();
                    foreach (var face in faces)
                    {
                        attr.Add(face.FaceAttributes.Age.ToString());
                        attr.Add(face.FaceAttributes.FacialHair.Beard.ToString());
                        attr.Add(face.FaceAttributes.FacialHair.Moustache.ToString());
                        attr.Add(face.FaceAttributes.FacialHair.Sideburns.ToString());
                        attr.Add(face.FaceAttributes.Gender.ToString());
                        attr.Add(face.FaceAttributes.Glasses.ToString());
                        attr.Add(face.FaceAttributes.HeadPose.Pitch.ToString());
                        attr.Add(face.FaceAttributes.HeadPose.Roll.ToString());
                        attr.Add(face.FaceAttributes.HeadPose.Yaw.ToString());
                        attr.Add(face.FaceAttributes.Smile.ToString());
                    }

                    TempData["attributes"] = attr;
                    var facePositions = faces.Select(face => face.FaceRectangle);

                    // Draw rectangles over original image.
                    using (var img = apiService.DrawRectangles(imageStream, facePositions))
                    {
                        using (var ms = new MemoryStream())
                        {
                            img.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg);
                            resultImageBytes = ms.ToArray();
                        }
                    }
                }
                CloudBlobContainer container = _blobStorageServices.GetCloudBlobContainer();
                CloudBlockBlob     blob      = container.GetBlockBlobReference(file.FileName);
                blob.UploadFromByteArray(resultImageBytes, 0, resultImageBytes.Count());

                TempData["resultImageBase64"] = GetImageBase64String(resultImageBytes);
                return(RedirectToAction("ViewFaces"));
            }

            return(RedirectToAction("Upload"));
        }