> ## Documentation Index
> Fetch the complete documentation index at: https://cloudanix.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Azure audit appservice http 2 disabled remediation

### Triage and Remediation

<Tabs>
  <Tab title="Remediation">
    ### Remediation

    <AccordionGroup>
      <Accordion title="Using Console" defaultOpen="true">
        To remediate the HTTP 2.0 disabled misconfiguration in Azure using the Azure console, you can follow these steps:

        1. Log in to the Azure portal and navigate to the App Service that needs to be configured.

        2. Under the Settings section, select Configuration.

        3. Scroll down to the General settings section, and locate the HTTP version configuration.

        4. Change the HTTP version configuration to "2.0" to enable HTTP 2.0.

        5. Click Save to apply the changes.

        6. Restart the App Service to ensure that the changes are applied.

        7. Once the App Service is restarted, verify that HTTP 2.0 is enabled by accessing the application through a web browser and checking the network tab of the developer tools.

        By following these steps, you can remediate the HTTP 2.0 disabled misconfiguration in Azure using the Azure console.

        #
      </Accordion>

      <Accordion title="Using CLI">
        To remediate HTTP 2.0 disabled misconfiguration in Azure using Azure CLI, you can follow the below steps:

        Step 1: Open Azure CLI and login to your Azure account.

        ```
        az login
        ```

        Step 2: Check the current status of HTTP 2.0 on the web app.

        ```
        az webapp show --resource-group <resource-group-name> --name <web-app-name> --query http20Enabled
        ```

        Step 3: If the output of the above command is false, then HTTP 2.0 is disabled for the web app. To enable it, run the below command:

        ```
        az webapp update --resource-group <resource-group-name> --name <web-app-name> --http20-enabled true
        ```

        Step 4: Verify that HTTP 2.0 is enabled by running the below command:

        ```
        az webapp show --resource-group <resource-group-name> --name <web-app-name> --query http20Enabled
        ```

        Step 5: Once verified, you have successfully remediated the HTTP 2.0 disabled misconfiguration for your Azure web app.

        Note: Replace `<resource-group-name>` and `<web-app-name>` with your actual resource group and web app name respectively.
      </Accordion>

      <Accordion title="Using Python">
        To remediate the HTTP 2.0 Disabled misconfiguration in Azure using Python, you can use the Azure SDK for Python. Here are the step-by-step instructions:

        1. Install the Azure SDK for Python by running the following command in your terminal:

           ```
           pip install azure
           ```

        2. Import the necessary modules:

           ```
           from azure.mgmt.web import WebSiteManagementClient
           from azure.common.credentials import ServicePrincipalCredentials
           ```

        3. Authenticate with Azure using a service principal:

           ```
           credentials = ServicePrincipalCredentials(
               client_id='<your_client_id>',
               secret='<your_client_secret>',
               tenant='<your_tenant_id>'
           )
           ```

        4. Create a `WebSiteManagementClient` object:

           ```
           client = WebSiteManagementClient(credentials, '<your_subscription_id>')
           ```

        5. Get the resource group and site name for the web app:

           ```
           resource_group_name = '<your_resource_group_name>'
           site_name = '<your_site_name>'
           ```

        6. Get the current site configuration:

           ```
           site_config = client.web_apps.get_configuration(resource_group_name, site_name)
           ```

        7. Check if HTTP 2.0 is already enabled:

           ```
           if site_config.http20_enabled:
               print('HTTP 2.0 is already enabled.')
           else:
               # Enable HTTP 2.0
               site_config.http20_enabled = True
               client.web_apps.update_configuration(resource_group_name, site_name, site_config)
               print('HTTP 2.0 has been enabled.')
           ```

           This code checks if HTTP 2.0 is already enabled. If it is, it prints a message saying so. If it is not, it enables HTTP 2.0 and prints a message saying it has been enabled.

        8. Run the code and verify that HTTP 2.0 has been enabled for your web app.

           ```
           python remediate_http2_disabled.py
           ```
      </Accordion>

      <Accordion title="Using Terraform">
        ```hcl theme={null}
        resource "azurerm_app_service" "APP_SERVICE_NAME" {
          name                = "APP_SERVICE_NAME"          # replace with your App Service name
          location            = azurerm_resource_group.RG_NAME.location
          resource_group_name = azurerm_resource_group.RG_NAME.name
          app_service_plan_id = azurerm_app_service_plan.PLAN_NAME.id

          site_config {
            http2_enabled = true
            # keep any other existing settings here (e.g., linux_fx_version, always_on, etc.)
          }

          # keep other existing blocks (app_settings, identity, auth_settings, etc.) as needed
        }
        ```

        This change does not force replacement of the App Service; it updates the existing site configuration in-place.

        To verify, `terraform plan` should show an in-place update on `azurerm_app_service.APP_SERVICE_NAME` with `site_config.0.http2_enabled` changing from `false` (or `null`) to `true`.
      </Accordion>
    </AccordionGroup>
  </Tab>
</Tabs>
