Hi Team, Need help in identifying the issue with below script. I am trying to Pause the Synapse services using below code but getting error as " Logging in to Azure...Connection not found." However, I am able to pause the services if I manually Login to the Azure account by signing in through email id.
try
{
"Logging in to Azure..."
Connect-AzAccount `
-ServicePrincipal `
-TenantId $servicePrincipalConnection.TenantId `
-ApplicationId $servicePrincipalConnection.ApplicationId `
-CertificateThumbprint $servicePrincipalConnection.CertificateThumbprint
}
catch {
if (!$servicePrincipalConnection)
{
$ErrorMessage = "Connection not found."
write-output $ErrorMessage
} else{
Write-Error -Message $.Exception
throw $.Exception
}
}
$database = Get-AzSqlDatabase ResourceGroupName "ABCD" ServerName "XYZ" DatabaseName "BCB"
if($database){
if($database.Status -eq 'online'){
$database | Suspend-AzSqlDatabase
Write-Output "The Data Warehouse was Active and paused now."
}else{
Write-Output "The Data Warehouse has already been paused."
}
}else{
Write-Output "The Data Warehouse does not exist."
}