我已在 azure blob 存储容器中设置了 SAS 令牌。目前它是有效的,正如 Windows cmd.exe 中的此命令有效的事实所证明的那样:
azcopy list "https://<mystorageaccountname>.blob.core.windows.net/<mystorageaccountcontainername>/path/to/file.BAK?<SAS token>"
Run Code Online (Sandbox Code Playgroud)
并作为输出返回:
INFO: ; Content Length: 7.58 GiB
Run Code Online (Sandbox Code Playgroud)
现在,如果我通过 SSMS 在 SQL Server 中发出以下命令(服务器在发出 azcopy 命令的同一台计算机上本地运行,并且 <> 括号中的值与上面相同。请注意,我末尾没有“/”容器名称,并且令牌中没有“?”,遵循 Microsoft 文档的建议):
CREATE CREDENTIAL [https://<mystorageaccountname>.blob.core.windows.net/<mystorageaccountcontainername>]
-- this name must match the container path, start with https and must not contain a forward slash at the end
WITH IDENTITY='SHARED ACCESS SIGNATURE'
-- this is a mandatory string and should not be changed
, SECRET = '<SAS token>';
GO
RESTORE HEADERONLY FROM …
Run Code Online (Sandbox Code Playgroud)