microsoft / azure-pipelines-tasks

Tasks for Azure Pipelines
https://aka.ms/tfbuild
MIT License
3.5k stars 2.61k forks source link

[enhancement]: Support Different Resource Groups for Container App and Environment in AzureContainerApps@1 #20594

Open jsinghcode opened 3 weeks ago

jsinghcode commented 3 weeks ago

Task name

AzureContainerApps@1

Describe your feature request here

Description

When deploying Container Apps in Azure, it is common for the Container Apps Environment and the Container App itself to reside in separate resource groups (e.g., the environment Dev-Environment in Resource Group A and the app MyContainerApp in Resource Group B). However, when using the AzureContainerApps@1 task in an Azure DevOps pipeline, specifying different resource groups for the environment and the app leads to an error, as the task expects both resources to be in the same group.

Steps to Reproduce

  1. Configure a pipeline with the AzureContainerApps@1 task:
    - stage: Deploy  
     jobs:
     - job:
       steps:
       - task: AzureContainerApps@1
         inputs:
           azureSubscription: 'MyAzureSubscription'
           acrName: 'myContainerRegistry'
           imageToDeploy: 'myContainerRegistry.azurecr.io/MyContainerApp:$(Build.BuildNumber)'
           containerAppName: 'MyContainerApp'
           resourceGroup: 'Resource Group B'
           containerAppEnvironment: 'Dev-Environment'
  2. Run the deployment.

Current Behavior The deployment fails with the following error:

(ResourceNotFound) The Resource 'Microsoft.App/managedEnvironments/Dev-Environment' under resource group 'Resource Group B' was not found.

Expected Behavior It should be possible to specify a different resource group for the Container Apps Environment using a full resource ID path, allowing for more flexible resource configurations.

Proposed Solution Enable support for specifying a full resource ID for the containerAppEnvironment input in the AzureContainerApps@1 task, like:

containerAppEnvironment: '/subscriptions/12345678-1234-1234-1234-123456789012/resourceGroups/Resource Group A/providers/Microsoft.App/managedEnvironments/Dev-Environment'

Full Example Task Here is an example of the full task configuration with the proposed solution:

- stage: Deploy  
  jobs:
  - job:
    steps:
    - task: AzureContainerApps@1
      inputs:
        azureSubscription: 'MyAzureSubscription'
        acrName: 'myContainerRegistry'
        imageToDeploy: 'myContainerRegistry.azurecr.io/MyContainerApp:$(Build.BuildNumber)'
        containerAppName: 'MyContainerApp'
        resourceGroup: 'Resource Group B'
        containerAppEnvironment: '/subscriptions/12345678-1234-1234-1234-123456789012/resourceGroups/Resource Group A/providers/Microsoft.App/managedEnvironments/Dev-Environment'