Azure devops pipeline error with create new revision and roll out new code

Nho Luong 65 Reputation points
2025-04-16T02:16:29.5866667+00:00

Hello All My Friends,

My project has been running for more than 1 year now and I have 3 environments dev, stg and prod and everything is normal But in the last 1 week, all 3 environments have had the same error:

tasks: AzureCLI@2 displayName: Create new modification and roll out new code

##[error]Script failed with exit code: 1

Screen Shot 2025-04-16 at 09.20.20

This is my current code here:

      - task: AzureCLI@2

        displayName: Create new revision and roll out new code

        inputs:

          azureSubscription: resourcemgrconnection

          scriptType: bash

          scriptLocation: inlineScript

          useGlobalConfig: false

          inlineScript: |

            echo "Installing Bicep manually..."

            curl -Lo bicep https://github.com/Azure/bicep/releases/latest/download/bicep-linux-x64

            chmod +x ./bicep

            sudo mv ./bicep /usr/local/bin/bicep

            echo "Bicep installed at $(which bicep)"

            bicep version

            az deployment group create --resource-group 'rg-$(applicationName)-$(region)' \

            --parameters '$(System.DefaultWorkingDirectory)/.azdo/pipelines/parameters/intoweb.$(aliasEnv).bicepparam' \

            --template-file '$(System.DefaultWorkingDirectory)/infra/abc.bicep'

        env:

          ACR_SERVER: acrdev.azurecr.io

          ${{ if eq(parameters.vargroup, 'dev') }}:

            CONTAINER_APP_NAME: '$(applicationName)$(region)'

          ${{ if eq(parameters.vargroup, 'uat') }}:

            CONTAINER_APP_NAME: '$(applicationName)uat$(region)'

          ${{ if and(ne(parameters.vargroup, 'dev'), ne(parameters.vargroup, 'uat')) }}:

            CONTAINER_APP_NAME: '$(applicationName)$(region)'

          ${{ if eq(parameters.vargroup, 'dev') }}:

            DB_HOST: mysql-$(applicationName)$(region)mysql.mysql.database.azure.com

          ${{ if eq(parameters.vargroup, 'uat') }}:

            DB_HOST: mysql-$(applicationName)$(region)mysql.mysql.database.azure.com

          ${{ if eq(parameters.vargroup, 'pro') }}:

            DB_HOST: mysql-$(applicationName)$(region)mysqlpro.mysql.database.azure.com

          ${{ if eq(parameters.vargroup, 'dev') }}:

            DB_NAME: intodb

            DB_PASSWORD: $(dbPassword)

          ${{ if eq(parameters.vargroup, 'uat') }}:

            DB_NAME: intodbuat

            DB_PASSWORD: $(dbPassword)

          ${{ if and(ne(parameters.vargroup, 'dev'), ne(parameters.vargroup, 'uat')) }}:

            DB_NAME: intodb

            DB_PASSWORD: $(dbPassword)

          DB_PORT: '3306'

          DB_USER: intoadmin

          ENVIRONMENTID: '/subscriptions/$(AZURE_SUBSCRIPTION_ID)/resourceGroups/rg-$(applicationName)-$(region)/providers/Microsoft.App/managedEnvironments/app-container-env'

          INTO_APP_MAX_REPLICA: 1

          INTO_APP_MIN_REPLICA: 1

          INTO_IMAGE: 'acrintodev.azurecr.io/intoapp:1.0.0${{ parameters.vargroup }}-$(Build.BuildId)'

          LOCATION: $(region)

          ${{ if or(eq(parameters.vargroup, 'dev'), eq(parameters.vargroup, 'uat')) }}:

            MANAGEID: '/subscriptions/$(AZURE_SUBSCRIPTION_ID)/resourcegroups/rg-abc-southeastasia/providers/Microsoft.ManagedIdentity/userAssignedIdentities/id-abc'

          ${{ if and(ne(parameters.vargroup, 'dev'), ne(parameters.vargroup, 'uat')) }}:

            MANAGEID: '/subscriptions/$(AZURE_SUBSCRIPTION_ID)/resourcegroups/rg-$(applicationName)-$(region)/providers/Microsoft.ManagedIdentity/userAssignedIdentities/id-cms'

          REDIS_HOST_SECRET: tls://redis-$(applicationName)$(region).redis.cache.windows.net

          REDIS_PASSWORD: $(redisPassword)

          ${{ if eq(parameters.vargroup, 'dev') }}:

            STORAGE_NAME: webstorage

          ${{ if eq(parameters.vargroup, 'uat') }}:

            STORAGE_NAME: webstorageuat

          ${{ if and(ne(parameters.vargroup, 'dev'), ne(parameters.vargroup, 'uat')) }}:

            STORAGE_NAME: webstorage

          VOLUME_NAME: abcstorage

          ${{ if eq(parameters.vargroup, 'dev') }}:

            ENV_CERTIFICATE_ID: /subscriptions/$(AZURE_SUBSCRIPTION_ID)/resourceGroups/rg-abc-southeastasia/providers/Microsoft.App/managedEnvironments/app-container-env/certificates/dev-abc.com

          ${{ if eq(parameters.vargroup, 'uat') }}:

            ENV_CERTIFICATE_ID: /subscriptions/$(AZURE_SUBSCRIPTION_ID)/resourceGroups/rg-abc-southeastasia/providers/Microsoft.App/managedEnvironments/app-container-env/certificates/uat-anc.com

          ${{ if and(ne(parameters.vargroup, 'dev'), ne(parameters.vargroup, 'uat')) }}:

            ENV_CERTIFICATE_ID: /subscriptions/$(AZURE_SUBSCRIPTION_ID)/resourceGroups/rg-$(applicationName)-$(region)/providers/Microsoft.App/managedEnvironments/app-cont
