Search code examples
sqlsql-serverazurepowershellazure-sql-database

How to create a login and set check policy as off in Azure SQL


I am using PowerShell to create a login in Azure SQL, but I am running into an issue of not being able to set the check policy flag as off. I am changing databases from SQL Server to Azure SQL where in SQL Server this query was allowed.

Here is an example of my PowerShell method that calls invoke-sqlcmd:

Run-powershellsqlcmd `
            -Server $DbHost -InstanceName $DbInstanceName -Port $DbPort `
            -Username $CreationUsername -Password $CreationPassword `
            -Query "CREATE LOGIN $(Get-Parameter $UserKey) WITH PASSWORD = N'$(Get-Parameter $PassKey)', CHECK_POLICY= OFF" `
            Out-Null

When I run this, I get an error

Keyword or statement option 'check_policy' is not supported in this version of SQL Server

Is there any way to turn check_policy off when creating an Azure SQL login?


Solution

  • As per this check policy is only applicable to local sql server it does not support for Azure sql server and azure sql database.

    enter image description here

    So you could not set CHECK_POLICY = ON or OFF.