Download .vhd as page blob to azure blob storage.

Reinhard Sanz 1 Reputation point

Hey, i am currently using the azure javascript sdk, and would like to copy a .vhd file, from a private remote server (with username and password), to my azure storage account. The file has to be copied into the blob-storage as a page blob. Creating the storage account and the container is no problem, but i am not able to copy the file to the storage. Has anyone ever tried this, and can someone provide some help?


Azure Blob Storage
Azure Blob Storage
An Azure service that stores unstructured data in the cloud as blobs.
1,702 questions
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. deherman-MSFT 27,411 Reputation points Microsoft Employee

    @Reinhard Sanz
    Please check the sample code here which shows how to work with page blobs using the azure-sdk-for-js. You might also find this issue on GitHub for uploadPages helpful.

    If you are still having issues please share the code you are working with and we will be happy to take a further look. I also recommend posting this over on StackOverflow to be engaged with more JavaScript experts.


    Please don’t forget to "Accept the answer" and “up-vote” wherever the information provided helps you, this can be beneficial to other community members.

    1 person found this answer helpful.

  2. Reinhard Sanz 1 Reputation point

    Hey, I looked through the samples you sent which were somewhat helpful, sadly the method syncCopyPagesFromURL() isn't explained in these. And when trying to use this method i get one of 2 errors. I guess i am using the method wrong but i can't find alot of info about how to use it. When trying to upload a file from a public Url i get the following:
    RestError: The value for one of the HTTP headers is not in the correct format.
    When trying to upload a file from a private Url i get the following:
    RestError: Could not verify the copy source within the specified time.

    I didn't find a way to set the headers for authentication for my download source so i tried authenticating with username:password@/.../...

    Also i am able to upload from public url using the blockBlobClient, so i don't think there is a problim with the Shared Access Signature.

    The code in question roughly looks something like this:

    function uploadVHD(accessToken, )   
        try {  
            // Get credentials from accessToken  
            const creds = new StorageSharedKeyCredential(, storageAccount.key);  
            // Get blobServiceClient  
            const blobServiceClient = new BlobServiceClient(`https://${}`, creds);  
            // Create Container  
            const containerClient = blobServiceClient.getContainerClient("vhd-images");  
            await containerClient.createIfNotExists();  
            const src = req.body.payload.image.srcUrl.replace('https://', 'https://username:password@');  
            // Upload to blob storage  
            const pageBlobClient = containerClient.getPageBlobClient("Test.vhd");  
            const fileSize = (await axiosRequest(src, { method: "HEAD" })).headers["content-length"];  
            const uploadResponse = await pageBlobClient.uploadPagesFromURL(src, 0, 0, fileSize);  
            return uploadResponse;  
        } catch (error) {  
            return error;