Azure DevOps
0 comments No comments
{count} votes

Accepted answer
  1. Suresh Chikkam 2,135 Reputation points Microsoft External Staff Moderator
    2025-04-16T05:58:33.56+00:00

    Hi Nho Luong,

    • You are using bicep version but the correct command is bicep --version

    The pipeline is expecting the bicep binary in a specific path: /home/vsts/work/_temp/.azclitask/bin/bicep, but you're moving it to /usr/local/bin/bicep.

    Update inline script like this:

    
    echo "Installing Bicep manually..."
    
    curl -Lo bicep https://github.com/Azure/bicep/releases/latest/download/bicep-linux-x64
    
    chmod +x ./bicep
    
    mkdir -p /home/vsts/work/_temp/.azclitask/bin
    
    mv ./bicep /home/vsts/work/_temp/.azclitask/bin/bicep
    
    export PATH="/home/vsts/work/_temp/.azclitask/bin:$PATH"
    
    echo "Bicep installed at $(which bicep)"
    
    bicep --version
    
    

    This above script downloads and makes the Bicep CLI executable, moves it to the path expected by Azure CLI tasks and updates the PATH so it's recognized, and finally verifies the installation using bicep --version.

    Hope it helps!


    Please do not forget to click "Accept the answer” and Yes wherever the information provided helps you, this can be beneficial to other community members.

    User's image

    If you have any other questions or still running into more issues, let me know in the "comments" and I would be happy to help you.


2 additional answers

Sort by: Most helpful
  1. Nho Luong 65 Reputation points
    2025-04-16T02:28:58.4933333+00:00

    Please help me this error?

    0 comments No comments

  2. Nho Luong 65 Reputation points
    2025-04-29T03:19:22.2233333+00:00

    Hello @Suresh Chikkam

    Many thanks for your bro support this case. My pipeline work now.
    Screen Shot 2025-04-29 at 10.17.02

    Cheers,Nho Luong

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.