/*** Generated by streamline 0.10.17 (callbacks) - DO NOT EDIT ***/ var __rt=require('streamline/lib/callbacks/runtime').runtime(__filename, false),__func=__rt.__func,__cb=__rt.__cb,__catch=__rt.__catch,__tryCatch=__rt.__tryCatch; var storage = require("azure-storage");
















var util = require("util");
var commander = require("commander");
var fs = require("fs");
var path = require("path");
var StorageUtil = require("../../util/storage.util");
var utils = require("../../util/utils");
var validation = require("../../util/validation");
var Wildcard = utils.Wildcard;
var performStorageOperation = StorageUtil.performStorageOperation;
var startProgress = StorageUtil.startProgress;
var endProgress = StorageUtil.endProgress;
var BlobConstants = storage.Constants.BlobConstants;
var BlobUtilities = storage.BlobUtilities;
var SpeedSummary = storage.BlobService.SpeedSummary;

var __ = require("underscore");
var $ = utils.getLocaleString;




commander.Command.prototype.addStorageAccountOption = function() {
  this.option("-a, --account-name <accountName>", $("the storage account name"));
  this.option("-k, --account-key <accountKey>", $("the storage account key"));
  this.option("-c, --connection-string <connectionString>", $("the storage connection string"));
  this.option("-vv", $("run storage command in debug mode"));
  return this;};





