dataplat / dbatools

🚀 SQL Server automation and instance migrations have never been safer, faster or freer
https://dbatools.io
MIT License
2.45k stars 797 forks source link

Copy-DbaDatabase - Could not discover a user realm #8602

Closed Johannes0501 closed 1 year ago

Johannes0501 commented 1 year ago

Verified issue does not already exist?

I have searched and found no existing issue

What error did you receive?

I am migrating from an on premise SQL server to azure managed SQL, using SQL credentials.

Getting this error Error occurred while establishing connection to "" | Could not discover a user realm.

Connect-DbaInstance with same credentials works fine.

Steps to Reproduce

# provide your command(s) executed pertaining to dbatools
# please include variable values (redacted or fake if needed) for reference
$copyParams = @{
    Source = $from 
    Destination = $to
    Database = $database
    BackupRestore = $True
    WithReplace = $True
    SourceSqlCredential = $cred 
    SetSourceOffline = $True        
    SharedPath = $blobPath
    AzureCredential = $blobAzCred
}  

Copy-DbaDatabase @copyParams

Please confirm that you are running the most recent version of dbatools

1.1.141

Other details or mentions

No response

What PowerShell host was used when producing this error

Windows PowerShell ISE (powershell_ise.exe)

PowerShell Host Version

PSVersion 5.1.17763.2090 PSEdition Desktop PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...} BuildVersion 10.0.17763.2090 CLRVersion 4.0.30319.42000 WSManStackVersion 3.0 PSRemotingProtocolVersion 2.3 SerializationVersion 1.1.0.1

SQL Server Edition and Build number

From: Microsoft SQL Server 2019 (RTM) - 15.0.2000.5 (X64) Sep 24 2019 13:48:23 Copyright (C) 2019 Microsoft Corporation Web Edition (64-bit) on Windows Server 2019 Standard 10.0 (Build 17763: ) (Hypervisor)

To: Microsoft SQL Azure (RTM) - 12.0.2000.8 Sep 30 2022 04:45:23 Copyright (C) 2022 Microsoft Corporation

.NET Framework Version

4.7.03190

Johannes0501 commented 1 year ago

Solved by using DestinationSqlCredential parameters