Skip to content

Init-DataFactory.ps1 fails when Event Grid subscription is already provisioning #1996

Description

@slapointe

🐛 Problem

When deploying a FinOps hub via Deploy-FinOpsHub, the deployment script Init-DataFactory.ps1 fails if the Event Grid subscription is already being provisioned (e.g., from a previous deployment attempt or a redeployment).

In Set-BlobTriggerSubscription, the Add-AzDataFactoryV2TriggerSubscription call and the Get-AzDataFactoryV2TriggerSubscriptionStatus check are inside the same Invoke-WithRetry block. This causes two problems:

  1. The status is checked immediately after subscribing, so it always finds Provisioning and throws.
  2. On retry, Add-AzDataFactoryV2TriggerSubscription is called again while already provisioning, which fails with Resource cannot be updated during provisioning (BadRequest).

All 20 retries are exhausted and the deployment fails.

👣 Repro steps

  1. Run Deploy-FinOpsHub -Name MyFinOpsHub -ResourceGroupName my-resource-group -Location eastus
  2. The deployment script calls Init-DataFactory.ps1 -StartTriggers
  3. Set-BlobTriggerSubscription calls Add-AzDataFactoryV2TriggerSubscription, then immediately checks status
  4. Status is Provisioning, retry re-calls Add which gets Resource cannot be updated during provisioning
  5. Deployment fails after exhausting all retries

🤔 Expected

The subscription operation and the status polling should be separate steps so the script waits for provisioning to complete instead of re-calling the subscribe operation.

ℹ️ Additional context

Error trace from the deployment failure:

System.Management.Automation.RuntimeException: Subscription status is Provisioning, expected Enabled
...
Microsoft.Rest.Azure.CloudException: HTTP Status Code: BadRequest Error Code: BadRequest Error Message: Resource cannot be updated during provisioning

File: src/templates/finops-hub/modules/fx/scripts/Init-DataFactory.ps1, function Set-BlobTriggerSubscription.

🙋‍♀️ Ask for the community

We could use your help:

  1. Please vote this issue up (👍) to prioritize it.
  2. Leave comments to help us solidify the vision.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Needs: Triage 🔍Untriaged issue needs to be reviewed

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions