Upload .vhd as Page-Blob to azure-blob-storage from Url

i have a bunch of VHD files stored on a private Server, which are accessible through a url.

I am trying upload these vhd files directly to my azure storage account using the azure javascript npm libraries. The vhds have to be uploaded as page-blobs. I tried using the method uploadPagesFromURL() of the pageblobClient but with no success. My code looks roughly like this:

 async function uploadVHD(accessToken, srcUrl) 
     try {
         // Get credentials from accessToken
         const creds = new StorageSharedKeyCredential(storageAccount.name, storageAccount.key);
         // Get blobServiceClient
         const blobServiceClient = new BlobServiceClient(`https://${storageAccount.name}.blob.core.windows.net`, creds);
         // Create Container
         const containerClient = blobServiceClient.getContainerClient("vhd-images");
         await containerClient.createIfNotExists();
         const src = srcUrl.replace('https://', 'https://username:[email protected]');
         // Upload to blob storage
         const pageBlobClient = containerClient.getPageBlobClient("Test.vhd");
         // Get fileSize of 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;


It is not possible to upload the Page Blob with your URL directly. You need to read data from the url. Then upload using uploadPages method.

axios.get(URL, {
    responseType: 'arraybuffer'
    .then((response) => {
        // upload page blob...
    }).catch((error) => {
      //handle error

// uploadPages method
const uploadResponse = pageBlobClient.uploadPages(data, 0, dataLength);

Leave a Reply

Your email address will not be published. Required fields are marked *