Azure Restart VM
Objective
The goal of the tutorial is to Restart the Azure Virtual Machine(s) using FlexDeploy Azure plugin operation. This automation includes:
Restart the Azure Virtual Machine using One or more Virtual Machine Id(s) / Virtual Machine Name and Resource group Name using Azure CLI.
We will walk through each of the FlexDeploy features that needs to be created/configured to accomplish this goal and restart the Virtual Machine in a very short amount of time.
Checklist
Checklist | Description |
---|---|
Azure Tenant Id | Azure Tenant Id for the company. |
Azure Subscription Id | Azure Subscription where the Virtual Machine exists. |
Azure Client ID | Client ID to connect to desired Azure Subscription. |
Azure Client Key | Password for the Client ID |
Virtual Machine Name | The Name of the Virtual Machine to restart. |
Virtual Machine Resource Id(s) | Provide either comma or space separated Resource Ids of the Virtual Machine(s). |
Azure Resource Group | The Resource Group containing the Virtual Machine. |
Azure CLI installation | Azure CLI needs to be installed where the plugin operation shall run (preferably FlexDeploy server) |
Azure CLI in class path | Azure CLI should be added to class path in the Server of execution. Else the path can also be set under FlexDeploy environment level property. |
Configure cloud account
First, an Azure account needs to be configured under Integrations. FlexDeploy will connect to the right Azure Subscription with provided details and restarts the Virtual Machine(s).
Select Integrations from the FlexDeploy Menu and navigate to the Cloud tab from the left-hand pane.
Create a new Cloud account with the “+ Create” button.
Provide the Cloud Account name.
Also provide the Cloud Account code.
Select “Azure” as Cloud Provider from drop down as shown below.
It should have a Client ID, Client Key, Tenant Id, and Subscription Id configured in it. The Client ID must have relevant access to the Virtual Machine and make other associated changes(Application Setting update etc).
Integration Instance Properties:
Property Name | Value for this tutorial | Mandatory | Description |
---|---|---|---|
Username |
| No | User name for the registered Azure account |
Password |
| No | Password for the registered Azure account. |
Subscription Id | 01bc8c42-614c-4d8c-a7c2-608d22e8407b | Yes | The subscription ID is a GUID that uniquely identifies your subscription to use Azure services. |
Tenant Id | 62968c10-0ab4-4eb8-9ba0-df1240a626eb | Yes | The tenant ID of resource. |
Azure Application Client ID | e6b83891-b341-465b-bc7e-5e522193bf40 | Yes | The Client ID assigned to Application |
Azure Application Client Key | <<Secured Value>> | Yes | The key assigned to Application |
Azure Active Directory Domain |
| No | The domain name of the AAD to access. |
Keystore Path |
| No | The path to the JKS containing the management certificate. |
Keystore Password |
| No | The password for Keystore Path |
Azure Environment |
| No | The name of the environment. |
Client Key is a password field and hence needs to be kept hidden. To update the same, click on the pencil icon as shown below.
Update the Client Key value under Secret Text. This is to make sure no one else can view/retrieve the password.
Save the credential.
Do a Test Connection. The green color ticket mark will show that the connection is successful.
After entering the credential, click on Save on the cloud instance.
Utility Workflow
Next, we shall create one Utility workflow as shown below. The Workflow Type field defines the type of workflow.
Next, create one Utility workflow as shown below. The Workflow Type field defines the type of workflow.
Utility Workflow
Navigate to the Workflows tab
Select the “+” button from the left-hand pane to create a new workflow with type as Utility.
The Workflow Group and Subgroup define the folder hierarchy. Once the workflow is created, it should look like the below. No constraint on workflow or folder naming convention.
The steps of the workflow execution can be configured through the Definition section.
Navigate to Plugin Operations section and search for Azure plugin restartVM operation.
Drag the operation under workflow execution step as shown below.
Below given is a sample utility workflow to restart the Virtual Machine.
The RestartVM operation returns three output variables. To capture them and use them for further processing/evaluation, one can create three variables and map them against the output parameters. Return As Output drop down option should be set as Yes.
First, navigate to the Workflow Definition tab and click on the Variables button.
Next use Create option to add three output variables. Return As Output is marked as true so that the workflow will return the same variables as Output. These variables can then further be used for other purposes.
Map the variables against the output of the RestartVM operation to capture the responses.
Save & Activate the workflow.
You can provide the VM Name & Resource Group or VM Resource Id(s) in the Project properties. Azure Plugin will consider the values and restart the servers.
However, one can also provide the VM Resource Id/ VM name directly to Plugin input as well as shown below.
Workflow Inputs
Property Name | Value for this tutorial | Description |
---|---|---|
Virtual Machine Resource Id(s) |
| Provide comma or space separated Virtual Machine Resource Id(s) (eg. /subscriptions/01bc8c42-614c-4d8c-a7c2-608d22e8407b/resourceGroups/srimukhi-resource-grp/providers/Microsoft.Compute/virtualMachines/srimukhi-test-vm ). |
Virtual Machine Name | srimukhi-test-vm | The name of the virtual machine to restart (eg. srimukhi-test-vm ). Requires the Resource group name (eg. srimukhi-resource-grp) to be set at Project Property when Virtual Machine name is given either as input / property |
VM Force Restart | false | Force Restart a Virtual Machine. The Default is false. |
Plugin Outputs
Output Name | Description |
---|---|
FDAZ_OUT_VM_STATUS | Captures the Virtual Machine Status code. |
FDAZ_OUT_VM_RESP | Captures the Virtual Machine Response. |
FDAZ_OUT_VM_ERR | Captures the Error Message of the Virtual Machine |
Topology
For detailed steps on how to configure the topology and map the workflows manually, please refer to Configure the Topology for Azure
Target Properties
Selecting the DEV environment mapped to the Target Group will display the configurable properties/Endpoint and allows to the configure the properties.
Provide the value for AzureCloudAccount, and AzureCLIPath(optional if set in classPath), Number of Iterations (optional, default value is 6), and Interval Duration (optional default value is 30sec) and map the localhost as Endpoint as shown below.
Target Properties Info
Property Name | Mandatory | Values for this Tutorial | Description |
---|---|---|---|
Azure Cloud Account | Yes | AzureFlexDev | The Azure Cloud Account Name configured. |
Absolute path of Azure CLI | Optional |
| The path to the directory where Azure CLI is installed. (Optional) |
Number of Iterations | Optional (default is 6) | 6 | The number of iterations to perform the status check. |
Interval between status check | Optional (default is 30) | 30 | The interval between Azure VM status check. |
Create the Azure ReStart VM Project using Blank Project
For details steps on how to configure the project and execution, please refer to Create the Azure Start/Stop/Restart VM Project
Once the VM is restarted using Azure CLI by the plugin operation, the plugin itself will check for restart status at periodic interval as mentioned above. Once the VM is up & running the plugin operation will successfully conclude.
Reports
With the successful execution of the Utility workflow, a text (.txt) file is created, stored in the reports tab. Every execution will generate a new report with execution Id appended to the text file in the Reports tab.
Click on the text file generated to see the details. This file captures the details of each instance i.e., VM Resource Id, Provision State, and Power State. In the workflow, there were two Azure VM Resource Id’s are provided as input. Hence, the report contains the details of both the Azure VM's. Also, user can download the report file generated.
Congratulations! You have successfully completed the Azure Restart Virtual Machine tutorial.
Now that you have configured FlexDeploy for one Azure VM operation, it is extremely easy to replicate the same for other Azure VM operations. Simply use the Copy Project feature and a new project will be created with all of the configuration completed already. You just need to make the necessary configuration changes.
- style