Code Monkey home page Code Monkey logo

compute-node-manage-vm's Introduction

page_type languages products description urlFragment
sample
javascript
azure
azure-nodejs
azure-resource-manager
azure-storage
azure-virtual-network
azure-virtual-machines
This sample demonstrates how to manage your Azure virtual machines using a Node.js client and specifically how to: create a virtual machine, start a virtual machine, stop a virtual machine, list virtual machines, delete a virtual machine
compute-node-manage-vm

Azure Virtual Machines Management Samples - Node.js

This sample demonstrates how to manage your Azure virtual machines using a Node.js client and specifically how to:

  • Create a virtual machine
  • Start a virtual machine
  • Stop a virtual machine
  • List virtual machines
  • Delete a virtual machine

On this page

Run this sample

  1. If you don't already have it, get Node.js.

  2. Clone the repository.

    git clone https://github.com/Azure-Samples/compute-node-manage-vm.git
    
  3. Install the dependencies.

    cd compute-node-manage-vm
    npm install
    
  4. Create an Azure service principal either through Azure CLI:

    az ad sp create-for-rbac --name YOUR-SERVICE-PRINCIPAL-NAME
    

    Other ways to create a service principal:

  5. Set the following environment variables using the information from the service principle that you created.

    export AZURE_SUBSCRIPION_ID={your subscription id}
    export AZURE_CLIENT_ID={your client/app id}
    export AZURE_CLIENT_SECRET={your client secret/password}
    export AZURE_TENANT_ID={your tenant id as a guid OR the domain name of your org <contosocorp.com>}
    

    [AZURE.NOTE] On Windows, use set instead of export.

  6. Run the sample.

    node index.js
    

    When this script is complete, it returns success YOUR-RESOURCE-GRUOP-NAME.

  7. To clean up after index.js, run the cleanup script, using the resource group name from the previous script's success statement.

    node cleanup.js YOUR-RESOURCE-GRUOP-NAME
    

What does index.js do?

The sample creates, lists, restarts and deletes virtual machines. It starts by logging in using your service principal.

More information

Please refer to Azure SDK for Node for more information. Additionally, here some other helpful links:

If you don't have a Microsoft Azure subscription you can get a FREE trial account here.

compute-node-manage-vm's People

Contributors

acomsmpbot avatar allclark avatar amarzavery avatar colawwj avatar dependabot[bot] avatar diberry avatar eduardkoller avatar jamezrin avatar thraka avatar v-hearya avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

compute-node-manage-vm's Issues

RestError While Creating NIC

Hi, Im getting a RestError when trying to run the index.js file (my code is the same as in the example)
I cant find the the reason why am i getting this error, can someone help me pls

Error:

RestError: Cannot parse the request. 
 {
  "name": "RestError",
  "code": "InvalidRequestFormat",
  "statusCode": 400,
  "request": {
    "url": "https://management.azure.com/subscriptions/..../resourceGroups/diberry-testrg3095/providers/Microsoft.Network/networkInterfaces/diberrynic7245?api-version=2021-05-01",
    "headers": {
      "content-type": "application/json",
      "accept": "application/json",
      "accept-encoding": "gzip,deflate",
          "message": "Value for reference id is missing. Path properties.ipConfigurations[0].properties.publicIPAddress."        
        }
      ]
    }
  },
  "message": "Cannot parse the request."
}

Code:

async function createNIC(subnetInfo, publicIPInfo) {
  console.log("\n5.Creating Network Interface: " + networkInterfaceName);
  const nicParameters = {
    location: location,
    ipConfigurations: [
      {
        name: ipConfigName,
        privateIPAllocationMethod: "Dynamic",
        subnet: subnetInfo,
        publicIPAddress: publicIPInfo,
      },
    ],
  };
  return await networkClient.networkInterfaces.beginCreateOrUpdateAndWait(
    resourceGroupName,
    networkInterfaceName,
    nicParameters
  );
}

Thank You

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.