Skip to main content

Azure Virtual Machines

The JAMS AzureVM Execution Method enables Azure virtual machine management via these actions:

  • Restart a running virtual machine
  • Start a virtual machine
  • Stop (deallocate) a virtual machine
  • Delete a virtual machine

The Execution Method has these options in its menu.

Before You Begin​

Ensure you have the following information from Azure:

  • Tenant ID
  • Client ID (Application ID) of a registered application (service principal)
  • Client Secret for the registered application
  • Subscription ID of the subscription that contains the virtual machine
  • Resource Group Name of the resource group that contains the virtual machine
  • Virtual Machine Name

The registered application must be allowed to read and control the virtual machine. The built-in Virtual Machine Contributor role on the virtual machine, its resource group, or the subscription is sufficient. If you use a custom role, it must include the following actions:

  • Microsoft.Compute/virtualMachines/read
  • Microsoft.Compute/virtualMachines/instanceView/read
  • Microsoft.Compute/virtualMachines/start/action
  • Microsoft.Compute/virtualMachines/deallocate/action
  • Microsoft.Compute/virtualMachines/restart/action
  • Microsoft.Compute/virtualMachines/delete

You can leave out the actions for operations you do not intend to run from JAMS.

note

To use the AzureVM Execution Method, ensure the JAMS Scheduler and JAMS Client are running 7.9.5 or higher.

The AzureVM Execution Method connects to the Azure public cloud. Sovereign clouds, such as Azure Government and Azure China, are not supported.

Virtual machines created in Azure DevTest Labs are not supported. DevTest Labs wraps each virtual machine in a separate lab resource that JAMS does not manage. For example, a Delete Job removes the underlying virtual machine, but the lab virtual machine remains in the lab and is reported as Corrupted.

Creating Credentials​

You need two Credentials in JAMS to run an Azure VM Job:

  • A Credential is used to store the Client Secret value from Azure in the Password field. The Logon As field can be left empty.
  • A Credential is used to run the Job in JAMS.

See Working with Credential Definitions for more information on creating a Credential.

Creating a Connection Store Item for an Azure Virtual Machine​

To connect to an Azure virtual machine, you need a Connection Store item in JAMS. See Connections for Integrations for the steps to configure the Connection.

The Connection identifies the tenant, subscription, and resource group. It can also name a virtual machine. If it does, Jobs that use the Connection default to that virtual machine, and you can override the name in each Job. If it does not, each Job must name the virtual machine.

Creating a Job for an Azure Virtual Machine​

  1. Click Definitions from the JAMS Shortcuts menu.

  2. Click a Folder where the Job will be saved.

  3. Click +.

  4. In the Name field, enter a name for the Job.

  5. In the Execution Method field, select AzureVM.

  6. Click Ok.

  7. In the Azure VM Connection field, select the Connection Store item that you created.

  8. In the Operation field, select one of the following actions:

    • Restart
    • Start
    • Stop
    • Delete
  9. In the Azure Virtual Machine Name field, enter the name of the virtual machine.
    If the Connection names a virtual machine, that name is displayed and used unless you enter a different one here. The name entered in the Job takes precedence over the name in the Connection.

  10. In the Change Timeout (In Seconds) field, enter the number of seconds to wait for the operation to finish.
    The default value is 300 seconds. Using zero will cause the Job to wait infinitely. For the Start and Stop operations, the Job fails if the virtual machine does not enter the desired power state within this wait time. For the Restart and Delete operations, the Job fails if Azure does not complete the operation within this wait time.

  11. Select the Fail on Invalid Action checkbox to set the JAMS Job to fail if the virtual machine is already in the desired state. This applies to the Start and Stop operations. If the checkbox is cleared, the JAMS Job will succeed even if the virtual machine did not require any changes. By default, this option is not enabled.

  12. Click the Schedule tab to add schedule items to set when the Job will run.

  13. Click the Properties tab.

  14. In the Execute As field, select the JAMS Credential to run the Job.

  15. In the Agent field, select the Agent if the Job will not run on the Scheduler.

  16. Click Save and Close.

How the Operations Work​

OperationWhat JAMS doesWhen the Job succeeds
StartPowers on the virtual machine.The virtual machine reports the running power state.
StopDeallocates the virtual machine. Deallocating releases the compute resources, so the virtual machine stops incurring compute charges.The virtual machine reports the deallocated power state.
RestartRestarts the virtual machine and waits for Azure to report that the restart is complete. The virtual machine must be running. Restarting a stopped virtual machine fails.Azure reports the restart as complete.
DeleteDeletes the virtual machine resource and waits for Azure to report that the deletion is complete.Azure reports the deletion as complete.

The Job log records each power state the virtual machine passes through while JAMS waits.

Before running any operation, JAMS confirms that the virtual machine exists. If it cannot be found, the Job fails. This means a Delete Job fails when the virtual machine has already been deleted, whether or not Fail on Invalid Action is selected.

note

The Delete operation removes the virtual machine resource. Whether the OS disk, data disks, network interface, and public IP address are deleted with it depends on the delete options configured on the virtual machine in Azure. Review those options before scheduling a Delete Job. A deleted virtual machine cannot be recovered.

Canceling the Job​

You can cancel a JAMS Job that is running an action on an Azure virtual machine. When the Job is canceled, it will fail and stop waiting for the operation to finish. The action being performed on the virtual machine may not be canceled.

  1. Click Monitor from the JAMS Shortcuts menu.
  2. Right-click the Job that is running and select Cancel.
  3. Click Yes.