azure.azcollection.azure_rm_webapp (2.3.0) — module

Manage Web App instances

| "added in version" 0.1.2 of azure.azcollection"

Authors: Yunge Zhu (@yungezz)

Install collection

Install with ansible-galaxy collection install azure.azcollection:==2.3.0


Add to requirements.yml

  collections:
    - name: azure.azcollection
      version: 2.3.0

Description

Create, update and delete instance of Web App.


Requirements

Usage examples

  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Create a windows web app with non-exist app service plan
  azure_rm_webapp:
    resource_group: myResourceGroup
    name: myWinWebapp
    plan:
      resource_group: myAppServicePlan_rg
      name: myAppServicePlan
      is_linux: false
      sku: S1
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Create a docker web app with some app settings, with docker image
  azure_rm_webapp:
    resource_group: myResourceGroup
    name: myDockerWebapp
    plan:
      resource_group: myAppServicePlan_rg
      name: myAppServicePlan
      is_linux: true
      sku: S1
      number_of_workers: 2
    app_settings:
      testkey: testvalue
      testkey2: testvalue2
    container_settings:
      name: ansible/ansible:ubuntu1404
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Create a docker web app with private acr registry
  azure_rm_webapp:
    resource_group: myResourceGroup
    name: myDockerWebapp
    plan: myAppServicePlan
    app_settings:
      testkey: testvalue
    container_settings:
      name: ansible/ubuntu1404
      registry_server_url: myregistry.io
      registry_server_user: user
      registry_server_password: pass
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Create a multi-container web app
  azure_rm_webapp:
    resource_group: myResourceGroup
    name: myMultiContainerWebapp
    plan: myAppServicePlan
    app_settings:
      testkey: testvalue
    container_settings:
      name: "COMPOSE|{{ lookup('file', 'docker-compose.yml') | b64encode }}"
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Create a linux web app with Node 6.6 framework
  azure_rm_webapp:
    resource_group: myResourceGroup
    name: myLinuxWebapp
    plan:
      resource_group: myAppServicePlan_rg
      name: myAppServicePlan
    app_settings:
      testkey: testvalue
    frameworks:
      - name: "node"
        version: "18"
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Create a windows web app with node, php
  azure_rm_webapp:
    resource_group: myResourceGroup
    name: myWinWebapp
    plan:
      resource_group: myAppServicePlan_rg
      name: myAppServicePlan
    app_settings:
      testkey: testvalue
    frameworks:
      - name: "node"
        version: 18
      - name: "php"
        version: 8.2
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Create a stage deployment slot for an existing web app
  azure_rm_webapp:
    resource_group: myResourceGroup
    name: myWebapp/slots/stage
    plan:
      resource_group: myAppServicePlan_rg
      name: myAppServicePlan
    app_settings:
      testkey:testvalue
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Create a linux web app with java framework
  azure_rm_webapp:
    resource_group: myResourceGroup
    name: myLinuxWebapp
    plan:
      resource_group: myAppServicePlan_rg
      name: myAppServicePlan
    app_settings:
      testkey: testvalue
    frameworks:
      - name: "java"
        version: "8"
        settings:
          java_container: "Tomcat"
          java_container_version: "8.5"
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Create a linux web app with python framework
  azure_rm_webapp:
    resource_group: myResourceGroup
    name: myLinuxWebapp
    plan:
      resource_group: myAppServicePlan_rg
      name: myAppServicePlan
    app_settings:
      testkey: testvalue
    frameworks:
      - name: "python"
        version: "3.10"

Inputs

    
name:
    description:
    - Unique name of the app to create or update. To create or update a deployment slot,
      use the {slot} parameter.
    required: true
    type: str

