[Bug] Connect-DbaInstance - Connection to Azure DB via Port 443 and not Port 1433
Environmental information
#### PowerShell version:
Name Value
---- -----
PSVersion 5.1.14393.3053
PSEdition Desktop
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
BuildVersion 10.0.14393.3053
CLRVersion 4.0.30319.42000
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
#### dbatools Module version:
Name : dbatools
Path : C:\Windows\system32\WindowsPowerShell\v1.0\Modules\dbatools\1.0.75\dbatools.psd1
Version : 1.0.75
LCID Name DisplayName
---- ---- -----------
1031 de-DE Deutsch (Deutschland)
SQL Server:
Azure SQL Server
N/A
Report
Host used
- [X] powershell.exe
- [X] ISE
- [ ] VS Code
- [ ] Other (please specify)
If anything other than powershell.exe was used, please confirm that you can duplicate the issue with powershell.exe
- [ ] Still buggy in powershell.exe
Errors Received
Ein Verbindungsversuch ist fehlgeschlagen, da die Gegenstelle nach einer bestimmten Zeitspanne nicht richtig reagiert
hat, oder die hergestellte Verbindung war fehlerhaft, da der verbundene Host nicht reagiert hat 40.126.1.130:443
In C:\Windows\system32\WindowsPowerShell\v1.0\Modules\dbatools\1.0.75\allcommands.ps1:81878 Zeichen:9
+ throw $records[0]
+ ~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [], Exception
+ FullyQualifiedErrorId : dbatools_Connect-DbaInstance
Steps to Reproduce
Connect-DbaInstance -SqlInstance "servername.database.windows.net:1433" -SqlCredential $cred -Database DatabaseName -Tenant TenantID
also tried
Connect-DbaInstance -SqlInstance "servername.database.windows.net" -SqlCredential $cred -Database DatabaseName -Tenant TenantID
Expected Behavior
- Connection via Port 1433 and not port 443
- invoke-sqlcmd works like a charm, just with the DBATools not
Actual Behavior
Connection is timed out as it is trying to connect with 443 and not SQL port 1433. Port 443 is blocked on our server, so I cannot connect to the azure database. As a test we opened port 443 on the firewall and the connection was established right after.
Additional Info: Account used to connect is a Azure Service Principle
@wsmelton I got this message send from Github but cannot see it anymore: "We do not control the port requirements or what port is used. Azure does and Azure SQL requires port 443, you don't have any other option for it."
Strange thing is that invoke-sqlcmd works on the same server and is only using Port 1433.
the way we authorize the TenantID is via their web services (port 443). I have no idea how invoke-sqlcmd is doing it without talking to web services first 🤔
are you using a tenantid with invoke-sqlcmd?
no, without the tenantid
Yeah thats the difference. We will require port 443 when using tenantid. To use solely 1433, please use another auth method.
so it will not work with the this commandlet or can I change the auth method?
yes, use the auth method you are using with invoke-sqlcmd. let me know if that gives problems
$AzureDBConnection = @{ ServerInstance = "servername.database.windows.net" Database = "databaseName" credential = New-Object System.Management.Automation.PSCredential ("useraccount", $securePass) EncryptConnection = $True ErrorAction = "Stop" } invoke-sqlcmd @AzureDBConnection -Query "Select * from table"
I'm not specifiying any auth method or did I misunderstood you
I am referrring to Connect-DbaInstance as listed above: Connect-DbaInstance -SqlInstance "servername.database.windows.net:1433" -SqlCredential $cred -Database DatabaseName -Tenant TenantID
Can You do
$AzureDBConnection = @{
SqlInstance = "servername.database.windows.net"
Database = "databaseName"
SqlCredential = New-Object System.Management.Automation.PSCredential ("useraccount", $securePass)
EncryptConnection = $True
ErrorAction = "Stop"
}
Connect-DbaInstance @AzureDBConnection
I get a "Login failed for user 'AppID'"
also the same error message if I execute the command without " -Tenant 'TenantID' "
🤔 seems like logic failure on my part, but @jaykul is all up in this command. can you take a look, Joel?
This issue has been automatically marked as stale because it has not had recent activity. If you would like this issue to remain open:
- Verify that you can still reproduce the issue in the latest version of dbatools
- Comment that the issue is still reproducible and include:
- What version of dbatools you reproduced the issue on
- What OS and version you reproduced the issue on
- What steps you followed to reproduce the issue
This issue has been automatically closed because it has not had activity in the last three months. If this issue is still valid, please add a comment
🚧🚨 This issue is being marked as stale due to 90 days of inactivity. If you would like this issue to remain open:
- Verify the issue/bug is reproduced in the latest version of the module
- Verify the environmental info provided is still accurate
- Add any additional steps you followed to reproduce if necessary 🚨🚧 ⌛️ This issue will be closed in 30 days ⌛️
I will close this for now, but you can reopen it if this is still an issue with the current version.
Hi Shawn, what do we want to do with this issue?
I had another look at this, and in the future we will not support the use of -Tenant any more.
We introduced -AccessToken as a new way to use advaned authentication methods with azure, see the last example at https://docs.dbatools.io/Connect-DbaInstance.
We will continue to support that because there is no valid reason not to.
The parameter you speak of that was introduced requires more effort on the users part when dealing with Azure. Why? What purpose is served when the method of getting a token with New command we have can be done? @andreasjordan