Share via

Use bicep to move sql server

Hao Hu 20 Reputation points Microsoft External Staff
2024-01-11T15:41:15.75+00:00

Can we use bicep to move sql server from one resource group to another resource group? I have a sql server in resource group A, and I want to move this sql server to resource group B, both resource group are under same subscription.

Azure SQL Database
Azure
Azure

A cloud computing platform and infrastructure for building, deploying and managing applications and services through a worldwide network of Microsoft-managed datacenters.

0 comments No comments

2 answers

Sort by: Most helpful
  1. Wilko van de Velde 2,241 Reputation points
    2024-01-12T07:41:19.7966667+00:00

    It is indeed not possible by bicep. But it possible to move the SQL server through the portal.

    1. Navigate to the SQL server you want to move
    2. Select Move > Move to another resource group
      User's image
    3. Then a wizard starts to select the source and target destination

    It should also possible with the Azure resource mover, but I don't have any experience with this. More info: https://learn.microsoft.com/en-us/azure/resource-mover/tutorial-move-region-sql

    Kind Regards,

    Wilko


    Please do not forget to "Accept the answer” wherever the information provided helps you, this can be beneficial to other community members. If you have extra questions about this answer, please click "Comment".

    Was this answer helpful?


  2. Stanislav Zhelyazkov 29,586 Reputation points MVP Volunteer Moderator
    2024-01-12T07:19:30.2833333+00:00

    Hi, This is not possible. Bicep is Infrastructure as code (IaC) where moving a resource from one resource group to another is more like operation rather configuring state. Similar things that are operation are start or stopping a VM or other resource, etc. Of course you can always use deploymentScripts resources which allows you to execute PowerShell/Az CLI scripts but at the end you will still write a script for that not so much Bicep code.

    Please "Accept the answer" if the information helped you. This will help us and others in the community as well.

    Was this answer helpful?

    0 comments No comments

Your answer

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