Azure / bicep-types-az

Bicep type definitions for ARM resources
MIT License
86 stars 27 forks source link

Microsoft.Cdn/profiles/endpoint: Failed to update existing hostName #1920

Open bennoschoonraad opened 1 year ago

bennoschoonraad commented 1 year ago

Bicep version Using AzureCLI@2 and the command: az deployment

Describe the bug When updating an existing Microsoft.Cdn profile with a .bicep file, there seems to be an issue replacing the existing hostName with the new hostName.

The originHostHeader gets updated as expected, however, it seems that the hostName failed to update, and remained as the previously configured hostName

To Reproduce Steps to reproduce the behavior:

Additional context

param location string = resourceGroup().location

resource profile 'Microsoft.Cdn/profiles@2023-05-01' = {
  name: 'xxxxx-cdnprofile'
  location: location
  properties: {}
  sku: {
    name: 'Standard_Microsoft'
  }
}

resource endpoint 'Microsoft.Cdn/profiles/endpoints@2023-05-01' = {
  parent: profile
  location: location
  name: 'xxxxx-cdnendpoint'
  properties: {
    originHostHeader: 'newhostname'
    isHttpAllowed: false
    isHttpsAllowed: true
    queryStringCachingBehavior: 'UseQueryString'
    contentTypesToCompress: [
      'text/plain'
      'text/html'
      'text/css'
      'text/javascript'
      'application/x-javascript'
      'application/javascript'
      'application/json'
    ]
    isCompressionEnabled: true
    origins: [
      {
        name: 'azurestorageaccount'
        properties: {
          hostName: 'newhostname'
          originHostHeader: 'newhostname'
        }
      }
    ]
    deliveryPolicy: {
      rules: [
        {
          name: 'redirectToCorporateWebsite'
          order: 1
          conditions: [
            {
              name: 'RequestUri'
              parameters: {
                typeName: 'DeliveryRuleRequestUriConditionParameters'
                operator: 'Equal'
                negateCondition: false
                matchValues: [
                  'https://xxxxx'
                  'https://xxxxx'
                ]
                transforms: []
              }
            }
          ]
          actions: [
            {
              name: 'UrlRedirect'
              parameters: {
                typeName: 'DeliveryRuleUrlRedirectActionParameters'
                redirectType: 'Found'
                destinationProtocol: 'Https'
                customPath: '/'
                customHostname: 'xxxxx'
              }
            }
          ]
        }
      ]
    }
  }
}
alex-frankel commented 1 year ago

Most likely not a bicep issue. Are you able to open a support case for this and have it routed to the CDN team?

blakedh commented 9 months ago

I also encountered this issue. I needed to update the hostname on my origin. In my Bicep I also explicitly set the hostname and originHostHeader properties to the same value.

When I looked at the endpoint in the Azure Portal, only the origin host header value had changed. The hostname was still set to the old value. I ended up deleting the resource manually and deploying again, which created it just fine.

microsoft-github-policy-service[bot] commented 9 months ago

Thanks for the feedback! We are routing this to the appropriate team for follow-up. cc @t-bzhan, @gxue. Please see https://aka.ms/biceptypesinfo for troubleshooting help.

samfromlv commented 6 months ago

We have faced the same issue.

To have properly working bicep template for cdn endpoint, that works correctly for endpoint creation and update you need to have 3 resources:

1) cdn profile 2) cdn endpoint 3) cdn endpoint origin - without this update of the host name will not work.

Here is sample of working template:

@description('Location for all resources.')
param location string = 'global'

resource profile 'Microsoft.Cdn/profiles@2024-02-01' = {
  name: 'xxxxx-cdnprofile'
  location: location
  properties: {}
  sku: {
    name: 'Standard_Microsoft'
  }
}

resource endpoint 'Microsoft.Cdn/profiles/endpoints@2024-02-01' = {
  parent: profile
  location: location
  name: 'xxxxx-cdnendpoint'
  properties: {
    originHostHeader: 'newhostname'
    isHttpAllowed: false
    isHttpsAllowed: true
    queryStringCachingBehavior: 'UseQueryString'
    contentTypesToCompress: [
      'text/plain'
      'text/html'
      'text/css'
      'text/javascript'
      'application/x-javascript'
      'application/javascript'
      'application/json'
    ]
    isCompressionEnabled: true
    origins: [
      {
        name: 'origin1'
        properties: {
          hostName: 'newhostname'
          originHostHeader: 'newhostname'
        }
      }
    ]
    deliveryPolicy: null
  }
}

resource origin 'Microsoft.Cdn/profiles/endpoints/origins@2024-02-01' = {
  name: 'origin1'
  parent: endpoint
  properties: {
    hostName: 'newhostname' 
  }
}