Azure Communication Services deploy fails due to InvalidResourceOperation

Tim Joosten 20 Reputation points
2023-06-13T11:19:21.59+00:00

The first run deploying communication services using the Bicep file below succeeds. However when deploying a second time the deployment fails due to an InvalidResourceOperation error. Could anyone tell me how to solve this issue?

When removing the resources and rerunning deployment resources are successfully created.

{
  "code": "DeploymentFailed",
  "target": "/subscriptions/711699cf-05b7-4ec1-948b-65637bfb0de0/resourceGroups/sso-dev/providers/Microsoft.Resources/deployments/nexusCommunications-20230613.3",
  "message": "At least one resource deployment operation failed. Please list deployment operations for details. Please see https://aka.ms/arm-deployment-operations for usage details.",
  "details": [
    {
      "code": "InvalidResourceOperation",
      "message": "The operation for resource '/subscriptions/711699cf-05b7-4ec1-948b-65637bfb0de0/resourceGroups/sso-dev/providers/Microsoft.Communication/communicationServices/coms-hsks-nxs-dev-we' is invalid as it is being provisioned with state: 'Accepted'."
    }
  ]
}
// https://learn.microsoft.com/en-us/azure/templates/microsoft.communication/communicationservices?pivots=deployment-language-bicep
// https://learn.microsoft.com/en-us/azure/templates/microsoft.communication/emailservices?pivots=deployment-language-bicep

param communicationsName string
param communicationsEmailName string
param domainUsername string
param domainDisplayName string

resource communicationsEmail 'Microsoft.Communication/emailServices@2023-03-01-preview' = {
  name: communicationsEmailName
  location: 'global'
  tags: {}
  properties: {
    dataLocation: 'Europe'
  }
}

resource communicationsEmailDomain 'Microsoft.Communication/emailServices/domains@2023-03-01-preview' = {
  name: 'AzureManagedDomain'
  location: 'global'
  parent: communicationsEmail
  properties: {
    domainManagement: 'AzureManaged'
    userEngagementTracking: 'Disabled'
  }
}

resource communicationsEmailDomainSendUsername 'Microsoft.Communication/emailServices/domains/senderUsernames@2023-03-01-preview' = {
  name: domainUsername
  parent: communicationsEmailDomain
  properties: {
    displayName: domainDisplayName
    username: domainUsername
  }
}

resource communications 'Microsoft.Communication/communicationServices@2023-03-01-preview' = {
  name: communicationsName
  location: 'global'
  tags: {}
  properties: {
    dataLocation: 'Europe'
    linkedDomains: [
      communicationsEmailDomain.id
    ]
  }
}

// Determine our connection string
var communicationsConnectionString = listKeys(communications.id, communications.apiVersion).primaryConnectionString

// Output our variables
output communicationsConnectionString string = communicationsConnectionString
output communicationsEmailDomainName string = communicationsEmailDomain.name
Azure Communication Services
Azure Communication Services
An Azure communication platform for deploying applications across devices and platforms.
905 questions
{count} votes

Accepted answer
  1. Tushar Kumar 3,331 Reputation points MVP
    2023-06-13T11:35:08.1233333+00:00

    Try changing the name to someting else seems like some previous deployment

    coms-hsks-nxs-dev-weu
    
    1 person found this answer helpful.

1 additional answer

Sort by: Most helpful
  1. Bhoir, Harshal Mahendra 0 Reputation points
    2024-07-10T04:49:56.25+00:00

    I am getting this same error in our CD pipeline while deploying to one particular environment (UAT) while for the other env (Dev, QA) it worked fine. Any solution for this?

    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.