找不到资源组下的资源(SQL 服务器)

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

当我尝试在弹性池中获取数据库时出现错误:

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

但对于其他数据库服务器和资源组,此脚本有效。

我正在尝试的脚本:

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 "

我验证了权限、资源及其 names/ids 都是正确的。

根据错误消息,我可以看到您将 -ServerName 提供为 dbserver.database.windows.net

请仅提供 -ServerName dbserver 而不是 dbserver.database.windows.net