title: Operation cannot be performed on database because it is involved in a database mirroring session or an availability group (Azure)
body: <p>I am experiencing an intermittent issue with SQL Azure. I am copying a readonly SQL Azure database (V12) from one elastic pool into another. Once the database is copied, I set it to read/write using:</p>
  
  <pre><code>$"ALTER DATABASE [{databaseName}] SET READ_WRITE"
  </code></pre>
  
  <p>This sometimes fails with the error:</p>
  
  <blockquote>
    <p>The operation cannot be performed on database *** because it is
    involved in a database mirroring session or an availability group</p>
  </blockquote>
  
  <p>I have tried implementing retry logic with backoff but that doesn't work. I have failed to find any documentation relating to this error or to database mirroring in Azure.</p>
  
  <p>Any advice would be greatly appreciated!</p>