protected static void uploadFileToBlob(
      String storageAccountName, String storageContainer, String fileName, String filePath)
      throws InvalidKeyException, URISyntaxException, StorageException, InterruptedException,
          IOException {
    MockCloudBlobClient blobClient = createBlobClient(storageAccountName, storageAccountKey);
    MockCloudBlobContainer container = blobClient.getContainerReference(storageContainer);

    MockCloudPageBlob pageblob = container.getPageBlobReference(fileName);

    File source = new File(filePath + fileName);
    pageblob.upload(new FileInputStream(source), source.length());

    // make sure it created and available, otherwise vm deployment will fail with storage/container
    // still creating
    boolean found = false;
    while (found == false) {
      // Loop over blobs within the container and output the URI to each of them
      for (MockListBlobItem item : container.listBlobs()) {
        if (item.getUri().getPath().contains(fileName) == true) {
          found = true;
        }
      }

      if (found == false) {
        Thread.sleep(1000 * 10);
      } else if (!IS_MOCKED) {
        Thread.sleep(1000 * 20);
      }
    }
  }
  protected static void createStorageContainer(String storageAccountName, String storageContainer)
      throws Exception {
    MockCloudBlobClient blobClient = createBlobClient(storageAccountName, storageAccountKey);
    MockCloudBlobContainer container = blobClient.getContainerReference(storageContainer);
    container.createIfNotExists();

    // make sure it created and available, otherwise vm deployment will fail with storage/container
    // still creating
    boolean found = false;
    while (found == false) {
      Iterable<MockCloudBlobContainer> listContainerResult =
          blobClient.listContainers(storageContainer);
      for (MockCloudBlobContainer item : listContainerResult) {
        blobhost = item.getUri().getHost();
        if (item.getName().contains(storageContainer) == true) {
          blobhost = item.getUri().getHost();
          found = true;
        }
      }

      if (found == false) {
        Thread.sleep(1000 * 30);
      } else if (!IS_MOCKED) {
        Thread.sleep(1000 * 60);
      }
    }
  }
  protected static void cleanBlob(String storageAccountName, String storageContainer) {
    // Create the blob client
    MockCloudBlobClient blobClient = null;
    try {
      blobClient = createBlobClient(storageAccountName, storageAccountKey);
    } catch (InvalidKeyException e) {
      e.printStackTrace();
    } catch (URISyntaxException e) {
      e.printStackTrace();
    }

    if (blobClient != null) {
      MockCloudBlobContainer container = null;
      try {
        container = blobClient.getContainerReference(storageContainer);
      } catch (URISyntaxException e) {
      } catch (StorageException e) {
      }

      try {
        container.breakLease(0);
      } catch (StorageException e) {
      }

      try {
        container.delete();
      } catch (StorageException e) {
      }

      try {
        while (container.exists()) {
          Thread.sleep(1000);
        }
      } catch (StorageException e) {
        e.printStackTrace();
      } catch (InterruptedException e) {
        e.printStackTrace();
      }
    }
  }