Azure / azure-dev

A developer CLI that reduces the time it takes for you to get started on Azure. The Azure Developer CLI (azd) provides a set of developer-friendly commands that map to key stages in your workflow - code, build, deploy, monitor, repeat.
https://aka.ms/azd
MIT License
396 stars 190 forks source link

KEDA scale rules reset after `azd deploy` #4264

Closed wbreza closed 1 week ago

wbreza commented 2 weeks ago

When using API version 2024-02-02-preview for Azure container apps and configuring KEDA scale rules

Example:

"rules": [
          {
            "name": "service-bus-queue-length-rule",
            "custom": {
              "type": "azure-servicebus",
              "metadata": {
                "messageCount": "10",
                "namespace": "sb-tl47kxvg5xjgo",
                "queueName": "ticket-render-requests"
              },
              "identity": "/subscriptions/{subscription}/resourceGroups/{resourceGroup}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/id-app-xxxxxxx"
            }
          }
        ]

Steps to reproduce

  1. Run azd provision Scale rules created successfully
  2. Run azd deploy Scale rules identity configuration reset

Actual behavior

KEDA scale rules identity are reset after running azd deploy

Expected behavior

KEDA scale rules remain intact and work correctly.

wbreza commented 2 weeks ago

After initial investigation the following is happening.

azd is using Azure SDK for go that is generated from API version 2023-11-02-preview

During azd deploy the container app metadata is retrieved, a few modifications are made to the metadata to support updating the revisions and referenced container image and the updated metadata is PUT back to the ARM control plan.

Since the new scale rules identity property is from a newer API version it is not unmarshalled into the existing SDK struct and when serialized back during the PUT operation the scale rules are essentially reset causing the current behavior.

azd should respect the API version of the configured container app without unintentionally truncating the configuration.