Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

The Resource (SQL Server) under resource group was not found

When I'm trying to fetch DB in elastic pool getting error as:

The Resource 'Microsoft.Sql/servers/dbserver.database.windows.net/databases/db_name' under resource group 'rg_name' was not found.

But for other DB servers and resource group, this script works.

The script I'm trying:

Import-Module Az.Accounts
Import-Module Az.Sql

#Connect-AzAccount -SubscriptionId $subscriptionId
$passwd = ConvertTo-SecureString <PASSWORD> -AsPlainText -Force
$pscredential = New-Object System.Management.Automation.PSCredential('<Application ID>/<Service Principle ID>', $passwd)
Connect-AzAccount -ServicePrincipal -Credential $pscredential -Tenant $tenantId 
#-SubscriptionId $subscriptionId

$rg = Get-AzResourceGroup -Name $resourceGroupName

Set-AzSqlDatabase -DatabaseName $DatabaseName -ElasticPoolName $PoolName -ResourceGroupName $rg.ResourceGroupName -ServerName $serverName 

Read-Host -Prompt "Press Enter to exit "

I verified the permissions, resources and their names/ids all are correct.

like image 982
Akash Samal Avatar asked Dec 18 '22 15:12

Akash Samal


1 Answers

According to the error message, I can see that you are providing the -ServerName as dbserver.database.windows.net

Please provide the -ServerName as only dbserver instead of dbserver.database.windows.net

like image 164
AmanGarg-MSFT Avatar answered Jan 21 '23 18:01

AmanGarg-MSFT