Joh*_*ohn 3 powershell azure-cli
我正在使用 PowerShell 中的 Azure CLI 2.0 来管理存储帐户。我有一个 SAS 令牌(我将其存储在一个变量中)并且我想在命令中使用它。这是我正在运行的脚本:
$sasToken = 'st=2017-11-13T10%3A55%3A06Z&se=2017-11-13T11%3A27%3A06Z&sp=w&spr=https&sv=2017-04-17&sr=c&sig=%2BA6LDTwHes6JdxEAHXSvbYc70y30OcznjMVSyFbCXog%3D'
az storage blob upload `
--account-name mystorageaccount `
--container-name mycontainer `
--file c:\temp\file.txt `
--name file.txt `
--sas-token $sasToken
Run Code Online (Sandbox Code Playgroud)
当我运行这个时,我收到这个错误:
The specified resource does not exist.
'se' is not recognized as an internal or external command,
operable program or batch file.
'sp' is not recognized as an internal or external command,
operable program or batch file.
'spr' is not recognized as an internal or external command,
operable program or batch file.
'sv' is not recognized as an internal or external command,
operable program or batch file.
'sr' is not recognized as an internal or external command,
operable program or batch file.
'sig' is not recognized as an internal or external command,
operable program or batch file.
Run Code Online (Sandbox Code Playgroud)
在我看来,PowerShell 每次看到 & 符号时都会截断 SAS 令牌,而 Azure CLI 没有将其作为同一字符串的所有部分。
有没有办法强制 PowerShell 完全按原样使用 SAS 令牌调用 Azure CLI?
尝试将 SAS 令牌包装在第二组引号中:
$sasToken = '"st=2017-11-13T10%3A55%3A06Z&se=2017-11-13T11%3A27%3A06Z&sp=w&spr=https&sv=2017-04-17&sr=c&sig=%2BA6LDTwHes6JdxEAHXSvbYc70y30OcznjMVSyFbCXog%3D"'
以便 CLI 命令如下所示:
--sas-token "st=2017-11-13T10%3A55%3A06Z&se=2017-11-13T11%3A27%3A06Z&sp=w&spr=https&sv=2017-04-17&sr=c&sig=%2BA6LDTwHes6JdxEAHXSvbYc70y30OcznjMVSyFbCXog%3D"
| 归档时间: |
|
| 查看次数: |
1499 次 |
| 最近记录: |