Code=DeploymentActive

Pankaj Zade (Hitachi) 5 Reputation points
2023-07-17T18:53:36.0866667+00:00

I am running bicep script to deploy I am getting below error

10:57:17 AM - Error: Code=DeploymentActive; Message=Unable to edit or replace deployment 'xxxxDEV-Apim': previous deployment from '7/17/2023 2:56:35 PM' is still active (expiration time is '7/24/2023 2:56:31 PM'). Please see https://aka.ms/arm-deploy-resources for usage details.

I did check deployment status following path

resourcegroup -> deployment ->List(xxxxDEV-Apim) -> Status (Successful)

I did delete it and re-run deployment again. Still I could see same error.

In short deleting deployment from resource group not helping.

I am stuck and don't know how to proceed further, please help?

Azure API Management
Azure API Management
An Azure service that provides a hybrid, multi-cloud management platform for APIs.
2,175 questions
Microsoft Deployment Toolkit
Microsoft Deployment Toolkit
A collection of Microsoft tools and documentation for automating desktop and server deployment. Previously known as Microsoft Solution Accelerator for Business Desktop Deployment (BDD).
904 questions
Microsoft Configuration Manager Deployment
Microsoft Configuration Manager Deployment
Microsoft Configuration Manager: An integrated solution for for managing large groups of personal computers and servers.Deployment: The process of delivering, assembling, and maintaining a particular version of a software system at a site.
992 questions
0 comments No comments
{count} vote

4 answers

Sort by: Most helpful
  1. Bryan Allen 5 Reputation points
    2024-03-21T17:07:34.1733333+00:00

    I am also experiencing this issue daily when executing bicep templates via Azure DevOps pipeline.

    Unable to edit or replace deployment 'cosmos-account': previous deployment from '3/21/2024 4:50:20 PM' is still active (expiration time is '3/28/2024 4:50:19 PM'). Please see https://aka.ms/arm-deploy-resources for usage details. (Code: DeploymentActive)
    

    Under Subscription > Deployments, the deployment is in a failed state and cannot be canceled. Additionally under Subscription > Resource Group > Deployments, the deployment is in a failed state and cannot be canceled. Deleting a deployment is not advisable for traceability.

    If I drill into the 'cosmos-account' deployment error, all of its components happen to be deployed successfully, but the overall deployment failed.

    I've executed this deployment multiple times. This error is intermittent.

    1 person found this answer helpful.
    0 comments No comments

  2. Pramod Valavala 20,636 Reputation points Microsoft Employee
    2023-07-18T00:36:57.9933333+00:00

    @Pankaj Zade (Hitachi) Azure APIM resources are by default soft-deleted when done from the Azure Portal. This is to protect against accidental deletion of services.

    In your case, since you are sure you want to delete the service, you will need to purge the soft-deleted instance. This can be done via the REST API as the docs mention or even using the az apim deletedservice purge command in Azure CLI.


  3. Simon Ren-MSFT 35,396 Reputation points Microsoft Vendor
    2023-07-18T07:47:41.2033333+00:00

    Hi,

    Thank you for posting in Microsoft Q&A forum.

    The error indicates that there is a previous deployment that is still active and hasn't expired yet. You can't create a new deployment to replace or edit the active deployment until it has expired.

    Per my experience, to resolve this issue, you need to wait until the active deployment expires or you can manually delete the active deployment from the command line using Azure CLI or PowerShell. You can try to use the Azure deployment group delete command in Azure CLI or the Remove-AzResourceGroupDeployment command in PowerShell to delete deployments from the history.

    If you want to delete all deployments older than a certain number of days, you can use the --older-than parameter. For example, to delete all deployments older than five days, you can try the following command in Azure CLI:

    az deployment group delete --resource-group <resource-group-name> --name <deployment-name> --older-than 5d

    Refer to: az deployment group

    And, for PowerShell, you can run the following command:

    Remove-AzResourceGroupDeployment -ResourceGroupName <resource-group-name> -Name <deployment-name> -AgeFilterInDays 5

    Thanks for your time. Have a nice day!

    Best regards,

    Simon


    If the response is helpful, please click "Accept Answer" and upvote it.

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments

  4. Matthew Lee 5 Reputation points
    2024-02-28T14:25:01.08+00:00

    Hi, I'm experiencing this issue daily when deploying from Azure DevOps and for traceability purposes, I'm not too keen to delete any deployment history. Any insight would be greatly appreciated. Thanks Matt We are using unique names for the bicep modules, like e.g.:

    module
      
    
    

    My deployment yaml looks like this:

              - powershell: |
                  $timestamp =  Get-Date -Format "yyyyMMddTHHmmssss"
                  Write-Host "##vso[task.setvariable variable=timestamp;isoutput=true]$timestamp"          
                name: setTimestamp
    
    
              - task: AzureCLI@2
                inputs:
                  azureSubscription: '${{ parameters.SubscriptionConnectionId }}'
                  scriptType: 'bash'
                  scriptLocation: 'inlineScript'
                  workingDirectory: $(System.ArtifactsDirectory)
                  inlineScript: |
                    az deployment group create \
                      --name $(setTimestamp.timestamp) \
                      --resource-group ${{ parameters.ResourceGroup }} \
                      --template-file ${{parameters.TemplateRelativeFileLocation}} \
                      --parameters ${{parameters.ParametersRelativeFileLocation}} 		${{parameters.OptionalArguments}}
    
    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.