자습서: Ansible을 사용하여 Azure App Service에서 앱 크기 조정

중요합니다

이 문서의 샘플 플레이북을 실행하려면 Ansible 2.7 이상이 필요합니다.

Azure App Service 를 사용하면 코드를 빌드하고 호스트할 수 있습니다. 이 코드는 웹앱, 모바일 백 엔드 및 RESTful API 형식일 수 있습니다. App Service를 사용하면 인프라를 관리하지 않고 선택한 프로그래밍 언어를 사용하여 코드를 개발할 수 있습니다. App Service는 Windows와 Linux를 모두 지원합니다. GitHub 및 Azure DevOps를 포함하여 모든 Git 리포지토리의 자동화된 배포가 지원됩니다.

이 문서에서는 다음 방법을 알아봅니다.

  • 기존 App Service 계획의 팩트 가져오기
  • 작업자 3명을 사용하여 App Service 계획을 S2로 확장

필수 조건

  • Azure 구독: Azure 구독이 아직 없는 경우 시작하기 전에 체험 계정을 만듭니다.

앱 강화

크기 조정을 위한 워크플로에는 스케일 업 및 스케일 아웃이라는 두 가지 워크플로 가 있습니다.

강화: 강화한다는 것은 더 많은 리소스를 획득하는 것을 의미합니다. 이러한 리소스에는 CPU, 메모리, 디스크 공간, VM 등이 포함됩니다. 앱이 속한 App Service 계획의 가격 책정 계층을 변경하여 앱을 확장합니다. 규모 확장: 규모 확장은 앱을 실행하는 VM 인스턴스 수를 늘리는 것을 의미합니다. App Service 계획 가격 책정 계층에 따라 최대 20개의 인스턴스로 확장할 수 있습니다. 자동 크기 조정 을 사용하면 미리 정의된 규칙 및 일정에 따라 인스턴스 수를 자동으로 조정할 수 있습니다.

이 섹션의 플레이북 코드는 다음 작업을 정의합니다.

  • 기존 App Service 계획의 팩트 가져오기
  • 세 명의 작업자를 사용하여 App Service 계획을 S2로 업데이트

다음 플레이북을 다음과 같이 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

ansible-playbook을 사용하여 플레이북 실행

ansible-playbook webapp_scaleup.yml

플레이북을 실행한 후 다음 결과와 유사한 출력이 표시됩니다.

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 

다음 단계