azure-cli
Version:
Microsoft Azure Cross Platform Command Line tool
921 lines (330 loc) • 87.3 kB
JavaScript
/*** 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("--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("--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("--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: 457 }; 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: 478 }; 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: 519 }; 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: 558 }; 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: 595 }; 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: 631 }; 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: 646 }; 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: 665 }; 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: 673 }; 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: 682 }; 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: 698 }; 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: 706 }; 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: 715 }; 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: 730 }; 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: 738 }; 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: 747 }; 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: 763 }; 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: 771 }; 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: 780 }; 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: 795 }; 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: 803 }; 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: 812 }; 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: 827 }; 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: 834 }; 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: 841 }; 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: 891 }; 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: 911 }; 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 {