0
votes

I'm trying to change the ResourceGroup for my Azure SQL Server (This includes one database I've added to this group and of course the master database). I created a new Azure Group and when I try switching the that group, I get a ResourceNotFound error.

The error displays the name of a database that I've been trying to deploy on the ResourceGroup I'm changing from, but it fails on deployment so there's no database of that name available.

This error occurs on the validation step and gives me this message:

{"code":"ResourceMoveFailed","message":"Could not get all the resources to be moved from the providers. Please see details for more information. Diagnostic information: timestamp '20190806T192716Z', subscription id '******', tracking id '*******', request correlation id '*******'.","details":[{"message":"Unable to get resource '/modules/AzureResourceManager/subscriptions/*******/resourcegroups/********/providers/Microsoft.Sql/servers/********/databases/{Undeployed_Database_Name}'. Status code 'NotFound'. Reason '{\"error\":{\"code\":\"ResourceNotFound\",\"message\":\"The requested resource of type 'Microsoft.Sql/servers/databases' with name '{Undeployed_Database_Name}' was not found.\"}}'."}]}

{Undeployed_Database_Name} pertains to the database name of the deployment that had failed. I'm assuming the deployment failure must have not completely rolled back during the error that had occurred, but I can't find this database ANYWHERE. Any help would be appreciated.

3

3 Answers

1
votes

Did you followed these steps in Portal?

  1. Clink your SQL Server overview, Move to another resource group:

enter image description here

  1. Check all the resources in the SQL server which you want to move. enter image description here

3.Click ok and wait the moving completed. Check the sql server in new Resource group: enter image description here

Hope this helps.

1
votes

Try using PowerShell instead. Sometimes the portal does not work as expected temporarily. The following example shows how to move several resources to a new resource group.

$webapp = Get-AzResource -ResourceGroupName OldRG -ResourceName ExampleSite
$plan = Get-AzResource -ResourceGroupName OldRG -ResourceName ExamplePlan
Move-AzResource -DestinationResourceGroupName NewRG -ResourceId $webapp.ResourceId, $plan.ResourceId

You can also use Azure CLI.

webapp=$(az resource show -g OldRG -n ExampleSite --resource-type "Microsoft.Web/sites" --query id --output tsv)
plan=$(az resource show -g OldRG -n ExamplePlan --resource-type "Microsoft.Web/serverfarms" --query id --output tsv)
az resource move --destination-group newgroup --ids $webapp $plan

And you can use REST API also as explained here.

0
votes

I figured out a way to resolve this issue, but it's not ideal for most situations. The problem seemed to come up by doing this:

I had created a free database (the 5 DTU 32 MB database). I tried to create another free database and it failed probably because you can't have more than one free database. This failed deployment ended up causing the issue I had.

I ended up deleting my SQL Server, which is where I was trying to host both of the free databases. Upon doing this I was able to create a new SQL Server with a basic database and a free database with no issues. I even named them the same name as the one I was trying to deploy before with no issues. I feel like this may have been a bug with how resources are handled when a deployment has failed, but I can't say for sure since I'm newer to Azure. Just wanted to give you all my solution, but I'd like to here if anyone else has had this issue and has solved it in a different way.