exports.init = function(cli) {


  StorageUtil.init(cli);




  var storage = cli.category("storage").description($("Commands to manage your storage objects"));


  var logger = cli.output;

  var interaction = cli.interaction;

  var container = storage.category("container").description($("Commands to manage your storage containers"));


  container.command("list [prefix]").description($("List storage containers with wildcard")).option("-p, --prefix <prefix>", $("the storage container name prefix")).addStorageAccountOption().execute(listAzureContainersWithAcl);





  container.command("show [container]").description($("Show details of the specified storage container")).option("--container <container>", $("the storage container name")).option("--lease <leaseId>", $("the lease ID")).addStorageAccountOption().execute(showAzureContainer);






  container.command("create [container]").description($("Create a storage container")).option("--container <container>", $("the storage container name")).option("-p, --permission <permission>", $("the storage container ACL permission(Off/Blob/Container)")).addStorageAccountOption().execute(createAzureContainer);






  container.command("delete [container]").description($("Delete the specified storage container")).option("--container <container>", $("the storage container name")).option("--lease <leaseId>", $("the lease ID")).option("-q, --quiet", $("remove the specified storage container without confirmation")).addStorageAccountOption().execute(deleteAzureContainer);







  container.command("set [container]").description($("Set storage container ACL")).option("--container <container>", $("the storage container name")).option("--lease <leaseId>", $("the lease ID")).option("-p, --permission <permission>", $("the storage container ACL permission(Off/Blob/Container)")).addStorageAccountOption().execute(setAzureContainer);







  var containerLease = container.category("lease").description($("Commands to manage leases of your storage container"));


  containerLease.command("acquire [container] [duration] [proposedId]").description($("Acquire a new lease against your storage container")).option("--container <container>", $("the storage container name")).option("--duration <duration>", $("the lease duration in seconds (15-60) or not specify for a lease that never expires")).option("--proposed-id <proposedId>", $("the proposed lease ID")).option("--sas <sas>", $("the shared access signature")).addStorageAccountOption().execute(acquireContainerLease);








  containerLease.command("renew [container] [lease]").description($("Renew an existing lease against your storage container")).option("--container <container>", $("the storage container name")).option("--lease <leaseId>", $("the existing lease ID")).option("--sas <sas>", $("the shared access signature")).addStorageAccountOption().execute(renewContainerLease);







  containerLease.command("change [container] [lease] [proposedId]").description($("Change an existing lease against your storage container")).option("--container <container>", $("the storage container name")).option("--lease <leaseId>", $("the existing lease ID")).option("--proposed-id <proposedId>", $("the proposed lease ID")).option("--sas <sas>", $("the shared access signature")).addStorageAccountOption().execute(changeContainerLease);








  containerLease.command("release [container] [lease]").description($("Release an existing lease against your storage container")).option("--container <container>", $("the storage container name")).option("--lease <leaseId>", $("the existing lease ID")).option("--sas <sas>", $("the shared access signature")).addStorageAccountOption().execute(releaseContainerLease);







  containerLease.command("break [container] [duration]").description($("Break an existing lease against your storage container")).option("--container <container>", $("the storage container name")).option("--duration <duration>", $("the proposed duration the lease should continue before it is broken in seconds (0-60)")).option("--sas <sas>", $("the shared access signature")).addStorageAccountOption().execute(breakContainerLease);







  var containerSas = container.category("sas").description($("Commands to manage shared access signatures of your storage container"));


  containerSas.command("create [container] [permissions] [expiry]").description($("Generate shared access signature of storage container")).option("--container <container>", $("the storage container name")).option("--permissions <permissions>", $("the operation permissions combining symbols of r(Read)/w(Write)/d(Delete)/l(List)")).option("--protocol <protocol>", $("the protocol permitted for a request made with the SAS. Possible values are HttpsOnly and HttpsOrHttp")).option("--ip-range <ipRange>", $("an IP address or a range of IP addresses from which to accept requests. When specifying a range of IP addresses, note that the range is inclusive. For example, specifying 168.1.5.65 or 168.1.5.60-168.1.5.70 on the SAS restricts the request to those IP addresses.")).option("--start <start>", $("the UTC time at which the SAS becomes valid")).option("--expiry <expiry>", $("the UTC time at which the SAS expires")).option("--policy <policy>", $("the stored access policy identifier")).addStorageAccountOption().execute(createContainerSAS);











  var policy = container.category("policy").description($("Commands to manage stored access policies of your storage container"));


  policy.command("create [container] [name]").usage("[options] [container] [name]").description($("Create a stored access policy on the container")).option("--container <container>", $("the storage container name")).option("--name <name>", $("the policy name")).option("--lease <leaseId>", $("the lease ID")).option("--start <start>", $("the UTC time at which the policy becomes valid")).option("--expiry <expiry>", $("the UTC time at which the policy expires")).option("--permissions <permissions>", $("the operation permissions combining symbols of r(Read)/w(Write)/d(Delete)/l(List)")).addStorageAccountOption().execute(createContainerPolicy);











  policy.command("show [container] [name]").usage("[options] [container] [name]").description($("Show a stored access policy on the container")).option("--container <container>", $("the storage container name")).option("--name <name>", $("the policy name")).option("--lease <leaseId>", $("the lease ID")).addStorageAccountOption().execute(showContainerPolicy);








  policy.command("list [container]").usage("[options] [container]").description($("List stored access policies on the container")).option("--container <container>", $("the storage container name")).option("--lease <leaseId>", $("the lease ID")).addStorageAccountOption().execute(listContainerPolicy);







  policy.command("set [container] [name]").usage("[options] [container] [name]").description($("Set a stored access policy on the container")).option("--container <container>", $("the storage container name")).option("--name <name>", $("the policy name")).option("--lease <leaseId>", $("the lease ID")).option("--start <start>", $("the UTC time at which the policy becomes valid and passing two spaces means to remove the existing setting")).option("--expiry <expiry>", $("the UTC time at which the policy expires and passing two spaces means to remove the existing setting")).option("--permissions <permissions>", $("the operation permissions combining symbols of r(Read)/w(Write)/d(Delete)/l(List) and passing two spaces means to remove the existing setting")).addStorageAccountOption().execute(setContainerPolicy);











  policy.command("delete [container] [name]").usage("[options] [container] [name]").description($("Delete a stored access policy on the container")).option("--container <container>", $("the storage container name")).option("--name <name>", $("the policy name")).option("--lease <leaseId>", $("the lease ID")).addStorageAccountOption().execute(deleteContainerPolicy);








  var blob = storage.category("blob").description($("Commands to manage your storage blobs"));


  blob.command("list [container] [prefix]").usage("[options] [container] [prefix]").description($("List storage blob in the specified storage container use wildcard and blob name prefix")).option("--container <container>", $("the storage container name")).option("-p, --prefix <prefix>", $("the blob name prefix")).option("--sas <sas>", $("the shared access signature")).addStorageAccountOption().execute(listAzureBlob);








  blob.command("show [container] [blob]").usage("[options] [container] [blob]").description($("Show details of the specified storage blob")).option("--container <container>", $("the storage container name")).option("-b, --blob <blobName>", $("the storage blob name")).option("--lease <leaseId>", $("the lease ID")).option("--snapshot <snapshotId>", $("the snapshot ID")).option("--sas <sas>", $("the shared access signature")).addStorageAccountOption().execute(showAzureBlob);










  blob.command("delete [container] [blob]").usage("[options] [container] [blob]").description($("Delete the specified storage blob")).option("--container <container>", $("the storage container name")).option("-b, --blob <blobName>", $("the storage blob name")).option("--snapshot <snapshotId>", $("the snapshot ID")).option("--lease <leaseId>", $("the lease ID")).option("--sas <sas>", $("the shared access signature")).option("--delete-snapshots <deleteSnapshots>", $("'include' to delete the base blob and all of its snapshots. 'only' to delete only the blob's snapshots and not the blob itself")).option("-q, --quiet", $("remove the specified storage blob without confirmation")).addStorageAccountOption().execute(deleteAzureBlob);












  blob.command("upload [file] [container] [blob]").usage("[options] [file] [container] [blob]").description($("Upload the specified file to storage blob")).option("-f, --file <file>", $("the local file path")).option("--container <container>", $("the storage container name")).option("-b, --blob <blobName>", $("the storage blob name")).option("-t, --blobtype <blobtype>", util.format($("the storage blob type(%s)"), getAvailableBlobTypes())).option("-p, --properties <properties>", $("the storage blob properties for uploaded file. Properties are key=value pairs and separated with semicolon(;). Available properties are contentType, contentEncoding, contentLanguage, cacheControl")).option("-m, --metadata <metadata>", $("the storage blob metadata for uploaded file. Metadata are key=value pairs and separated with semicolon(;)")).option("--concurrenttaskcount <concurrenttaskcount>", $("the maximum number of concurrent upload requests")).option("--lease <leaseId>", $("the lease ID")).option("--sas <sas>", $("the shared access signature")).option("-q, --quiet", $("overwrite the specified storage blob without confirmation")).addStorageAccountOption().execute(uploadAzureBlob);















  blob.command("download [container] [blob] [destination]").usage("[options] [container] [blob] [destination]").description($("Download the specified storage blob")).option("--container <container>", $("the storage container name")).option("-b, --blob <blobName>", $("the storage blob name")).option("--snapshot <snapshotId>", $("the snapshot ID")).option("--lease <leaseId>", $("the lease ID")).option("-d, --destination [destination]", $("download destination file or directory path")).option("-m, --checkmd5", $("check md5sum for the downloaded file")).option("--concurrenttaskcount <concurrenttaskcount>", $("the maximum number of concurrent download requests")).option("--sas <sas>", $("the shared access signature")).option("-q, --quiet", $("overwrite the destination file without confirmation")).addStorageAccountOption().execute(downloadAzureBlob);














  blob.command("snapshot [container] [blob]").usage("[options] [container] [blob]").description($("Creates a read-only snapshot of the blob")).option("--container <container>", $("the storage container name")).option("-b, --blob <blobName>", $("the storage blob name")).option("--lease <leaseId>", $("the lease ID")).option("--sas <sas>", $("the shared access signature")).addStorageAccountOption().execute(snapshotAzureBlob);









  var blobLease = blob.category("lease").description($("Commands to manage leases of your storage blob"));


  blobLease.command("acquire [container] [blob] [duration] [proposedId]").description($("Acquire a new lease against your storage blob")).option("--container <container>", $("the storage container name")).option("-b, --blob <blobName>", $("the storage blob name")).option("--duration <duration>", $("the lease duration in seconds (15-60) or negative one (-1) for a lease that never expires")).option("--proposed-id <proposedId>", $("the proposed lease ID")).option("--sas <sas>", $("the shared access signature")).addStorageAccountOption().execute(acquireBlobLease);









  blobLease.command("renew [container] [blob] [lease]").description($("Renew an existing lease against your storage blob")).option("--container <container>", $("the storage container name")).option("-b, --blob <blobName>", $("the storage blob name")).option("--lease <leaseId>", $("the existing lease ID")).option("--sas <sas>", $("the shared access signature")).addStorageAccountOption().execute(renewBlobLease);








  blobLease.command("change [container] [blob] [lease] [proposedId]").description($("Change an existing lease against your storage blob")).option("--container <container>", $("the storage container name")).option("-b, --blob <blobName>", $("the storage blob name")).option("--lease <leaseId>", $("the existing lease ID")).option("--proposed-id <proposedId>", $("the proposed lease ID")).option("--sas <sas>", $("the shared access signature")).addStorageAccountOption().execute(changeBlobLease);









  blobLease.command("release [container] [blob] [lease]").description($("Release an existing lease against your storage blob")).option("--container <container>", $("the storage container name")).option("-b, --blob <blobName>", $("the storage blob name")).option("--lease <leaseId>", $("the existing lease ID")).option("--sas <sas>", $("the shared access signature")).addStorageAccountOption().execute(releaseBlobLease);








  blobLease.command("break [container] [blob] [duration]").description($("Break an existing lease against your storage blob")).option("--container <container>", $("the storage container name")).option("-b, --blob <blobName>", $("the storage blob name")).option("--duration <duration>", $("the proposed duration the lease should continue before it is broken in seconds (0-60)")).option("--sas <sas>", $("the shared access signature")).addStorageAccountOption().execute(breakBlobLease);








  var copy = blob.category("copy").description($("Commands to manage your blob copy operations"));


  copy.command("start [sourceUri] [destContainer]").usage("[options] [sourceUri] [destContainer]").description($("Start to copy the resource to the specified storage blob which completes asynchronously")).option("--source-sas <sourceSas>", $("the shared access signature of the source storage")).option("--source-uri <sourceUri>", $("the source storage blob or file absolute uri")).option("--source-container <sourceContainer>", $("the source storage container name when copies a blob to a blob")).option("--source-blob <sourceBlob>", $("the source storage blob name when copies a blob to a blob")).option("--snapshot <snapshot>", $("the snapshot id if source is a snapshot")).option("--source-lease <sourceLeaseId>", $("the lease ID of the source blob ")).option("--source-share <sourceShare>", $("the source storage share name when copies a file to a blob")).option("--source-path <sourcePath>", $("the source storage file path when copies a file to a blob")).option("--dest-account-name <destAccountName>", $("the destination storage account name")).option("--dest-account-key <destAccountKey>", $("the destination storage account key")).option("--dest-connection-string <destConnectionString>", $("the destination storage connection string")).option("--dest-sas <destSas>", $("the shared access signature of the destination storage container or blob")).option("--dest-container <destContainer>", $("the destination storage container name")).option("--dest-blob <destBlob>", $("the destination storage blob name")).option("--dest-lease <destLeaseId>", $("the lease ID of the destination blob ")).option("-q, --quiet", $("overwrite the destination blob without confirmation")).addStorageAccountOption().execute(startBlobCopy);





















  copy.command("show [container] [blob]").usage("[options] [container] [blob]").description($("Show the copy status")).option("--container <container>", $("the destination container in the blob copy start operation")).option("--blob <blob>", $("the destination blob in the blob copy start operation")).option("--lease <leaseId>", $("the lease ID of the destination blob ")).option("--sas <sas>", $("the shared access signature of the destination storage container or blob")).addStorageAccountOption().execute(showBlobCopy);









  copy.command("stop [container] [blob] [copyid]").usage("[options] [container] [blob] [copyid]").description($("Stop the copy operation")).option("--container <container>", $("the destination container in the blob copy start operation")).option("--blob <blob>", $("the destination blob in the blob copy start operation")).option("--lease <leaseId>", $("the lease ID of the destination blob ")).option("--copyid <copyid>", $("the copy ID which is returned from blob copy start operation")).addStorageAccountOption().execute(stopBlobCopy);









  var blobSas = blob.category("sas").description($("Commands to manage shared access signature of your storage blob"));


  blobSas.command("create [container] [blob] [permissions] [expiry]").description($("Generate shared access signature of storage blob")).option("--container <container>", $("the storage container name")).option("--blob <blobName>", $("the storage blob name")).option("--permissions <permissions>", $("the operation permissions combining symbols of r(Read)/a(Add)/c(Create)/w(Write)/d(Delete)")).option("--protocol <protocol>", $("the protocol permitted for a request made with the SAS. Possible values are HttpsOnly and HttpsOrHttp")).option("--ip-range <ipRange>", $("an IP address or a range of IP addresses from which to accept requests. When specifying a range of IP addresses, note that the range is inclusive. For example, specifying 168.1.5.65 or 168.1.5.60-168.1.5.70 on the SAS restricts the request to those IP addresses.")).option("--start <start>", $("the UTC time at which the SAS becomes valid")).option("--expiry <expiry>", $("the UTC time at which the SAS expires")).option("--policy <policy>", $("the stored access policy identifier")).addStorageAccountOption().execute(createBlobSAS);





















  function getStorageBlobOperation(serviceClient, operationName) {
    return StorageUtil.getStorageOperation(serviceClient, StorageUtil.OperationType.Blob, operationName); };





  function getStorageBlobOperationDefaultOption() {
    var option = StorageUtil.getStorageOperationDefaultOption();


    option.parallelOperationThreadCount = StorageUtil.threadsInOperation;

    return option; };





  function getBlobServiceClient(options) {
    var serviceClient = StorageUtil.getServiceClient(StorageUtil.getBlobService, options);
    applyBlobServicePatch(serviceClient);
    return serviceClient; };





  function createContainerPolicySetting(options) {
    var policySettings = { };
    policySettings.accessType = StorageUtil.AccessType.Container;
    policySettings.serviceClient = getBlobServiceClient(options);
    policySettings.getAclOperation = getStorageBlobOperation(policySettings.serviceClient, "getContainerAcl");
    policySettings.setAclOperation = getStorageBlobOperation(policySettings.serviceClient, "setContainerAcl");
    policySettings.storageOptions = getStorageBlobOperationDefaultOption();
    policySettings.storageOptions.leaseId = options.lease;
    policySettings.policyOptions = options;
    return policySettings; };








  function listAzureContainersWithAcl(prefix, options, _) { var blobService, listOperation, tips, containerOpts, useWildcard, containers, supportACL; var __frame = { name: "listAzureContainersWithAcl", line: 460 }; return __func(_, this, arguments, listAzureContainersWithAcl, 2, __frame, function __$listAzureContainersWithAcl() {
      blobService = getBlobServiceClient(options);
      listOperation = getStorageBlobOperation(blobService, "listAllContainers");
      tips = $("Getting storage containers");
      containerOpts = getStorageBlobOperationDefaultOption();
      useWildcard = false;
      containerOpts.include = "metadata";

      if (Wildcard.containWildcards(prefix)) {
        containerOpts.prefix = Wildcard.getNonWildcardPrefix(prefix);
        useWildcard = true; }
       else {
        containerOpts.prefix = prefix; } ;


      containers = [];
      startProgress(tips); return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$listAzureContainersWithAcl() {



            supportACL = true;
            return performStorageOperation(listOperation, __cb(_, __frame, 21, 6, function ___(__0, __2) { return __2.forEach_(__cb(_, __frame, 21, 63, function __$listAzureContainersWithAcl() { _(null, null, true); }, true), 1, function __1(_, container) { var aclOperation, aclOptions, permission, level; var __frame = { name: "__1", line: 481 }; return __func(_, this, arguments, __1, 0, __frame, function __$__1() {

                  if ((useWildcard && !Wildcard.isMatch(container.name, prefix))) { return _(null); } ;


                  containers.push(container); return (function __$__1(__then) {

                    if (supportACL) { return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$__1() {

                            aclOperation = getStorageBlobOperation(blobService, "getContainerAcl");
                            aclOptions = StorageUtil.getStorageOperationDefaultOption();
                            return performStorageOperation(aclOperation, __cb(_, __frame, 11, 29, function ___(__0, __1) { permission = __1;
                              level = StorageUtil.containerAccessLevelToString(permission.publicAccessLevel);
                              container.publicAccessLevel = level; __then(); }, true), container.name, aclOptions); }); })(function ___(e, __result) { __catch(function __$__1() { if (e) {

                              supportACL = false;
                              logger.warn($("Current storage account doesn't support getting ACL")); __then(); } else { _(null, __result); } ; }, _); }); })(function ___() { __tryCatch(_, __then); }); } else { __then(); } ; })(_); }); }); }, true), containerOpts); }); })(function ___(__e, __r, __cont) { (function ___(__then) { __tryCatch(_, function __$listAzureContainersWithAcl() {




              endProgress(); __then(); }); })(function ___() { __tryCatch(_, function ___() { if (__cont) { __then(); } else { _(__e, __r); }; }); }); }); })(function ___() { __tryCatch(_, function __$listAzureContainersWithAcl() {


          cli.interaction.formatOutput(containers, function(outputData) {
            if ((outputData.length === 0)) {
              logger.info($("No containers found")); }
             else {
              logger.table(outputData, function(row, item) {
                row.cell($("Name"), item.name);
                row.cell($("Public Access"), item.publicAccessLevel);
                row.cell($("Last Modified"), item.lastModified); }); } ; }); _(); }); }); }); };









  function showAzureContainer(container, options, _) { var blobService, propertiesOperation, tips, showOptions, aclOperation, properties, permission, level; var __frame = { name: "showAzureContainer", line: 522 }; return __func(_, this, arguments, showAzureContainer, 2, __frame, function __$showAzureContainer() {
      blobService = getBlobServiceClient(options);
      return interaction.promptIfNotGiven($("Container name: "), container, __cb(_, __frame, 2, 28, function ___(__0, __1) { container = __1;
        propertiesOperation = getStorageBlobOperation(blobService, "getContainerProperties");
        tips = $("Getting storage container information");
        showOptions = getStorageBlobOperationDefaultOption();
        aclOperation = getStorageBlobOperation(blobService, "getContainerAcl");
        properties = { };

        startProgress(tips); return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$showAzureContainer() { return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$showAzureContainer() {


                    showOptions.leaseId = options.lease;

                    return performStorageOperation(propertiesOperation, __cb(_, __frame, 14, 19, function ___(__0, __2) { properties = __2; return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$showAzureContainer() {

                            return performStorageOperation(aclOperation, __cb(_, __frame, 16, 25, function ___(__0, __3) { permission = __3;
                              level = StorageUtil.containerAccessLevelToString(permission.publicAccessLevel);
                              properties.publicAccessLevel = level; __then(); }, true), container, showOptions); }); })(function ___(e, __result) { __catch(function __$showAzureContainer() { if (e) {

                              logger.warn($("Current storage account doesn't support getting ACL")); __then(); } else { _(null, __result); } ; }, _); }); })(function ___() { __tryCatch(_, __then); }); }, true), container, showOptions); }); })(function ___(e, __result) { __catch(function __$showAzureContainer() { if (e) {


                      if (StorageUtil.isNotFoundException(e)) {
                        return _(new Error(util.format($("Container %s doesn't exist"), container))); }
                       else {
                        return _(e); } ; __then(); } else { _(null, __result); } ; }, _); }); })(function ___() { __tryCatch(_, function __$showAzureContainer() { _(null, null, true); }); }); }); })(function ___(__e, __r, __cont) { (function ___(__then) { __tryCatch(_, function __$showAzureContainer() {


                endProgress(); __then(); }); })(function ___() { __tryCatch(_, function ___() { if (__cont) { __then(); } else { _(__e, __r); }; }); }); }); })(function ___() { __tryCatch(_, function __$showAzureContainer() {


            logger.json(properties); _(); }); }); }, true)); }); };






  function createAzureContainer(container, options, _) { var blobService, operation, tips, storageOptions, permission, createResult, aclOperation; var __frame = { name: "createAzureContainer", line: 561 }; return __func(_, this, arguments, createAzureContainer, 2, __frame, function __$createAzureContainer() {
      blobService = getBlobServiceClient(options);
      return interaction.promptIfNotGiven($("Container name: "), container, __cb(_, __frame, 2, 28, function ___(__0, __1) { container = __1;
        operation = getStorageBlobOperation(blobService, "createContainerIfNotExists");
        tips = util.format($("Creating storage container %s"), container);
        storageOptions = getStorageBlobOperationDefaultOption();
        permission = options.permission;
        if (permission) {
          validation.isValidEnumValue(permission, Object.keys(BlobUtilities.BlobContainerPublicAccessType)); } ;


        startProgress(tips); return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$createAzureContainer() {

              return performStorageOperation(operation, __cb(_, __frame, 13, 25, function ___(__0, __2) { createResult = __2; return (function __$createAzureContainer(__then) {
                  if ((createResult.created === false)) {
                    return _(new Error(util.format($("Container '%s' already exists"), container))); } else { return (function __$createAzureContainer(__then) {
                      if (permission) { return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$createAzureContainer() {


                              aclOperation = getStorageBlobOperation(blobService, "setContainerAcl");
                              storageOptions.publicAccessLevel = StorageUtil.stringToContainerAccessLevel(permission);
                              return performStorageOperation(aclOperation, __cb(_, __frame, 21, 10, __then, true), container, null, storageOptions); }); })(function ___(e, __result) { __catch(function __$createAzureContainer() { if (e) {

                                logger.warn($("Current storage account doesn't support setting ACL")); __then(); } else { _(null, __result); } ; }, _); }); })(function ___() { __tryCatch(_, __then); }); } else { __then(); } ; })(__then); } ; })(function __$createAzureContainer() { _(null, null, true); }); }, true), container, storageOptions); }); })(function ___(__e, __r, __cont) { (function ___(__then) { __tryCatch(_, function __$createAzureContainer() {



                endProgress(); __then(); }); })(function ___() { __tryCatch(_, function ___() { if (__cont) { __then(); } else { _(__e, __r); }; }); }); }); })(function ___() { __tryCatch(_, function __$createAzureContainer() {


            logger.verbose(util.format($("Container %s created successfully"), container));
            return showAzureContainer(container, StorageUtil.getStorageAccountOptions(options), __cb(_, __frame, 31, 4, function __$createAzureContainer() { _(); }, true)); }); }); }, true)); }); };





  function deleteAzureContainer(container, options, _) { var blobService, tips, operation, storageOptions, force; var __frame = { name: "deleteAzureContainer", line: 598 }; return __func(_, this, arguments, deleteAzureContainer, 2, __frame, function __$deleteAzureContainer() {
      blobService = getBlobServiceClient(options);
      return interaction.promptIfNotGiven($("Container name: "), container, __cb(_, __frame, 2, 28, function ___(__0, __1) { container = __1;
        tips = util.format($("Deleting Container %s"), container);
        operation = getStorageBlobOperation(blobService, "deleteContainer");
        storageOptions = getStorageBlobOperationDefaultOption();
        force = !!options.quiet; return (function __$deleteAzureContainer(__then) {

          if ((force !== true)) {
            return interaction.confirm(util.format($("Do you want to remove the storage container %s? "), container), __cb(_, __frame, 9, 26, function ___(__0, __2) { force = __2;
              if ((force !== true)) { return _(null); } ; __then(); }, true)); } else { __then(); } ; })(function __$deleteAzureContainer() {




          startProgress(tips); return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$deleteAzureContainer() { return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$deleteAzureContainer() {


                      storageOptions.leaseId = options.lease;
                      return performStorageOperation(operation, __cb(_, __frame, 19, 6, __then, true), container, storageOptions); }); })(function ___(e, __result) { __catch(function __$deleteAzureContainer() { if (e) {

                        if (StorageUtil.isNotFoundException(e)) {
                          return _(new Error(util.format($("Can not find container '%s'"), container))); }
                         else {
                          return _(e); } ; __then(); } else { _(null, __result); } ; }, _); }); })(function ___() { __tryCatch(_, function __$deleteAzureContainer() { _(null, null, true); }); }); }); })(function ___(__e, __r, __cont) { (function ___(__then) { __tryCatch(_, function __$deleteAzureContainer() {


                  endProgress(); __then(); }); })(function ___() { __tryCatch(_, function ___() { if (__cont) { __then(); } else { _(__e, __r); }; }); }); }); })(function ___() { __tryCatch(_, function __$deleteAzureContainer() {


              logger.info(util.format($("Container %s deleted successfully"), container)); _(); }); }); }); }, true)); }); };





  function setAzureContainer(container, options, _) { var blobService, tips; var __frame = { name: "setAzureContainer", line: 634 }; return __func(_, this, arguments, setAzureContainer, 2, __frame, function __$setAzureContainer() {
      blobService = getBlobServiceClient(options);
      return interaction.promptIfNotGiven($("Container name: "), container, __cb(_, __frame, 2, 28, function ___(__0, __1) { container = __1;
        tips = $("Set container");

        startProgress(tips);
        return setAzureContainerAcl(blobService, container, options, __cb(_, __frame, 6, 4, function __$setAzureContainer() {
          endProgress();

          return showAzureContainer(container, StorageUtil.getStorageAccountOptions(options), __cb(_, __frame, 9, 4, function __$setAzureContainer() { _(); }, true)); }, true)); }, true)); }); };





  function setAzureContainerAcl(blobService, container, options, _) { var operation, storageOptions; var __frame = { name: "setAzureContainerAcl", line: 649 }; return __func(_, this, arguments, setAzureContainerAcl, 3, __frame, function __$setAzureContainerAcl() { return (function __$setAzureContainerAcl(__then) {
        if (options.permission) { return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$setAzureContainerAcl() {

                operation = getStorageBlobOperation(blobService, "setContainerAcl");
                storageOptions = getStorageBlobOperationDefaultOption();
                storageOptions.leaseId = options.lease;
                validation.isValidEnumValue(options.permission, Object.keys(BlobUtilities.BlobContainerPublicAccessType));
                storageOptions.publicAccessLevel = StorageUtil.stringToContainerAccessLevel(options.permission);
                return performStorageOperation(operation, __cb(_, __frame, 8, 8, __then, true), container, null, storageOptions); }); })(function ___(e, __result) { __catch(function __$setAzureContainerAcl() { if (e) {

                  logger.warn($("Cannot set container ACL"));
                  return _(e); } else { _(null, __result); } ; }, _); }); })(function ___() { __tryCatch(_, __then); }); } else { __then(); } ; })(_); }); };







  function acquireContainerLease(container, duration, proposedId, options, _) { var __frame = { name: "acquireContainerLease", line: 668 }; return __func(_, this, arguments, acquireContainerLease, 4, __frame, function __$acquireContainerLease() {
      options.tips = $("Acquiring a new lease against the container");
      return acquireLease(container, null, duration, proposedId, options, __cb(_, __frame, 2, 4, function __$acquireContainerLease() { _(); }, true)); }); };





  function acquireBlobLease(container, blob, duration, proposedId, options, _) { var __frame = { name: "acquireBlobLease", line: 676 }; return __func(_, this, arguments, acquireBlobLease, 5, __frame, function __$acquireBlobLease() {
      options.forBlob = true;
      options.tips = $("Acquiring a new lease against the blob");
      return acquireLease(container, blob, duration, proposedId, options, __cb(_, __frame, 3, 4, function __$acquireBlobLease() { _(); }, true)); }); };





  function acquireLease(container, blob, duration, proposedId, options, _) { var blobService; var __frame = { name: "acquireLease", line: 685 }; return __func(_, this, arguments, acquireLease, 5, __frame, function __$acquireLease() {
      blobService = getBlobServiceClient(options);
      __.extend(options, getStorageBlobOperationDefaultOption());

      options.container = container;
      options.blob = blob;
      options.leaseDuration = duration;
      options.proposedLeaseId = proposedId;

      options.operation = getStorageBlobOperation(blobService, "acquireLease");
      return StorageUtil.acquireLease(blobService, options, __cb(_, __frame, 10, 16, function __$acquireLease() { _(); }, true)); }); };





  function renewContainerLease(container, leaseId, options, _) { var __frame = { name: "renewContainerLease", line: 701 }; return __func(_, this, arguments, renewContainerLease, 3, __frame, function __$renewContainerLease() {
      options.tips = $("Renewing a new lease against the container");
      return renewLease(container, null, leaseId, options, __cb(_, __frame, 2, 4, function __$renewContainerLease() { _(); }, true)); }); };





  function renewBlobLease(container, blob, leaseId, options, _) { var __frame = { name: "renewBlobLease", line: 709 }; return __func(_, this, arguments, renewBlobLease, 4, __frame, function __$renewBlobLease() {
      options.forBlob = true;
      options.tips = $("Renewing a new lease against the blob");
      return renewLease(container, blob, leaseId, options, __cb(_, __frame, 3, 4, function __$renewBlobLease() { _(); }, true)); }); };





  function renewLease(container, blob, leaseId, options, _) { var blobService; var __frame = { name: "renewLease", line: 718 }; return __func(_, this, arguments, renewLease, 4, __frame, function __$renewLease() {
      blobService = getBlobServiceClient(options);
      __.extend(options, getStorageBlobOperationDefaultOption());

      options.container = container;
      options.blob = blob;
      options.leaseId = leaseId;

      options.operation = getStorageBlobOperation(blobService, "renewLease");
      return StorageUtil.renewLease(blobService, options, __cb(_, __frame, 9, 16, function __$renewLease() { _(); }, true)); }); };





  function changeContainerLease(container, leaseId, proposedId, options, _) { var __frame = { name: "changeContainerLease", line: 733 }; return __func(_, this, arguments, changeContainerLease, 4, __frame, function __$changeContainerLease() {
      options.tips = $("Changing a new lease against the container");
      return changeLease(container, null, leaseId, proposedId, options, __cb(_, __frame, 2, 4, function __$changeContainerLease() { _(); }, true)); }); };





  function changeBlobLease(container, blob, leaseId, proposedId, options, _) { var __frame = { name: "changeBlobLease", line: 741 }; return __func(_, this, arguments, changeBlobLease, 5, __frame, function __$changeBlobLease() {
      options.forBlob = true;
      options.tips = $("Changing a new lease against the blob");
      return changeLease(container, blob, leaseId, proposedId, options, __cb(_, __frame, 3, 4, function __$changeBlobLease() { _(); }, true)); }); };





  function changeLease(container, blob, leaseId, proposedId, options, _) { var blobService; var __frame = { name: "changeLease", line: 750 }; return __func(_, this, arguments, changeLease, 5, __frame, function __$changeLease() {
      blobService = getBlobServiceClient(options);
      __.extend(options, getStorageBlobOperationDefaultOption());

      options.container = container;
      options.blob = blob;
      options.leaseId = leaseId;
      options.proposedId = proposedId;

      options.operation = getStorageBlobOperation(blobService, "changeLease");
      return StorageUtil.changeLease(blobService, options, __cb(_, __frame, 10, 16, function __$changeLease() { _(); }, true)); }); };





  function releaseContainerLease(container, leaseId, options, _) { var __frame = { name: "releaseContainerLease", line: 766 }; return __func(_, this, arguments, releaseContainerLease, 3, __frame, function __$releaseContainerLease() {
      options.tips = $("Releasing an existing lease against the container");
      return releaseLease(container, null, leaseId, options, __cb(_, __frame, 2, 4, function __$releaseContainerLease() { _(); }, true)); }); };





  function releaseBlobLease(container, blob, leaseId, options, _) { var __frame = { name: "releaseBlobLease", line: 774 }; return __func(_, this, arguments, releaseBlobLease, 4, __frame, function __$releaseBlobLease() {
      options.forBlob = true;
      options.tips = $("Releasing an existing lease against the blob");
      return releaseLease(container, blob, leaseId, options, __cb(_, __frame, 3, 4, function __$releaseBlobLease() { _(); }, true)); }); };





  function releaseLease(container, blob, leaseId, options, _) { var blobService; var __frame = { name: "releaseLease", line: 783 }; return __func(_, this, arguments, releaseLease, 4, __frame, function __$releaseLease() {
      blobService = getBlobServiceClient(options);
      __.extend(options, getStorageBlobOperationDefaultOption());

      options.container = container;
      options.blob = blob;
      options.leaseId = leaseId;
      options.tips = $("Release an existing lease ");
      options.operation = getStorageBlobOperation(blobService, "releaseLease");
      return StorageUtil.releaseLease(blobService, options, __cb(_, __frame, 9, 16, function __$releaseLease() { _(); }, true)); }); };





  function breakContainerLease(container, duration, options, _) { var __frame = { name: "breakContainerLease", line: 798 }; return __func(_, this, arguments, breakContainerLease, 3, __frame, function __$breakContainerLease() {
      options.tips = $("Breaking an existing lease against the container");
      return breakLease(container, null, duration, options, __cb(_, __frame, 2, 4, function __$breakContainerLease() { _(); }, true)); }); };





  function breakBlobLease(container, blob, duration, options, _) { var __frame = { name: "breakBlobLease", line: 806 }; return __func(_, this, arguments, breakBlobLease, 4, __frame, function __$breakBlobLease() {
      options.forBlob = true;
      options.tips = $("Breaking an existing lease against the blob");
      return breakLease(container, blob, duration, options, __cb(_, __frame, 3, 4, function __$breakBlobLease() { _(); }, true)); }); };





  function breakLease(container, blob, duration, options, _) { var blobService; var __frame = { name: "breakLease", line: 815 }; return __func(_, this, arguments, breakLease, 4, __frame, function __$breakLease() {
      blobService = getBlobServiceClient(options);
      __.extend(options, getStorageBlobOperationDefaultOption());

      options.container = container;
      options.blob = blob;
      options.leaseBreakPeriod = duration;

      options.operation = getStorageBlobOperation(blobService, "breakLease");
      return StorageUtil.breakLease(blobService, options, __cb(_, __frame, 9, 16, function __$breakLease() { _(); }, true)); }); };





  function createContainerSAS(container, permissions, expiry, options, _) { var __frame = { name: "createContainerSAS", line: 830 }; return __func(_, this, arguments, createContainerSAS, 4, __frame, function __$createContainerSAS() {
      return createSas(container, null, permissions, options.protocol, options.ipRange, expiry, options, true, __cb(_, __frame, 1, 4, function __$createContainerSAS() { _(); }, true)); }); };





  function createBlobSAS(container, blob, permissions, expiry, options, _) { var __frame = { name: "createBlobSAS", line: 837 }; return __func(_, this, arguments, createBlobSAS, 5, __frame, function __$createBlobSAS() {
      return createSas(container, blob, permissions, options.protocol, options.ipRange, expiry, options, false, __cb(_, __frame, 1, 4, function __$createBlobSAS() { _(); }, true)); }); };





  function createSas(container, blob, permissions, protocol, ipRange, expiry, options, isOnContainer, _) { var blobService, accessType, start, output, sharedAccessPolicy, tips; var __frame = { name: "createSas", line: 844 }; return __func(_, this, arguments, createSas, 8, __frame, function __$createSas() {
      blobService = getBlobServiceClient(options);
      return interaction.promptIfNotGiven($("Container name: "), container, __cb(_, __frame, 2, 28, function ___(__0, __1) { container = __1; return (function __$createSas(__then) {


          if (!isOnContainer) {
            return interaction.promptIfNotGiven($("Blob name: "), blob, __cb(_, __frame, 6, 25, function ___(__0, __2) { blob = __2;
              accessType = StorageUtil.AccessType.Blob; __then(); }, true)); } else {

            accessType = StorageUtil.AccessType.Container; __then(); } ; })(function __$createSas() { return (function __$createSas(__then) {


            if (!options.policy) {
              return interaction.promptIfNotGiven($("Permissions: "), permissions, __cb(_, __frame, 13, 32, function ___(__0, __3) { permissions = __3;
                StorageUtil.validatePermissions(accessType, permissions);

                return interaction.promptIfNotGiven($("Expiry: "), expiry, __cb(_, __frame, 16, 27, function ___(__0, __4) { expiry = __4;
                  expiry = utils.parseDateTime(expiry); __then(); }, true)); }, true)); } else { __then(); } ; })(function __$createSas() {



            if (options.start) {
              start = utils.parseDateTime(options.start); } ;


            output = { sas: "", url: "" };
            sharedAccessPolicy = StorageUtil.getSharedAccessPolicy(accessType, permissions, protocol, ipRange, start, expiry, null, options.policy);

            if (isOnContainer) {
              tips = util.format($("Creating shared access signature for container %s"), container); }
             else {
              tips = util.format($("Creating shared access signature for blob %s in container %s"), blob, container); } ;

            startProgress(tips); return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$createSas() {

                  output.sas = blobService.generateSharedAccessSignature(container, blob, sharedAccessPolicy);
                  output.url = blobService.getUrl(container, blob, output.sas); _(null, null, true); }); })(function ___(__e, __r, __cont) { (function ___(__then) { __tryCatch(_, function __$createSas() {

                    endProgress(); __then(); }); })(function ___() { __tryCatch(_, function ___() { if (__cont) { __then(); } else { _(__e, __r); }; }); }); }); })(function ___() { __tryCatch(_, function __$createSas() {


                cli.interaction.formatOutput(output, function(outputData) {
                  logger.data($("Shared Access Signature"), outputData.sas);
                  logger.data($("Shared Access URL"), outputData.url); }); _(); }); }); }); }); }, true)); }); };






  function createContainerPolicy(container, name, options, _) { var createPolicySettings, policies; var __frame = { name: "createContainerPolicy", line: 894 }; return __func(_, this, arguments, createContainerPolicy, 3, __frame, function __$createContainerPolicy() {
      createPolicySettings = createContainerPolicySetting(options);
      return interaction.promptIfNotGiven($("Container name: "), container, __cb(_, __frame, 2, 52, function ___(__0, __1) { createPolicySettings.resourceName = __1;
        return interaction.promptIfNotGiven($("Policy name: "), name, __cb(_, __frame, 3, 50, function ___(__0, __2) { createPolicySettings.policyName = __2;
          createPolicySettings.tips = util.format($("Creating the stored access policy %s on the container %s"), createPolicySettings.policyName, createPolicySettings.resourceName);

          if (options.permissions) {
            StorageUtil.validatePermissions(StorageUtil.AccessType.Container, options.permissions); } ;


          return StorageUtil.createPolicy(createPolicySettings, __cb(_, __frame, 10, 31, function ___(__0, __3) { policies = __3;
            cli.interaction.formatOutput(policies, function(outputData) {
              logger.info(util.format($("The stored access policies on container %s are: "), createPolicySettings.resourceName));
              StorageUtil.showPolicyResults(outputData); }); _(); }, true)); }, true)); }, true)); }); };






  function listContainerPolicy(container, options, _) { var listPolicySettings, policies; var __frame = { name: "listContainerPolicy", line: 914 }; return __func(_, this, arguments, listContainerPolicy, 2, __frame, function __$listContainerPolicy() {
      listPolicySettings = createContainerPolicySetting(options);
      return interaction.promptIfNotGiven($("Container name: "), container, __cb(_, __frame, 2, 50, function ___(__0, __1) { listPolicySettings.resourceName = __1;
        listPolicySettings.tips = util.format($("Listing the stored access policies on the container %s"), listPolicySettings.resourceName);

        return StorageUtil.selectPolicy(listPolicySettings, __cb(_, __frame, 5, 31, function ___(__0, __2) { policies = __2;
          cli.interaction.formatOutput(policies, function(outputData) {
            if (outputData) {
              StorageUtil.showPolicyResults(outputData); }
             else {
              logger.info(util.format($("There is no stored access policy on the container %s."), listPolicySettings.resourceName)); } ; }); _(); }, true)); }, true)); }); };







  function showContainerPolicy(container, name, options, _) { var showPolicySettings, policy; var __frame = { name: "showContainerPolicy", line: 932 }; return __func(_, this, arguments, showContainerPolicy, 3, __frame, function __$showContainerPolicy() {
      showPolicySettings = createContainerPolicySetting(options);
      return interaction.promptIfNotGiven($("Container name: "), container, __cb(_, __frame, 2, 50, function ___(__0, __1) { showPolicySettings.resourceName = __1;
        return interaction.promptIfNotGiven($("Policy name: "), name, __cb(_, __frame, 3, 48, function ___(__0, __2) { showPolicySettings.policyName = __2;
          showPolicySettings.tips = util.format($("Showing the stored access policy %s on the container %s"), showPolicySettings.policyName, showPolicySettings.resourceName);

          return StorageUtil.selectPolicy(showPolicySettings, __cb(_, __frame, 6, 29, function ___(__0, __3) { policy = __3;
            cli.interaction.formatOutput(policy, function(outputData) {
              StorageUtil.showPolicyResults(outputData); }); _(); }, true)); }, true)); }, true)); }); };






  function setContainerPolicy(container, name, options, _) { var setPolicySettings, policies; var __frame = { name: "setContainerPolicy", line: 947 }; return __func(_, this, arguments, setContainerPolicy, 3, __frame, function __$setContainerPolicy() {
      setPolicySettings = createContainerPolicySetting(options);
      return interaction.promptIfNotGiven($("Container name: "), container, __cb(_, __frame, 2, 49, function ___(__0, __1) { setPolicySettings.resourceName = __1;
        return interaction.promptIfNotGiven($("Policy name: "), name, __cb(_, __frame, 3, 47, function ___(__0, __2) { setPolicySettings.policyName = __2;
          setPolicySettings.tips = util.format($("Setting the stored access policy %s on the container %s"), setPolicySettings.policyName, setPolicySettings.resourceName);

          if (options.permissions) {
            StorageUtil.validatePermissions(StorageUtil.AccessType.Container, options.permissions); } ;


          return StorageUtil.setPolicy(setPolicySettings, __cb(_, __frame, 10, 31, function ___(__0, __3) { policies = __3;
            cli.interaction.formatOutput(policies, function(outputData) {
              logger.info(util.format($("The stored access policies on container %s are: "), setPolicySettings.resourceName));
              StorageUtil.showPolicyResults(outputData); }); _(); }, true)); }, true)); }, true)); }); };






  function deleteContainerPolicy(container, name, options, _) { var deletePolicySettings, policies; var __frame = { name: "deleteContainerPolicy", line: 967 }; return __func(_, this, arguments, deleteContainerPolicy, 3, __frame, function __$deleteContainerPolicy() {
      deletePolicySettings = createContainerPolicySetting(options);
      return interaction.promptIfNotGiven($("Container name: "), container, __cb(_, __frame, 2, 52, function ___(__0, __1) { deletePolicySettings.resourceName = __1;
        return interaction.promptIfNotGiven($("Policy name: "), name, __cb(_, __frame, 3, 50, function ___(__0, __2) { deletePolicySettings.policyName = __2;
          deletePolicySettings.tips = util.format($("Deleting the stored access policy %s on the container %s"), deletePolicySettings.policyName, deletePolicySettings.resourceName);

          return StorageUtil.deletePolicy(deletePolicySettings, __cb(_, __frame, 6, 31, function ___(__0, __3) { policies = __3;
            cli.interaction.formatOutput(policies, function(outputData) {
              if (outputData) {
                logger.info(util.format($("The stored access policies on container %s are: "), deletePolicySettings.resourceName));
                StorageUtil.showPolicyResults(outputData); }
               else {
                logger.info(util.format($("There is no stored access policy on the container %s."), deletePolicySettings.resourceName)); } ; }); _(); }, true)); }, true)); }, true)); }); };







  function listAzureBlob(container, blobName, options, _) { var blobService, specifiedContainerName, tips, operation, storageOptions, useWildcard, inputBlobName, blobs, outputBlobs, i, len, blob; var __frame = { name: "listAzureBlob", line: 987 }; return __func(_, this, arguments, listAzureBlob, 3, __frame, function __$listAzureBlob() {
      blobService = getBlobServiceClient(options);
      return interaction.promptIfNotGiven($("Container name: "), container, __cb(_, __frame, 2, 45, function ___(__0, __1) { specifiedContainerName = __1;
        tips = util.format($("Getting blobs in container %s"), specifiedContainerName);
        operation = getStorageBlobOperation(blobService, "listAllBlobs");
        storageOptions = getStorageBlobOperationDefaultOption();
        useWildcard = false;
        inputBlobName = blobName;
        if (Wildcard.containWildcards(inputBlobName)) {
          storageOptions.prefix = Wildcard.getNonWildcardPrefix(inputBlobName);
          useWildcard = true; }
         else {
          storageOptions.prefix = inputBlobName; } ;

        storageOptions.include = "snapshots,metadata,copy";
        blobs = [];

        startProgress(tips); return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$listAzureBlob() {


              return performStorageOperation(operation, __cb(_, __frame, 20, 14, function ___(__0, __2) { blobs = __2; _(null, null, true); }, true), specifiedContainerName, storageOptions); }); })(function ___(__e, __r, __cont) { (function ___(__then) { __tryCatch(_, function __$listAzureBlob() {

                endProgress(); __then(); }); })(function ___() { __tryCatch(_, function ___() { if (__cont) { __then(); } else { _(__e, __r); }; }); }); }); })(function ___() { __tryCatch(_, function __$listAzureBlob() {


            outputBlobs = [];

            if (useWildcard) {
              for (i = 0, len = blobs.length; (i < len); i++) {
                blob = blobs[i];
                if (Wildcard.isMatch(blob.name, inputBlobName)) {
                  outputBlobs.push(blob); } ; }; }


             else {
              outputBlobs = blobs; } ;


            cli.interaction.formatOutput(outputBlobs, function(outputData) {
              if ((outputData.length === 0)) {
                logger.info($("No blobs found")); }
               else {
                outputData.contentSettings = (outputData.contentSettings || { });
                logger.table(outputData, function(row, item) {
                  row.cell($("Name"), item.name);
                  row.cell($("Blob Type"), item.blobType);
                  row.cell($("Length"), item.contentLength);
                  row.cell($("Content Type"), item.contentSettings.contentType);
                  row.cell($("Last Modified"), item.lastModified);
                  row.cell($("Snapshot Time"), (item.snapshot || "")); }); } ; }); _(); }); }); }, true)); }); };








  function showAzureBlob(containerName, blobName, options, _) { var blob; var __frame = { name: "showAzureBlob", line: 1045 }; return __func(_, this, arguments, showAzureBlob, 3, __frame, function __$showAzureBlob() {
      return getAzureBlobProperties(containerName, blobName, options, __cb(_, __frame, 1, 15, function ___(__0, __1) { blob = __1;
        logBlobProperties(blob, options.speedSummary); _(); }, true)); }); };





  function logBlobProperties(properties, speedSummary) {
    if (!properties) { return };
    var extendProperties = StorageUtil.embedTransferSummary(properties, speedSummary);

    cli.interaction.formatOutput(extendProperties, function(data) {
      var outputProperties = ["container","name","blobType","contentLength","contentType","contentMD5",];
      var output = outputProperties.map(function(propertyName) {
        return {
          property: propertyName, value: (data[propertyName] || data.contentSettings[propertyName]) }; });


      logger.table(output, function(row, item) {
        row.cell($("Property"), item.property);
        row.cell($("Value"), item.value); }); }); };







  function getAzureBlobProperties(container, blobName, options, _) { var blobService, specifiedContainerName, specifiedBlobName, storageOptions, blob, propertiesOperation, tips; var __frame = { name: "getAzureBlobProperties", line: 1074 }; return __func(_, this, arguments, getAzureBlobProperties, 3, __frame, function __$getAzureBlobProperties() {
      blobService = getBlobServiceClient(options);
      return interaction.promptIfNotGiven($("Container name: "), container, __cb(_, __frame, 2, 45, function ___(__0, __1) { specifiedContainerName = __1;
        return interaction.promptIfNotGiven($("Blob name: "), blobName, __cb(_, __frame, 3, 40, function ___(__0, __2) { specifiedBlobName = __2;
          storageOptions = getStorageBlobOperationDefaultOption();
          blob = { };
          propertiesOperation = getStorageBlobOperation(blobService, "getBlobProperties");
          tips = $("Getting storage blob information");

          startProgress(tips); return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$getAzureBlobProperties() { return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$getAzureBlobProperties() {


                      storageOptions.leaseId = options.lease;
                      storageOptions.snapshotId = options.snapshot;
                      return performStorageOperation(propertiesOperation, __cb(_, __frame, 14, 13, function ___(__0, __3) { blob = __3; __then(); }, true), specifiedContainerName, specifiedBlobName, storageOptions); }); })(function ___(e, __result) { __catch(function __$getAzureBlobProperties() { if (e) {

                        if (StorageUtil.isNotFoundException(e)) {
                          return _(new Error(util.format($("Blob %s in Container %s doesn't exist"), specifiedBlobName, specifiedContainerName))); }
                         else {
                          return _(e); } ; __then(); } else { _(null, __result); } ; }, _); }); })(function ___() { __tryCatch(_, function __$getAzureBlobProperties() { _(null, null, true); }); }); }); })(function ___(__e, __r, __cont) { (function ___(__then) { __tryCatch(_, function __$getAzureBlobProperties() {


                  endProgress(); __then(); }); })(function ___() { __tryCatch(_, function ___() { if (__cont) { __then(); } else { _(__e, __r); }; }); }); }); })(function ___() { __tryCatch(_, function __$getAzureBlobProperties() {

              return _(null, blob); }); }); }, true)); }, true)); }); };





  function deleteAzureBlob(container, blobName, options, _) { var blobService, specifiedContainerName, specifiedBlobName, storageOptions, force, message, tips, operation; var __frame = { name: "deleteAzureBlob", line: 1104 }; return __func(_, this, arguments, deleteAzureBlob, 3, __frame, function __$deleteAzureBlob() {
      blobService = getBlobServiceClient(options);
      return interaction.promptIfNotGiven($("Container name: "), container, __cb(_, __frame, 2, 45, function ___(__0, __1) { specifiedContainerName = __1;
        return interaction.promptIfNotGiven($("Blob name: "), blobName, __cb(_, __frame, 3, 40, function ___(__0, __2) { specifiedBlobName = __2;
          storageOptions = getStorageBlobOperationDefaultOption();

          if (options.deleteSnapshots) {
            validation.isValidEnumValue(options.deleteSnapshots, Object.keys(StorageUtil.BlobSnapshotDeletion)); } ;


          force = !!options.quiet; return (function __$deleteAzureBlob(__then) {
            if ((force !== true)) {

              if ((options.deleteSnapshots && (options.deleteSnapshots.toLowerCase() == StorageUtil.BlobSnapshotDeletion.Only.toLowerCase()))) {
                message = util.format($("Do you want to remove all of the snapshots of the storage blob %s? "), blobName); } else {
                if (options.snapshot) {
                  message = util.format($("Do you want to remove the snapshot %s of blob %s? "), options.snapshot, blobName); }
                 else {
                  message = util.format($("Do you want to remove the storage blob %s and all of its snapshots? "), blobName); } ; } ;


              return interaction.confirm(message, __cb(_, __frame, 21, 26, function ___(__0, __3) { force = __3;
                if ((force !== true)) { return _(null); } ; __then(); }, true)); } else {


              if (!options.snapshot) {
                options.deleteSnapshots = (options.deleteSnapshots || StorageUtil.BlobSnapshotDeletion.Include); } ; __then(); } ; })(function __$deleteAzureBlob() {


            storageOptions.deleteSnapshots = options.deleteSnapshots;
            storageOptions.snapshotId = options.snapshot;
            storageOptions.leaseId = options.lease;

            tips = util.format($("Deleting Blob %s in container %s"), blobName, container);
            operation = getStorageBlobOperation(blobService, "deleteBlob");
            startProgress(tips); return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$deleteAzureBlob() { return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$deleteAzureBlob() {


                        return performStorageOperation(operation, __cb(_, __frame, 38, 6, __then, true), specifiedContainerName, specifiedBlobName, storageOptions); }); })(function ___(e, __result) { __catch(function __$deleteAzureBlob() { if (e) {

                          if (StorageUtil.isNotFoundException(e)) {
                            if (options.snapshot) {
                              return _(new Error(util.format($("Can not find snapshot '%s' of blob '%s' in container '%s'"), options.snapshot, specifiedBlobName, specifiedContainerName))); }
                             else {
                              return _(new Error(util.format($("Can not find blob '%s' in container '%s'"), specifiedBlobName, specifiedContainerName))); } ; }

                           else {
                            return _(e); } ; __then(); } else { _(null, __result); } ; }, _); }); })(function ___() { __tryCatch(_, function __$deleteAzureBlob() { _(null, null, true); }); }); }); })(function ___(__e, __r, __cont) { (function ___(__then) { __tryCatch(_, function __$deleteAzureBlob() {


                    endProgress(); __then(); }); })(function ___() { __tryCatch(_, function ___() { if (__cont) { __then(); } else { _(__e, __r); }; }); }); }); })(function ___() { __tryCatch(_, function __$deleteAzureBlob() {


                logger.info(util.format($("Blob %s deleted successfully"), blobName)); _(); }); }); }); }, true)); }, true)); }); };





  function uploadAzureBlob(file, container, blobName, options, _) { var blobService, specifiedContainerName, specifiedFileName, specifiedBlobName, storageOptions, properties, force, summary, fsStatus, defaultBlobTypeName, blobTypeName, specifiedBlobType, sizeLimit, tips, blobProperties, propertiesOperation, operation, printer, intervalId, extendOption; var __frame = { name: "uploadAzureBlob", line: 1163 }; return __func(_, this, arguments, uploadAzureBlob, 4, __frame, function __$uploadAzureBlob() {
      blobService = getBlobServiceClient(options);
      return interaction.promptIfNotGiven($("Container name: "), container, __cb(_, __frame, 2, 45, function ___(__0, __1) { specifiedContainerName = __1;
        return interaction.promptIfNotGiven($("File name: "), file, __cb(_, __frame, 3, 40, function ___(__0, __2) { specifiedFileName = __2;
          specifiedBlobName = blobName;
          storageOptions = getStorageBlobOperationDefaultOption();
          properties = StorageUtil.parseKvParameter(options.properties);
          force = options.quiet;
          storageOptions.metadata = StorageUtil.parseKvParameter(options.metadata);
          storageOptions.storeBlobContentMD5 = true;
          StorageUtil.formatBlobProperties(properties, storageOptions);
          summary = new SpeedSummary(specifiedBlobName);
          storageOptions.speedSummary = summary;
          storageOptions.leaseId = options.lease;

          if (!specifiedBlobName) {
            specifiedBlobName = path.basename(specifiedFileName); } ;

          specifiedBlobName = StorageUtil.convertFileNameToBlobName(specifiedBlobName);

          return utils.fileExists(specifiedFileName, __cb(_, __frame, 20, 15, function ___(__0, __4) { var __3 = !__4; return (function __$uploadAzureBlob(__then) { if (__3) {
                return _(new Error(util.format($("Local file %s doesn't exist"), specifiedFileName))); } else { __then(); } ; })(function __$uploadAzureBlob() {

              return fs.stat(specifiedFileName, __cb(_, __frame, 23, 22, function ___(__0, __5) { fsStatus = __5;
                if (!fsStatus.isFile()) {
                  return _(new Error(util.format($("%s is not a file"), specifiedFileName))); } ;


                defaultBlobTypeName = "BLOCK";

                if ((specifiedFileName.indexOf(".vhd") === ((specifiedFileName.length - 4)))) {
                  defaultBlobTypeName = "PAGE"; } ;

                blobTypeName = (options.blobtype || defaultBlobTypeName);
                validation.isValidEnumValue(blobTypeName, Object.keys(BlobConstants.BlobTypes));
                specifiedBlobType = BlobConstants.BlobTypes[blobTypeName.toUpperCase()];

                sizeLimit = StorageUtil.MaxBlockBlobSize;
                if ((specifiedBlobType === BlobConstants.BlobTypes.APPEND)) {
                  sizeLimit = StorageUtil.MaxAppendBlobSize; } else {
                  if ((specifiedBlobType === BlobConstants.BlobTypes.PAGE)) {
                    sizeLimit = StorageUtil.MaxPageBlobSize; } ; } ;

                if ((fsStatus.size > sizeLimit)) {
                  return _(new Error(util.format($("The local file size %d exceeds the Azure blob size limit %d"), fsStatus.size, sizeLimit))); } ;


                tips = ""; return (function __$uploadAzureBlob(__then) {
                  if ((force !== true)) {
                    blobProperties = null; return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$uploadAzureBlob() { return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$uploadAzureBlob() {

                                tips = util.format($("Checking blob %s in container %s"), specifiedBlobName, specifiedContainerName);
                                startProgress(tips);
                                propertiesOperation = getStorageBlobOperation(blobService, "getBlobProperties");
                                return performStorageOperation(propertiesOperation, __cb(_, __frame, 54, 25, function ___(__0, __6) { blobProperties = __6; __then();
                                }, true), specifiedContainerName, specifiedBlobName, storageOptions); }); })(function ___(e, __result) { __catch(function __$uploadAzureBlob() { if (e) {

                                  if (!StorageUtil.isNotFoundException(e)) {
                                    return _(e); } ; __then(); } else { _(null, __result); } ; }, _); }); })(function ___() { __tryCatch(_, function __$uploadAzureBlob() { _(null, null, true); }); }); }); })(function ___(__e, __r, __cont) { (function ___(__then) { __tryCatch(_, function __$uploadAzureBlob() {


                            endProgress(); __then(); }); })(function ___() { __tryCatch(_, function ___() { if (__cont) { __then(); } else { _(__e, __r); }; }); }); }); })(function ___() { __tryCatch(_, function __$uploadAzureBlob() { return (function __$uploadAzureBlob(__then) {


                          if ((blobProperties !== null)) { return (function __$uploadAzureBlob(__then) {
                              if ((blobProperties.blobType !== specifiedBlobType)) {
                                return _(new Error(util.format($("BlobType mismatch. The current blob type is %s"), blobProperties.blobType))); } else {


                                return interaction.confirm(util.format($("Do you want to overwrite the blob %s in container %s? "), specifiedBlobName, specifiedContainerName), __cb(_, __frame, 69, 27, function ___(__0, __8) { var __7 = !__8; return (function __$uploadAzureBlob(__then) { if (__7) { return _(null); } else { __then(); } ; })(__then); }, true)); } ; })(__then); } else { __then(); } ; })(__then); }); }); } else { __then(); } ; })(function __$uploadAzureBlob() {







                  tips = util.format($("Uploading %s to blob %s in container %s"), specifiedFileName, specifiedBlobName, specifiedContainerName);
                  operation = getStorageBlobOperation(blobService, "createBlockBlobFromLocalFile");
                  storageOptions.parallelOperationThreadCount = (options.concurrenttaskcount || storageOptions.parallelOperationThreadCount);
                  printer = StorageUtil.getSpeedPrinter(summary);
                  intervalId = -1;
                  if (!logger.format().json) {
                    intervalId = setInterval(printer, 1000); } ;

                  startProgress(tips);
                  endProgress(); return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$uploadAzureBlob() { return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$uploadAzureBlob() {

                              if ((blobTypeName.toLowerCase() === "page")) {

                                operation = getStorageBlobOperation(blobService, "createPageBlobFromLocalFile"); } else {
                                if ((blobTypeName.toLowerCase() === "block")) {

                                  operation = getStorageBlobOperation(blobService, "createBlockBlobFromLocalFile"); } else {
                                  if ((blobTypeName.toLowerCase() === "append")) {

                                    storageOptions.absorbConditionalErrorsOnRetry = true;
                                    operation = getStorageBlobOperation(blobService, "createAppendBlobFromLocalFile"); } ; } ; } ;

                              return performStorageOperation(operation, __cb(_, __frame, 99, 6, __then, true), specifiedContainerName, specifiedBlobName, specifiedFileName, storageOptions); }); })(function ___(e, __result) { __catch(function __$uploadAzureBlob() { if (e) {

                                printer(true);
                                return _(e); } else { _(null, __result); } ; }, _); }); })(function ___() { __tryCatch(_, function __$uploadAzureBlob() { _(null, null, true); }); }); }); })(function ___(__e, __r, __cont) { (function ___(__then) { __tryCatch(_, function __$uploadAzureBlob() {

                          printer(true);
                          clearInterval(intervalId); __then(); }); })(function ___() { __tryCatch(_, function ___() { if (__cont) { __then(); } else { _(__e, __r); }; }); }); }); })(function ___() { __tryCatch(_, function __$uploadAzureBlob() {

                      extendOption = __.extend(StorageUtil.getStorageAccountOptions(options), { speedSummary: summary });
                      return showAzureBlob(specifiedContainerName, specifiedBlobName, extendOption, __cb(_, __frame, 108, 4, function __$uploadAzureBlob() { _(); }, true)); }); }); }); }, true)); }); }, true)); }, true)); }, true)); }); };





  function downloadAzureBlob(container, blobName, destination, options, _) { var blobService, specifiedContainerName, specifiedFileName, specifiedBlobName, dirName, fileName, isDirectory, force, fsStatus, structure, fullName, tips, storageOptions, operation, summary, printer, intervalId, downloadBlob, calcTips, blobProperties, propertiesOperation, downloadedBlob; var __frame = { name: "downloadAzureBlob", line: 1277 }; return __func(_, this, arguments, downloadAzureBlob, 4, __frame, function __$downloadAzureBlob() {
      blobService = getBlobServiceClient(options);
      return interaction.promptIfNotGiven($("Container name: "), container, __cb(_, __frame, 2, 45, function ___(__0, __2) { specifiedContainerName = __2;

        specifiedFileName = (destination || ".");
        return interaction.promptIfNotGiven($("Blob name: "), blobName, __cb(_, __frame, 5, 40, function ___(__0, __3) { specifiedBlobName = __3;
          dirName = "";
          fileName = "";
          isDirectory = false;
          force = options.quiet; return (function __$downloadAzureBlob(__then) {
            if (utils.pathExistsSync(specifiedFileName)) {
              return fs.stat(specifiedFileName, __cb(_, __frame, 11, 24, function ___(__0, __4) { fsStatus = __4;
                isDirectory = fsStatus.isDirectory(); __then(); }, true)); } else {

              if (((specifiedFileName === ".") || ((specifiedFileName.length && (specifiedFileName[(specifiedFileName.length - 1)] === path.sep))))) {

                isDirectory = true; } ; __then(); } ; })(function __$downloadAzureBlob() {



            if (isDirectory) {
              dirName = specifiedFileName;
              fileName = ""; }
             else {
              fileName = path.basename(specifiedFileName);
              dirName = path.dirname(specifiedFileName); } ;


            return utils.fileExists(dirName, __cb(_, __frame, 28, 15, function ___(__0, __6) { var __5 = !__6; return (function __$downloadAzureBlob(__then) { if (__5) {
                  return _(new Error(util.format($("Local directory %s doesn't exist"), dirName))); } else { __then(); } ; })(function __$downloadAzureBlob() {


                if (!fileName) {
                  structure = StorageUtil.getStructureFromBlobName(specifiedBlobName);
                  fileName = structure.fileName;
                  fileName = utils.escapeFilePath(fileName);
                  structure.dirName = StorageUtil.recursiveMkdir(dirName, structure.dirName);
                  fileName = path.join(structure.dirName, fileName);








                  dirName = (path.isAbsolute(fileName) ? "" : "."); } ;


                fullName = path.join(dirName, fileName); return (function __$downloadAzureBlob(_) {
                  var __1 = (force !== true); if (!__1) { return _(null, __1); } ; return utils.fileExists(fullName, __cb(_, __frame, 50, 32, _, true)); })(__cb(_, __frame, -1276, 18, function ___(__0, __7) { return (function __$downloadAzureBlob(__then) { if (__7) {
                      return interaction.confirm(util.format($("Do you want to overwrite %s? "), fullName), __cb(_, __frame, 51, 23, function ___(__0, __9) { var __8 = !__9; return (function __$downloadAzureBlob(__then) { if (__8) { return _(null); } else { __then(); } ; })(__then); }, true)); } else { __then(); } ; })(function __$downloadAzureBlob() {



                    tips = util.format($("Download blob %s in container %s to %s"), specifiedBlobName, specifiedContainerName, fullName);
                    storageOptions = getStorageBlobOperationDefaultOption();
                    operation = getStorageBlobOperation(blobService, "getBlobToLocalFile");
                    storageOptions.parallelOperationThreadCount = (options.concurrenttaskcount || storageOptions.parallelOperationThreadCount);
                    summary = new SpeedSummary(specifiedBlobName);
                    storageOptions.speedSummary = summary;
                    storageOptions.disableContentMD5Validation = !options.checkmd5;
                    storageOptions.leaseId = options.lease;
                    storageOptions.snapshotId = options.snapshot;

                    startProgress(tips);
                    endProgress();
                    printer = StorageUtil.getSpeedPrinter(summary);
                    intervalId = -1;
                    if (!logger.format().json) {
                      intervalId = setInterval(printer, 1000); } ;

                    downloadBlob = { }; return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$downloadAzureBlob() { return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$downloadAzureBlob() {

                                return performStorageOperation(operation, __cb(_, __frame, 74, 21, function ___(__0, __10) { downloadBlob = __10; __then(); }, true), specifiedContainerName, specifiedBlobName, fullName, storageOptions); }); })(function ___(e, __result) { __catch(function __$downloadAzureBlob() { if (e) {

                                  printer(true);
                                  if (StorageUtil.isNotFoundException(e)) {
                                    return _(new Error(util.format($("Can not find blob '%s' in container '%s'"), specifiedBlobName, specifiedContainerName))); }
                                   else {
                                    return _(e); } ; __then(); } else { _(null, __result); } ; }, _); }); })(function ___() { __tryCatch(_, function __$downloadAzureBlob() { _(null, null, true); }); }); }); })(function ___(__e, __r, __cont) { (function ___(__then) { __tryCatch(_, function __$downloadAzureBlob() {


                            printer(true);
                            clearInterval(intervalId); __then(); }); })(function ___() { __tryCatch(_, function ___() { if (__cont) { __then(); } else { _(__e, __r); }; }); }); }); })(function ___() { __tryCatch(_, function __$downloadAzureBlob() { return (function __$downloadAzureBlob(__then) {


                          if (options.checkmd5) {
                            calcTips = $("Calculating content md5");
                            blobProperties = { };
                            startProgress(calcTips); return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$downloadAzureBlob() {

                                  propertiesOperation = getStorageBlobOperation(blobService, "getBlobProperties");
                                  return performStorageOperation(propertiesOperation, __cb(_, __frame, 93, 25, function ___(__0, __11) { blobProperties = __11; _(null, null, true);
                                  }, true), specifiedContainerName, specifiedBlobName, storageOptions); }); })(function ___(__e, __r, __cont) { (function ___(__then) { __tryCatch(_, function __$downloadAzureBlob() {

                                    endProgress(); __then(); }); })(function ___() { __tryCatch(_, function ___() { if (__cont) { __then(); } else { _(__e, __r); }; }); }); }); })(function ___() { __tryCatch(_, function __$downloadAzureBlob() {


                                blobProperties.contentSettings = (blobProperties.contentSettings || { });
                                downloadBlob.contentSettings = (downloadBlob.contentSettings || { });

                                if (!blobProperties.contentSettings.contentMD5) {
                                  logger.warn(util.format($("Blob contentMd5 is missing, and the local file md5 is %s"), downloadBlob.contentSettings.contentMD5)); }
                                 else {
                                  if ((blobProperties.contentSettings.contentMD5 === downloadBlob.contentSettings.contentMD5)) {
                                    logger.info(util.format($("Md5checksum validation passed, and md5checksum is %s"), downloadBlob.contentSettings.contentMD5)); }
                                   else {
                                    return _(new Error(util.format($("Md5checksum validation failed. Blob md5 is %s, but local file md5 is %s"), blobProperties.contentSettings.contentMD5, downloadBlob.contentSettings.contentMD5))); } ; } ; __then(); }); }); } else { __then(); } ; })(function __$downloadAzureBlob() {




                          return getAzureBlobProperties(specifiedContainerName, specifiedBlobName, options, __cb(_, __frame, 113, 25, function ___(__0, __12) { downloadedBlob = __12;
                            if (downloadedBlob) {
                              downloadedBlob["fileName"] = fullName; } ;


                            downloadedBlob = StorageUtil.embedTransferSummary(downloadedBlob, summary);
                            cli.interaction.formatOutput(downloadedBlob, function(data) {
                              logger.info(util.format($("File saved as %s"), data.fileName)); }); _(); }, true)); }); }); }); }); }, true)); }); }, true)); }); }, true)); }, true)); }); };






  function snapshotAzureBlob(container, blobName, options, _) { var blobService, snapshotOperation, snapshotOptions, snapshotTime, tips, result; var __frame = { name: "snapshotAzureBlob", line: 1404 }; return __func(_, this, arguments, snapshotAzureBlob, 3, __frame, function __$snapshotAzureBlob() {
      blobService = getBlobServiceClient(options);
      return interaction.promptIfNotGiven($("Container name: "), container, __cb(_, __frame, 2, 28, function ___(__0, __1) { container = __1;
        return interaction.promptIfNotGiven($("Blob name: "), blobName, __cb(_, __frame, 3, 27, function ___(__0, __2) { blobName = __2;
          snapshotOperation = getStorageBlobOperation(blobService, "createBlobSnapshot");
          snapshotOptions = getStorageBlobOperationDefaultOption();

          tips = $("Creating a storage blob snapshot");

          startProgress(tips); return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$snapshotAzureBlob() { return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$snapshotAzureBlob() {


                      snapshotOptions.leaseId = options.lease;
                      return performStorageOperation(snapshotOperation, __cb(_, __frame, 13, 21, function ___(__0, __3) { snapshotTime = __3; __then(); }, true), container, blobName, snapshotOptions); }); })(function ___(e, __result) { __catch(function __$snapshotAzureBlob() { if (e) {

                        if (StorageUtil.isNotFoundException(e)) {
                          return _(new Error(util.format($("Blob %s in Container %s doesn't exist"), blobName, container))); }
                         else {
                          return _(e); } ; __then(); } else { _(null, __result); } ; }, _); }); })(function ___() { __tryCatch(_, function __$snapshotAzureBlob() { _(null, null, true); }); }); }); })(function ___(__e, __r, __cont) { (function ___(__then) { __tryCatch(_, function __$snapshotAzureBlob() {


                  endProgress(); __then(); }); })(function ___() { __tryCatch(_, function ___() { if (__cont) { __then(); } else { _(__e, __r); }; }); }); }); })(function ___() { __tryCatch(_, function __$snapshotAzureBlob() {


              result = {
                snapshot: snapshotTime,
                url: util.format((blobService.getUrl(container, blobName) + "?snapshot=%s"), snapshotTime) };

              cli.interaction.formatOutput(result, function(data) {
                logger.info(util.format(util.format("The blob snapshot %s is created "), data.url));
                logger.data($("Snapshot Time: "), data.snapshot);
                logger.data($("URL: "), data.url); }); _(); }); }); }, true)); }, true)); }); };






  function applyBlobServicePatch(blobService) {





    blobService.listAllContainers = function(options, callback) {
      StorageUtil.listWithContinuation(blobService.listContainersSegmentedWithPrefix, blobService, StorageUtil.ListContinuationTokenArgIndex.Container, options.prefix, null, options, callback); };






    blobService.listAllBlobs = function(container, options, callback) {
      StorageUtil.listWithContinuation(blobService.listBlobsSegmentedWithPrefix, blobService, StorageUtil.ListContinuationTokenArgIndex.Blob, container, options.prefix, null, options, callback); }; };






  function startBlobCopy(sourceUri, destContainer, options, _) { var startCopyParams; var __frame = { name: "startBlobCopy", line: 1464 }; return __func(_, this, arguments, startBlobCopy, 3, __frame, function __$startBlobCopy() {
      startCopyParams = StorageUtil.getStartCopyParameters(StorageUtil.CopyTypes.CopyToBlob, sourceUri, options);
      return StorageUtil.startAsyncCopy(startCopyParams, destContainer, options, __cb(_, __frame, 2, 16, function __$startBlobCopy() { _(); }, true)); }); };





  function showBlobCopy(container, blob, options, _) { var showCopyParams; var __frame = { name: "showBlobCopy", line: 1472 }; return __func(_, this, arguments, showBlobCopy, 3, __frame, function __$showBlobCopy() {
      showCopyParams = {
        type: StorageUtil.CopyTypes.CopyToBlob,
        getProperties: getAzureBlobProperties };


      return StorageUtil.showAsyncCopy(showCopyParams, container, blob, options, __cb(_, __frame, 6, 16, function __$showBlobCopy() { _(); }, true)); }); };





  function stopBlobCopy(container, blob, copyid, options, _) { var getStopOperation, stopCopyParams; var __frame = { name: "stopBlobCopy", line: 1484 }; return __func(_, this, arguments, stopBlobCopy, 4, __frame, function __$stopBlobCopy() {
      getStopOperation = function(serviceClient) {
        var operationInfo = { };
        operationInfo.operation = getStorageBlobOperation(serviceClient, "abortCopyBlob");
        operationInfo.options = getStorageBlobOperationDefaultOption();
        operationInfo.options.leaseId = options.lease;
        return operationInfo; };


      stopCopyParams = {
        type: StorageUtil.CopyTypes.CopyToBlob,
        getStopOperation: getStopOperation };


      return StorageUtil.stopAsyncCopy(stopCopyParams, container, blob, copyid, options, __cb(_, __frame, 14, 16, function __$stopBlobCopy() { _(); }, true)); }); };


  function getAvailableBlobTypes() {
    var result = "";
    Object.keys(BlobConstants.BlobTypes).forEach(function(type) {
      result += (type.toLowerCase() + ", "); });

    return result.slice(0, -2); };};
