Skip to content

Latest commit

 

History

History
133 lines (100 loc) · 3.84 KB

azure-web-apps-scale.md

File metadata and controls

133 lines (100 loc) · 3.84 KB
title description keywords ms.topic ms.date ms.custom
Tutorial - Scale apps in Azure App Service using Ansible
Learn how to scale up an app in Azure App Service
ansible, azure, devops, bash, playbook, Azure App Service, Web App, scale, Java
tutorial
04/30/2019
devx-track-ansible

Tutorial: Scale apps in Azure App Service using Ansible

[!INCLUDE ansible-27-note.md]

[!INCLUDE open-source-devops-intro-app-service.md]

In this article, you learn how to:

[!div class="checklist"]

  • Get facts of an existing App Service plan
  • Scale up the App Service plan to S2 with three workers

Prerequisites

[!INCLUDE open-source-devops-prereqs-azure-subscription.md] [!INCLUDE ansible-prereqs-cloudshell-use-or-vm-creation2.md]

Scale up an app

There are two workflows for scaling: scale up and scale out.

Scale up: To scale up means to acquire more resources. These resources include CPU, memory, disk space, VMs, and more. You scale up an app by changing the pricing tier of the App Service plan to which the app belongs. Scale out: To scale out means to increase the number of VM instances that run your app. Depending on your App Service plan pricing tier, you can scale out to as many as 20 instances. Autoscaling allows you to scale instance count automatically based on predefined rules and schedules.

The playbook code in this section defines following operation:

  • Get facts of an existing App Service plan
  • Update the App service plan to S2 with three workers

Save the following playbook as webapp_scaleup.yml:

- hosts: localhost
  connection: local
  vars:
    resource_group: myResourceGroup
    plan_name: myAppServicePlan
    location: eastus

  tasks:
  - name: Get facts of existing App service plan
    azure_rm_appserviceplan_facts:
      resource_group: "{{ resource_group }}"
      name: "{{ plan_name }}"
    register: facts

  - debug: 
      var: facts.appserviceplans[0].sku

  - name: Scale up the App service plan
    azure_rm_appserviceplan:
      resource_group: "{{ resource_group }}"
      name: "{{ plan_name }}"
      is_linux: true
      sku: S2
      number_of_workers: 3
      
  - name: Get facts
    azure_rm_appserviceplan_facts:
      resource_group: "{{ resource_group }}"
      name: "{{ plan_name }}"
    register: facts

  - debug: 
      var: facts.appserviceplans[0].sku

Run the playbook using ansible-playbook

ansible-playbook webapp_scaleup.yml

After running the playbook, you see output similar to the following results:

PLAY [localhost] 

TASK [Gathering Facts] 
ok: [localhost]

TASK [Get facts of existing App service plan] 
 [WARNING]: Azure API profile latest does not define an entry for WebSiteManagementClient

ok: [localhost]

TASK [debug] 
ok: [localhost] => {
    "facts.appserviceplans[0].sku": {
        "capacity": 1,
        "family": "S",
        "name": "S1",
        "size": "S1",
        "tier": "Standard"
    }
}

TASK [Scale up the App service plan] 
changed: [localhost]

TASK [Get facts] 
ok: [localhost]

TASK [debug] 
ok: [localhost] => {
    "facts.appserviceplans[0].sku": {
        "capacity": 3,
        "family": "S",
        "name": "S2",
        "size": "S2",
        "tier": "Standard"
    }
}

PLAY RECAP 
localhost                  : ok=6    changed=1    unreachable=0    failed=0 

Next steps

[!div class="nextstepaction"] Ansible on Azure