3
votes

We are creating 2 cloud services in parallel with one deployment(VM Role) in each cloud service. For both requests (Sometimes only on 1) we are getting the following 409 Conflict error as a response to create hosted service POST request:

409 ConflictError : Windows Azure is currently performing an operation on this hosted service that requires exclusive access.

On getting the exception we have a cleanup call and in retry we are trying to create again. On each retry we are using a new cloud service name.

The error occurs few times, every time we invoke the creation of 2 cloud services with VM in parallel. And on 2-15 retries, its getting created successfully. However when we invoke 1 cloud service creation with VM, we are not seeing this error. Not sure why this error is thrown during simultaneous creations. Any help would be greatly appreciated. Thanks.

1

1 Answers

0
votes

The only way is to catch the error and retry now, it's a limitation of Windows Azure. Azure requires most requests to be serialized.

Something like this, you can change Stop-AzureVM to your command require exclusive access.

$error.Clear();

Stop-AzureVM -Name $VMName -ServiceName $CloudServiceName -Force

$retryCount=0;

while($error[0].Exception.Message.Contains("ConflictError") -and $retryCount -le 10)
{
    Start-Sleep -Seconds 180
    Stop-AzureVM -Name $VMName -ServiceName $CloudServiceName -Force
    $retryCount = $retryCount + 1;        
}