Azure SQL创建数据库范围的凭据 [英] Azure SQL Creating Database Scoped Credential

查看:99
本文介绍了Azure SQL创建数据库范围的凭据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用SSMS在Azure SQL中创建范围凭证.

I'm trying to create a scoped credential in azure SQL using SSMS.

CREATE DATABASE SCOPED CREDENTIAL [cred-name] WITH IDENTITY = [db-user], SECRET = 'password'

我一直遇到错误消息,指出'cred-name'附近的语法不正确.预期为'='."我不确定我的语法是不正确的,因为我过去已经成功完成了此确切命令,所以我不确定发生了什么变化.我以为可能只是intellisense搞砸了,所以我将SSMS实例从17.3更新到17.7,但是我仍然收到相同的错误消息.

I keep running into the error message stating "Incorrect syntax near 'cred-name'. Expected '='." I'm not sure how my syntax is incorrect as I've done this exact command successfully in the past so I'm not sure what has changed. I thought maybe it was just intellisense that was messing up so I updated my SSMS instance from 17.3 to 17.7 but I still get the same error message.

有人对可能发生的变化有任何想法吗?

Does anyone have any idea of what could have changed?

推荐答案

运行针对 Microsoft SQL Azure(RTM)发布的完全T-SQL-12.0.2000.8 2018年5月4日13:05:56 版本会导致以下错误:

Running the exactly T-SQL you posted against Microsoft SQL Azure (RTM) - 12.0.2000.8 May 4 2018 13:05:56 version leads to the following error:

Msg 102, Level 15, State 1, Line 1
Incorrect syntax near 'db-user'.

将身份名称方括号替换为单引号会导致以下错误:

Replacing the identity name brackets for single quotes leads to the error below:

Msg 15581, Level 16, State 6, Line 1
Please create a master key in the database or open the master key in the session before performing this operation.

使用以下T-SQL创建主密钥可以使我成功创建凭据:

Creating the master key with following T-SQL allows me to create the credential successfully:

CREATE MASTER KEY ENCRYPTION BY PASSWORD='MyPassw0rdIsComplex.'
GO

CREATE DATABASE SCOPED CREDENTIAL [cred-name] WITH IDENTITY = 'db-user' , SECRET = 'password'
GO

此外,您还可以使用以下查询来检查范围凭证:

Also, you can check if the scoped credential using the following query:

SELECT * FROM sys.database_scoped_credentials WHERE credential_identity='db-user'

我正在使用SSMS版本17.2,但是我不确定这是否重要,因为错误将来自SQL Server引擎本身.

I'm using SSMS version 17.2, but I'm not sure if this matters since errors would come from the SQL Server engine itself.

这篇关于Azure SQL创建数据库范围的凭据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