Create AutoStopping Rules for Azure

Updated 1 week ago by Archana Singh

AutoStopping Rules make sure that your non-production resources run only when used, and never when idle. It also allows you to run your workloads on fully orchestrated spot instances without any worry of spot interruptions.

In this topic:

Before You Begin

Prerequisites

  • Ensure that you have Azure on-demand VMs created
  • Make sure that you have the Application Administrator role assigned for your Azure AD. Users in this role can create and manage all aspects of enterprise applications, application registrations, and application proxy settings. See Application Administrator
  • Many Azure CLI commands act within a subscription. Ensure that you have selected the right subscription before executing the commands. If you need to switch the subscription, use the following command:
    az account set -s <subs id/name>
    For more information, see Manage Subscriptions
  • Permissions to create an application gateway:
    • A dedicated subnet with no other resources
    • A public IP belonging to the same VPN as the application gateway
      • SKU : Basic for V1 Application gateway and Standard for V2 application gateway
      • Type : Static or Dynamic
  • Permissions to create Azure function and a dedicated storage account
  • SSL certificate in *.pfx format to support HTTPS traffic if required. You can use a wild card certificate or specific to the domain certificate

Step 1: Add a Cloud Provider

Perform the following steps to link your Azure cloud account to Harness.

  1. In Cloud Costs, click New AutoStopping Rule.
  2. In AutoStopping Rules, select Azure. It is the cloud account in which your workloads are running that you want to manage using AutoStopping rules.
  3. If you have already linked your Azure account and want to use that account, then select the Azure account from Connect to your Azure account drop-down list.
  4. If you have not added your cloud account, click + Link a new Azure account. For the detailed steps, see Connect to an Azure Connector.

Step 2: Add a New AutoStopping Rule

Perform the following steps to add a new AutoStopping rule for Azure:

Step 1: Define an AutoStopping Rule

Perform the following steps to get started with AutoStopping Rule.

  1. In Cloud Costs, in AutoStopping Rules, click New AutoStopping Rule.
  2. In the cloud account type, select Azure. It is the cloud account in which your workloads are running that you want to manage using AutoStopping rules.
  3. Select your Azure account from the Connect to your Azure account drop-down list and click Next.

    If you have not added an Azure cloud account, see Connect to an Azure Connector.
  4. In Define your AutoStopping rule, in Name your Rule, enter a name for your rule. This is the name of your AutoStopping rule.
  5. In Idle time, enter the idle time in minutes. This is the time that the AutoStopping rule will wait before stopping the idle instances.
    AutoStopping will shut down (for on-demand) or snapshot and terminate (for spot) the instances after the idle time period has elapsed.

Step 2: Select the Resources to be Managed by the AutoStopping Rule

Select the cloud resources that you want to manage using this rule. AutoStopping Rule will monitor the selected resources and stop them when they are idle beyond the configured idle time.

Option 1: Select Instances

You can add multiple instances to a single Rule. However, all the VMs should be part of the same region.
  1. Select Instances and click Add an Instance.
  2. Select the instances that you want to manage using the AutoStopping rules. You can use the search option to search the instances.
  3. Once you have finished selecting the instances, click Add selected.
Option 2: Select Kubernetes Clusters

Add a cluster to be managed by the AutoStopping Rule.

  1. Select Kubernetes Cluster and then click Add a cluster.
  2. Select the Kubernetes cluster that you want to manage using the AutoStopping rules. If you wish to create a new connector for the Kubernetes cluster, see Create a Kubernetes Connector for AutoStopping Rules.
  3. Once you have finished selecting the Kubernetes cluster, click Add selected.
    If you select a Kubernetes cluster, follow the steps in Create AutoStopping Rules for Kubernetes Cluster.

Step 3: Select the Instance Fulfillment Type

For Azure instances, only On-Demand fulfillment type is supported.
  1. Select On demand.

(Optional) Step 4: Set Up Advanced Configuration

In this step, you can configure the following settings:

Hide Progress Page

Toggle the button to enable or disable the instances warming up progress status. If you turn this ON, the progress status will not be displayed.

