我正在尝试使用Azure DevOps发布管道将一些用户添加到Azure SQL DB Server。
Azure DevOps用于使用连接到我们订阅的服务主体来构建基础结构。一切正常,但是当我尝试在DevOps中使用DACPAC任务配置数据库用户时,使用Microsoft身份验证(集成)模式进行身份验证时会出现错误。
如果我在任务中使用SQL Server管理员登录名,则会运行SQL命令,但由于我使用的登录名不是AD登录名,因此无法分配用户。
我曾尝试将Azure门户中的AD Admin设置为服务主体-这对我来说很有意义-但该任务失败,并显示与身份验证相关的错误。
我还尝试部署DACPAC而不是运行SQL Command并遇到类似问题。
我要运行的SQL命令:
IF NOT EXISTS (SELECT * FROM sys.sysusers WHERE name = 'azSG-XXXX-Fred')
CREATE USER [azSG-XXXX-Fred] FOR EXTERNAL PROVIDER;
GO
输出如下:
2019-07-31T10:57:38.6287831Z ##[section]Starting: Azure SQL SqlTask
2019-07-31T10:57:38.6393885Z ==============================================================================
2019-07-31T10:57:38.6394009Z Task : Azure SQL Database deployment
2019-07-31T10:57:38.6394095Z Description : Deploy an Azure SQL Database using DACPAC or run scripts using SQLCMD
2019-07-31T10:57:38.6394185Z Version : 1.153.0
2019-07-31T10:57:38.6394249Z Author : Microsoft Corporation
2019-07-31T10:57:38.6394342Z Help : https://docs.microsoft.com/azure/devops/pipelines/tasks/deploy/sql-azure-dacpac-deployment
2019-07-31T10:57:38.6394428Z ==============================================================================
2019-07-31T10:57:49.8641267Z Temporary inline SQL file: C:\Users\VssAdministrator\AppData\Local\Temp\tmp4A74.tmp
2019-07-31T10:57:49.8843725Z Invoke-Sqlcmd -connectionString "Data Source=xxxxxxxxxx.database.windows.net; Initial Catalog=master; Authentication=Active Directory Integrated;" -Inputfile "C:\Users\VssAdministrator\AppData\Local\Temp\tmp4A74.tmp"
2019-07-31T10:57:52.7552260Z Sql file: D:\a\r1\a\BuildDirectory\SQLServer\azSG-XXXX-Fred.sql
2019-07-31T10:57:52.7583808Z Invoke-Sqlcmd -connectionString "Data Source=xxxxxxxxxxxx.database.windows.net; Initial Catalog=master; Authentication=Active Directory Integrated;" -Inputfile "D:\a\r1\a\BuildDirectory\SQLServer\azSG-XXXX-Fred.sql" -Verbose
2019-07-31T10:57:52.9929063Z ##[error]One or more errors occurred.
2019-07-31T10:57:53.0718651Z ##[error]ManagedBatchParser.ParserException
at ManagedBatchParser.Parser.Parse()
at Microsoft.SqlServer.Management.PowerShell.ExecutionProcessor.ExecuteTSql(String sqlCommand)Check out how to troubleshoot failures at https://aka.ms/sqlazuredeployreadme#troubleshooting-
2019-07-31T10:57:53.1217956Z ##[section]Finishing: Azure SQL SqlTask