Azure / container-apps-deploy-action

GitHub Action for building and deploying Azure Container Apps
MIT License
50 stars 30 forks source link

ERROR: (ManagedEnvironmentNotFound) For valid environment #84

Closed danielPerez97 closed 8 months ago

danielPerez97 commented 8 months ago

We are trying to run a Github Action that deploys a Container App. The steps are as follows:

      - name: Login to Azure
        uses: azure/login@v1
        with:
          creds: ${{ secrets.AZURE_SERVICE_ACCOUNT_CREDENTIALS }}

      - name: Add containerapp extension
        run: az extension add -n containerapp

      - name: Ensure ACR Exists
        run: |
          az acr show --name ${{ env.SERVICE }} --resource-group ${{ secrets.RESOURCE_GROUP }} ||
          az acr create --name ${{ env.SERVICE }} --resource-group ${{ secrets.RESOURCE_GROUP }} --sku Basic

      - name: Login to ACR
        run: az acr login --name ${{ env.SERVICE }}

      - name: Build and push Docker image
        run: |
          docker build -t ${{ env.SERVICE }}.azurecr.io/our-container:${{ github.sha }} --target base .
          docker push ${{ env.SERVICE }}.azurecr.io/our-container:${{ github.sha }}

      - name: Deploy Azure Container App
        uses: azure/container-apps-deploy-action@v1
        with:
          acrName: ouracrname
          yamlConfigPath: gh-azure-config.yaml
          resourceGroup: MY_RESOURCE_GROUP
          containerAppEnvironment: MY_ENVIRONMENT_NAME
          containerAppName: ${{ env.SERVICE }} 

Which, on the "Deploy Azure Container App" step, yields the following error with exit code 1:

ERROR: (ManagedEnvironmentNotFound) Environment /subscriptions/MY_SUBSCRIPTION_ID/resourceGroups/MY_RESOURCE_GROUP/providers/Microsoft.App/managedEnvironments/MY_ENVIRONMENT_NAME was not found.

With the following command, we can get the managedEnvironmentId(for the gh-azure-config.yaml) from the id key:

az containerapp env show --name MY_ENVIRONMENT_NAME --resource-group MY_RESOURCE_GROUP

We plug in the id value into managedEnvironmentId in the gh-azure-config.yaml file, but we get this error. The service account we are using has contributor access to the environment and we've validated it can see the environment with this command. We're unsure how to proceed from here and are wondering if this may be a bug. Thank you

danielPerez97 commented 8 months ago

We were able to resolve this. The location in our YAML file was not set to the same location as the Container Environment. Closing.