Add Dependency

Set dependencies between two or more AutoStopping Rules when you want one Rule to make one or more Rules to be active based on the traffic that it receives. For example for an application server dependant on a database server, create two AutoStopping Rules managing both the servers. Add a dependency on the Rule managing the application server to be dependant on the Rule managing the database server.

  1. Click add dependency to add a dependency on any existing rule.
  2. Select the rule from the RULES drop-down list.
  3. In DELAY IN SECS, enter the number of seconds that rule should wait after warming up the dependent rule. For example, you have Rule 1 dependent on Rule 2 and you have set 5 seconds delay. In that case, when the request is received to warm up Rule 1, then first Rule 2 (dependent rule) is warmed up, and then there will be a delay of 5 seconds before warming up Rule 1.
  4. Once you're done with all the configurations, click Next.

    Now that you have the AutoStopping Rule configured, define how to access the instances.

A DNS link allows you to access the resources managed by the AutoStopping rule using an URL.

  1. In Setup Access, select DNS Link.
  2. Select a Load Balancer from the drop-down list. If your Load Balancer is not added, click New Application Gateway. For detailed steps, see Create an Application Gateway for Azure.
  3. Verify listeners information under the Routing tab. If the security groups are configured for the selected instances, then the routing information is auto-populated for those instances.

    You can edit or delete the routing information. However, it is mandatory to have at least one port listed. For more information, see Listeners.
    1. Click add port if you wish to add more ports.
  4. Toggle the Health check button to configure the health check. Health check makes sure that the specified parameters are met before stopping the instances. Health check status should be successful for the AutoStopping rules to come into effect.
    1. In PROTOCOL, select http or https.
    2. Enter Path, port, and timeout details. For example, you have configured port 80 and the timeout as 30 seconds for your instance, then the AutoStopping rule will check these specified parameters before stopping the instance.
  5. (Optional) Specify the URL used to access the resources. You can select either of the following options:
    1. Select the auto-generated URL to access the resources managed by this AutoStopping Rule.
    2. Enter the URL currently used to access the instances
      The domain name should be entered without prefixing the scheme. A rule can have multiple URLs. You can enter comma-separated values into the Custom URL to support multiple URLs.
    3. Select the checkbox This url is publicly accessible, if the URL is publicly accessible.
  6. Once you're done, click Next.

    Setup Access Using SSH/RDP

    SSH and RDP allow you to access the resources managed by the AutoStopping rule via SSH or RDP HTTPS URL. Select this option if the underlying applications running on the resources managed by AutoStopping Rule are accessed via SSH or RDP.
    1. In Setup Access, select SSH/RDP.
    2. Select your operating system to download the Harness CLI for your system.
    3. Click Download CLI.
    4. You can connect using SSH or RDP.
    SSH Commands
    Run the following commands for SSH:

    harness ssh --host default-test-ssh-1.abc1000test.lightwingtest.com --user ubuntu --config lwc.toml -- -i ~/.ssh/ry-jupyter.pem

    Run the connect command to open a proxy connection in your machine which can be used from other applications.
    harness connect --host default-test-ssh-1.abc1000test.lightwingtest.com --port 22 -- -i ~/.ssh/ry-jupyter.pem

    Here is the output:
    Proxy listening details:
    Rule name: Test SSH 1
    Listen address: 127.0.0.1
    Port forwarding: 14527 => 22
    Protocol: tcp
    Started at: 2021-05-19 21:53:38.320943 +0530 IST m=+48.950643931
    RDP Commands

    For RDP run the following command:
    harness rdp --host default-test-rdp-1.abc1000test.lightwingtest.com

    Run the following command to connect via private IP:
    harness rdp --host default-test-rdp-1.abc1000test.lightwingtest.com --internal-ip
    1. Click Next.

    Review

    1. In Review, verify all the configuration details and click Save Rule. To edit any of the configuration settings, click EDIT and modify the settings.

      Your AutoStopping rule is listed under the AutoStopping Rules dashboard.

Next Step


Please Provide Feedback