Transfer the .vhd file as a Page Blob to Azure Blob Storage using a URL

I have a collection of VHD files stored on a secure server, accessible via URL links.

My goal is to transfer these VHD files directly to my Azure storage account using the Azure JavaScript npm libraries. The VHDs must be uploaded as page-blobs, but I encountered issues when attempting to use the uploadPagesFromURL() method of the pageBlobClient. Here is a simplified version of the code I tried:

 async function uploadVHD(accessToken, srcUrl) 
 {
     try {
         // Obtain credentials from access token
         const creds = new StorageSharedKeyCredential(storageAccount.name, storageAccount.key);
         // Acquire 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:password@');
           
         // Upload to blob storage
         const pageBlobClient = containerClient.getPageBlobClient("Test.vhd");
         // Retrieve file size 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;
     }
 });

Answer №1

Uploading the Page Blob with your URL directly is not supported. You must first retrieve the data from the URL and then use the uploadPages method to upload it.

axios.get(URL, {
    responseType: 'arraybuffer'
  })
    .then((response) => {
        console.log(response.data)
        console.log(response.data.length)
        // Perform page blob upload here...
    }).catch((error) => {
      // Handle any errors
    });

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

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Configuring webpack to serve static HTML files alongside a React application involves setting up the necessary webpack configuration to handle both types

I'm attempting to create a React app using Webpack that reserves specific paths for HTML static files without actually importing them into the React app. Here's an example: Expected Outcome: localhost:3000/any/other/path -> load React localho ...

Having trouble fetching JSON data using Ajax in Flask

I am working on creating a straightforward web application for displaying logs. The backend is powered by Python 3.4 and Flask, while the frontend consists of a simple web form with AJAX integration. Flask: import json from flask import Flask, jsonify, r ...

Tips for preventing the caret (^) symbol from being added to a package when installing with yarn

Is there a way to prevent Yarn from adding the caret prefix to version numbers when installing packages like npm has for changing version prefix (https://docs.npmjs.com/misc/config#save-prefix)? I would like to apply this configuration only for the current ...

TypeScript encounters difficulty in locating the namespace within a Node.js dependency

I am faced with a situation where I have two node.js packages that each contain type declaration files. In package a, there is a namespace declared that I want to reference in package b. Package A index.d.ts declare namespace foo { export interface A ...

Failure to reload the page occurs when trying to invoke a React component via the Link and transferring the props

Having just started with React and TypeScript, I'm encountering an issue where the page fails to reload when I refresh the browser. I suspect that I am not setting the state of the class I am reloading properly. Can someone please assist with the foll ...

Capture all HTTP requests made by Angular2

I'm trying to find a way to intercept and modify all HTTP requests made by Angular by adding custom headers. In previous releases prior to angular2 RC5, this was achieved by extending the BaseRequestOptions like this: class MyOptions extends BaseRequ ...

The imgAreaSelect plugin is up and running successfully. Now, I am looking to utilize the x and y coordinates to make updates to the image stored in the database. How can I

After retrieving the dimensions and coordinates from the jQuery plugin imgAreaSelect, I am looking for guidance on how to update the image in my database based on this selection. The database contains a tempImage and Image field, and my goal is to allow ...

Creating spec.ts files for components by hand: A guide

Currently, I am facing an issue where the automatic generation of spec.ts files has been disabled by the developers when they created the components. To address this, I manually created the spec.ts files by copying over an existing one into each component, ...

Reorganizing array elements to match the order of another array in ES6

I am attempting to organize one array based on the order of another array... For instance... (Utilizing ES6 React) const orderArr = ["Daniel","Lucas","Gwen","Henry","Jasper"]; const nameArr = ["Gwen","Jasper","Daniel"]; in order to output Daniel // fi ...

Credit for the Position swipejs

After integrating a swipeJS photo slideshow into my jQuery mobile application, I encountered an issue. I am trying to create points for counting the pictures similar to what is seen on this page: Although I have added the necessary HTML and CSS code to my ...

When sending an ajax request with HTML data as the payload

While working on an MVC program, I encountered an issue when trying to send data from a TextArea to the controller upon a button click. Everything worked fine until I had HTML-based data inside the TextArea. Here's a snippet of the HTML code: <te ...

What is the best way to add multiple rows using a parameter in SQL?

My goal is to insert multiple rows in SQLite using the ionic framework. Inserting a single row works fine, as does running the following query: INSERT INTO categories (category_id, category_name, category_type) VALUES (1,"test",1),(2,"test again", 2); ...

What are some ways to disable text selection when working with VueJS?

Let's say I have a component that displays some text. When I click on the text at the beginning and then shift-click on another part, the text between those two points gets selected. Is there a way to prevent this behavior using only VueJS? ...

Angular Material Tooltips

Seeking help on showcasing an array of elements in a list format using mat-angular tooltip. This code snippet belongs to app.component.html <button mat-raised-button matTooltip={{items}} aria-label="Button that displays a tooltip when focu ...

What is the method for setting the proxy URL in Webpack.config.js following the deployment of the application?

When running on my local machine, the React front-end is hosted on localhost:3000 while the Node/Express back-end is hosted on localhost:8080. Within the webpack.config.js file for the front-end, I utilize a proxy to enable the front-end to retrieve data ...

Assistance required in designing a unique shape using Three.js

https://i.sstatic.net/pmHP2.png Hello there! I could use some assistance with replicating the 2D shape shown in the image above using three.js. Specifically, I'm encountering some difficulty with incorporating the subtle curvature seen on the inner l ...

Validation of the top-level URL

How can I validate or filter only the top-level URL/domain using JavaScript or PHP? This filter should also accept new domain extensions, for example: Valid URL: and so on... Invalid URL: and so on... Subdomains are also not allowed! I need this val ...

Display conceal class following successful ajax response

Upon clicking the button, the following script is executed: $.ajax({ url: "<?php echo CHILD_URL; ?>/takeaway-orders.php", type: 'POST', async:false, data: 'uniq='+encodeURIComponent(uniq)+'&menu_id=' ...

Attempting to transform Go Pro GYRO data into rotational values using Three.js

I am currently working on converting gyro data from Go Pro to Three.js coordinates in order to project the footage onto the inside of a sphere. My goal is to rotate the sphere and achieve 3D stabilization. https://i.sstatic.net/VYHV6.png The camera' ...

Close ui-bootstrap typeahead menu only when a row is manually chosen

I have set up this jsBin to show the problem I am facing. When you visit the link and try to type "Five," the expected behavior would be to type "Five" and then press tab. However, in this case, you need to type "Five" and then either escape or click outsi ...