in src/tree/blob/BlobContainerTreeItem.ts [206:273]
private async deployStaticWebsiteCore(
context: IActionContext,
sourceFolderPath: string,
destBlobFolder: string,
notificationProgress: NotificationProgress,
cancellationToken: vscode.CancellationToken
): Promise<string> {
ext.outputChannel.appendLog(localize('deploying', 'Deploying to static website "{0}/{1}"', this.root.storageAccountId, this.container.name));
const retries: number = 4;
await retry(
async (currentAttempt) => {
context.telemetry.properties.deployAttempt = currentAttempt.toString();
if (currentAttempt > 1) {
const message: string = localize('retryingDeploy', 'Retrying deploy (Attempt {0}/{1})...', currentAttempt, retries + 1);
ext.outputChannel.appendLog(message);
}
if (getWorkspaceSetting<boolean>(configurationSettingsKeys.deleteBeforeDeploy)) {
// Find existing blobs
let blobsToDelete: azureStorageBlob.BlobItem[] = [];
blobsToDelete = await this.listAllBlobs(cancellationToken);
if (blobsToDelete.length) {
const message = `The storage container "${this.friendlyContainerName}" contains ${blobsToDelete.length} files. Deploying will delete all of these existing files. Continue?`;
const deleteAndDeploy: vscode.MessageItem = { title: 'Delete and Deploy' };
const result = await vscode.window.showWarningMessage(message, { modal: true }, deleteAndDeploy, DialogResponses.cancel);
if (result !== deleteAndDeploy) {
context.telemetry.properties.cancelStep = 'AreYouSureYouWantToDeleteExistingBlobs';
throw new UserCancelledError();
}
}
// Delete existing blobs
const transferProgress = new TransferProgress('blobs', 'Deleting');
await this.deleteBlobs(blobsToDelete, transferProgress, notificationProgress, cancellationToken, context.telemetry.properties);
// Reset notification progress. Otherwise the progress bar will remain full when uploading blobs
notificationProgress.report({ increment: -1 });
}
// Upload files as blobs
await uploadLocalFolder(context, this, sourceFolderPath, destBlobFolder, notificationProgress, cancellationToken, 'Uploading');
},
{
retries,
minTimeout: 2 * 1000,
onFailedAttempt: error => {
const parsedError: IParsedError = parseError(error);
if (/server failed to authenticate/i.test(parsedError.message)) {
// Only retry if we see this error
return;
} else if (parsedError.isUserCancelledError) {
ext.outputChannel.appendLog("Deployment canceled.");
}
throw error;
}
}
);
const webEndpoint = this.getPrimaryWebEndpoint();
if (!webEndpoint) {
throw new Error(`Could not obtain the primary web endpoint for ${this.root.storageAccountName}`);
}
ext.outputChannel.appendLog(`Deployment to static website complete. Primary web endpoint is ${webEndpoint}`);
return webEndpoint;
}