How to update properties (rewriteRuleSets) via bicep for existing resource (app gateway)

Diem Nguyen 0 Reputation points
2024-08-02T10:04:44.4+00:00

I want to update rewriteRuleSets for existing app gate way. How to update an existing resource via bicep

I'm a beginer in this field so If possible, please give me an example

resource appGateWay 'Microsoft.Network/applicationGateways@2024-01-01' existing = {
  name: 'existing-agw'
  scope: resourceGroup('preac_RG')
}

resource updatedAppGateWay 'Microsoft.Network/applicationGateways@2024-01-01' = {
  name: 'existing-agw'
  location: 'West Europe'
  properties: {
    rewriteRuleSets: [
      {
        // id: ''
        name: 'cors-test'
        properties: {
          rewriteRules: [
            {
              actionSet: {
                requestHeaderConfigurations: [
                  {
                    headerName: 'Access-Control-Request-Headers'
                    headerValue: '*'
                  }
                ]
                responseHeaderConfigurations: [
                  {
                    headerName: 'Access-Control-Allow-Origin'
                    headerValue: '*'
                  }
                ]
              }
              conditions: [{

              }]
              name: 'test'
              ruleSequence: 5
            }            
          ]
        }
      }
    ]   
  }

}
Azure Application Gateway
Azure Application Gateway
An Azure service that provides a platform-managed, scalable, and highly available application delivery controller as a service.
1,076 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Iheanacho Chukwu 1,020 Reputation points
    2024-08-08T20:16:47.4433333+00:00

    Please do not forget to "Accept the answer" if the information provided helps you to help others in the community.

    Hello @Diem Nguyen

    To update the rewriteRuleSets for an existing Application Gateway using Bicep, you dont need to declare an existing resource block for the resource, since there is no child resource or module available for managing Application Gateway rewriteRules.

    You must declare the entire resource block to include the updated rules directly within the Application Gateway resource bicep template.

    Refer to the documentation on:

    1 person found this answer helpful.
    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.