plan:
    description:
    - App service plan. Required for creation.
    - Can be name of existing app service plan in same resource group as web app.
    - Can be the resource ID of an existing app service plan. For example /subscriptions/<subs_id>/resourceGroups/<resource_group>/providers/Microsoft.Web/serverFarms/<plan_name>.
    - Can be a dict containing five parameters, defined below.
    - C(name), name of app service plan.
    - C(resource_group), resource group of the app service plan.
    - C(sku), SKU of app service plan, allowed values listed on U(https://azure.microsoft.com/en-us/pricing/details/app-service/linux/).
    - C(is_linux), whether or not the app service plan is Linux. defaults to C(False).
    - C(number_of_workers), number of workers for app service plan.
    type: raw

tags:
    description:
    - Dictionary of string:string pairs to assign as metadata to the object.
    - Metadata tags on the object will be updated with any provided values.
    - To remove tags set append_tags option to false.
    - Currently, Azure DNS zones and Traffic Manager services also don't allow the use
      of spaces in the tag.
    - Azure Front Door doesn't support the use of
    - Azure Automation and Azure CDN only support 15 tags on resources.
    type: dict

state:
    choices:
    - absent
    - present
    default: present
    description:
    - State of the Web App.
    - Use C(present) to create or update a Web App and C(absent) to delete it.
    type: str

secret:
    description:
    - Azure client secret. Use when authenticating with a Service Principal.
    type: str

tenant:
    description:
    - Azure tenant ID. Use when authenticating with a Service Principal.
    type: str

ad_user:
    description:
    - Active Directory username. Use when authenticating with an Active Directory user
      rather than service principal.
    type: str

profile:
    description:
    - Security profile found in ~/.azure/credentials file.
    type: str

location:
    description:
    - Resource location. If not set, location from the resource group will be used as
      default.
    type: str

log_mode:
    description:
    - Parent argument.
    type: str

log_path:
    description:
    - Parent argument.
    type: str

password:
    description:
    - Active Directory user password. Use when authenticating with an Active Directory
      user rather than service principal.
    type: str

scm_type:
    description:
    - Repository type of deployment source, for example C(LocalGit), C(GitHub).
    - List of supported values maintained at U(https://docs.microsoft.com/en-us/rest/api/appservice/webapps/createorupdate#scmtype).
    type: str

always_on:
    description:
    - Keeps the app loaded even when there's no traffic.
    type: bool

app_state:
    choices:
    - started
    - stopped
    - restarted
    default: started
    description:
    - Start/Stop/Restart the web app.
    type: str

client_id:
    description:
    - Azure client ID. Use when authenticating with a Service Principal or Managed Identity
      (msi).
    - Can also be set via the C(AZURE_CLIENT_ID) environment variable.
    type: str

frameworks:
    description:
    - Set of run time framework settings. Each setting is a dictionary.
    - See U(https://docs.microsoft.com/en-us/azure/app-service/app-service-web-overview)
      for more info.
    elements: dict
    suboptions:
      name:
        choices:
        - java
        - net_framework
        - php
        - python
        - ruby
        - dotnetcore
        - node
        description:
        - Name of the framework.
        - Supported framework list for Windows web app and Linux web app is different.
        - Windows web apps support C(java), C(net_framework), C(php), C(python), and C(node)
          from June 2018.
        - Windows web apps support multiple framework at the same time.
        - Linux web apps support C(java), C(ruby), C(php), C(python), C(dotnetcore), and
          C(node) from June 2018.
        - Linux web apps support only one framework.
        - Java framework is mutually exclusive with others.
        required: true
        type: str
      settings:
        description:
        - List of settings of the framework.
        suboptions:
          java_container:
            description:
            - Name of Java container.
            - Supported only when I(frameworks=java). Sample values C(Tomcat), C(JavaSE),
              C(RedHat).
            required: true
            type: str
          java_container_version:
            description:
            - Version of Java container.
            - Supported only when I(frameworks=java).
            - Sample values for C(Tomcat), C(8.5), C(9.0), C(10.0), C(10.1).
            required: true
            type: str
        type: dict
      version:
        description:
        - Version of the framework. For Linux web app supported value, see U(https://aka.ms/linux-stacks)
          for more info.
        - C(net_framework) supported value sample, C(v4.8) for .NET 4.8 and C(v3.5) for
          .NET 3.5.
        - C(php) supported value sample, C(8.1), C(8.2).
        - C(python) supported value sample, C(3.8), C(3.9), C(3.10), C(3.11), C(3.12).
        - C(node) supported value sample, C(18), C(20).
        - C(dotnetcore) supported value sample, C(8), C(7), C(6).
        - C(ruby) supported value sample, C(2.3).
        - C(java) supported value sample, C(21), C(17), C(11) and C(8).
        required: true
        type: str
    type: list

ftps_state:
    choices:
    - AllAllowed
    - FtpsOnly
    - Disabled
    description:
    - The state of the FTP/FTPS service.
    type: str

https_only:
    description:
    - Configures web site to accept only https requests.
    type: bool

thumbprint:
    description:
    - The thumbprint of the private key specified in I(x509_certificate_path).
    - Use when authenticating with a Service Principal.
    - Required if I(x509_certificate_path) is defined.
    type: str
    version_added: 1.14.0
    version_added_collection: azure.azcollection

api_profile:
    default: latest
    description:
    - Selects an API profile to use when communicating with Azure services. Default value
      of C(latest) is appropriate for public clouds; future values will allow use with
      Azure Stack.
    type: str
    version_added: 0.0.1
    version_added_collection: azure.azcollection

append_tags:
    default: true
    description:
    - Use to control if tags field is canonical or just appends to existing tags.
    - When canonical, any tags not found in the tags parameter will be removed from the
      object's metadata.
    type: bool

auth_source:
    choices:
    - auto
    - cli
    - credential_file
    - env
    - msi
    default: auto
    description:
    - Controls the source of the credentials to use for authentication.
    - Can also be set via the C(ANSIBLE_AZURE_AUTH_SOURCE) environment variable.
    - When set to C(auto) (the default) the precedence is module parameters -> C(env)
      -> C(credential_file) -> C(cli).
    - When set to C(env), the credentials will be read from the environment variables
    - When set to C(credential_file), it will read the profile from C(~/.azure/credentials).
    - When set to C(cli), the credentials will be sources from the Azure CLI profile.
      C(subscription_id) or the environment variable C(AZURE_SUBSCRIPTION_ID) can be used
      to identify the subscription ID if more than one is present otherwise the default
      az cli subscription is used.
    - When set to C(msi), the host machine must be an azure resource with an enabled MSI
      extension. C(subscription_id) or the environment variable C(AZURE_SUBSCRIPTION_ID)
      can be used to identify the subscription ID if the resource is granted access to
      more than one subscription, otherwise the first subscription is chosen.
    - The C(msi) was added in Ansible 2.6.
    type: str
    version_added: 0.0.1
    version_added_collection: azure.azcollection

app_settings:
    description:
    - Configure web app application settings. Suboptions are in key value pair format.
    type: dict

startup_file:
    description:
    - The web's startup file.
    - Used only for Linux web apps.
    type: str

http20_enabled:
    description:
    - Configures a web site to allow clients to connect over HTTP 2.0.
    type: bool

resource_group:
    description:
    - Name of the resource group to which the resource belongs.
    required: true
    type: str

min_tls_version:
    choices:
    - '1.0'
    - '1.1'
    - '1.2'
    description:
    - The minimum TLS encryption version required for the app.
    type: str

subscription_id:
    description:
    - Your Azure subscription Id.
    type: str

cloud_environment:
    default: AzureCloud
    description:
    - For cloud environments other than the US public cloud, the environment name (as
      defined by Azure Python SDK, eg, C(AzureChinaCloud), C(AzureUSGovernment)), or a
      metadata discovery endpoint URL (required for Azure Stack). Can also be set via
      credential file profile or the C(AZURE_CLOUD_ENVIRONMENT) environment variable.
    type: str
    version_added: 0.0.1
    version_added_collection: azure.azcollection

deployment_source:
    description:
    - Deployment source for git.
    suboptions:
      branch:
        description:
        - The branch name of the repository.
        type: str
      url:
        description:
        - Repository url of deployment source.
        type: str
    type: dict

adfs_authority_url:
    description:
    - Azure AD authority url. Use when authenticating with Username/password, and has
      your own ADFS authority.
    type: str
    version_added: 0.0.1
    version_added_collection: azure.azcollection

container_settings:
    description:
    - Web app container settings.
    suboptions:
      name:
        description:
        - Name of the container, for example C(imagename:tag).
        - To create a multi-container app, the name should be 'COMPOSE|' or 'KUBE|' followed
          by base64 encoded configuration.
        required: true
        type: str
      registry_server_password:
        description:
        - The container registry server password.
        type: str
      registry_server_url:
        description:
        - Container registry server URL, for example C(mydockerregistry.io).
        type: str
      registry_server_user:
        description:
        - The container registry server user name.
        type: str
    type: dict

purge_app_settings:
    default: false
    description:
    - Purge any existing application settings. Replace web app application settings with
      app_settings.
    type: bool

cert_validation_mode:
    choices:
    - ignore
    - validate
    description:
    - Controls the certificate validation behavior for Azure endpoints. By default, all
      modules will validate the server certificate, but when an HTTPS proxy is in use,
      or against Azure Stack, it may be necessary to disable this behavior by passing
      C(ignore). Can also be set via credential file profile or the C(AZURE_CERT_VALIDATION)
      environment variable.
    type: str
    version_added: 0.0.1
    version_added_collection: azure.azcollection

x509_certificate_path:
    description:
    - Path to the X509 certificate used to create the service principal in PEM format.
    - The certificate must be appended to the private key.
    - Use when authenticating with a Service Principal.
    type: path
    version_added: 1.14.0
    version_added_collection: azure.azcollection

client_affinity_enabled:
    default: true
    description:
    - Whether or not to send session affinity cookies, which route client requests in
      the same session to the same instance.
    type: bool

disable_instance_discovery:
    default: false
    description:
    - Determines whether or not instance discovery is performed when attempting to authenticate.
      Setting this to true will completely disable both instance discovery and authority
      validation. This functionality is intended for use in scenarios where the metadata
      endpoint cannot be reached such as in private clouds or Azure Stack. The process
      of instance discovery entails retrieving authority metadata from https://login.microsoft.com/
      to validate the authority. By setting this to **True**, the validation of the authority
      is disabled. As a result, it is crucial to ensure that the configured authority
      host is valid and trustworthy.
    - Set via credential file profile or the C(AZURE_DISABLE_INSTANCE_DISCOVERY) environment
      variable.
    type: bool
    version_added: 2.3.0
    version_added_collection: azure.azcollection

Outputs

id:
  description:
  - ID of current web app.
  returned: always
  sample: /subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/resourceGroups/myResourceGroup/providers/Microsoft.Web/sites/myWebApp
  type: str

See also