我正在编写一个bash脚本,用于使用“armclient”将证书从linux服务器上载到azure keyvault
我遵循以下关于如何使用armclient的指南:
https://blogs.msdn.microsoft.com/appserviceteam/2016/05/24/deploying-azure-web-app-certificate-through-key-vault/
我要执行的命令是:
ARMClient.exe PUT /subscriptions/<Subscription Id>/resourceGroups/<Server Farm Resource Group>/providers/Microsoft.Web/certificates/<User Friendly Resource Name>?api-version=2016-03-01 "{'Location':'<Web App Location>','Properties':{'KeyVaultId':'<Key Vault Resource Id>', 'KeyVaultSecretName':'<Secret Name>', 'serverFarmId':'<Server Farm (App Service Plan) resource Id>'}}"
我创建了一个字符串,用于填充所有必需的字段:
putparm=$resolved_armapi" \"{'Location':'$resolved_locationid','Properties':{'KeyVaultId':'$resolved_keyvaultid','KeyVaultSecretName':'$certname','serverFarmId':'$resolved_farmid'}}"\"
当我回显变量putparm的输出时,结果看起来与预期的一样(x-ed-out-names/id):
/subscriptions/f073334f-240f-4261-9db5-XXXXXXXXXXXXX/resourceGroups/XXXXXXXX/providers/Microsoft.Web/certificates/XXXX-XXXXX-XXXXX?api-version=2016-03-01 "{'Location':'Central US','Properties':{'KeyVaultId':'/subscriptions/f073334f-240f-4261-9db5-XXXXXXXXXXXXX/resourceGroups/XXXXXXXX/providers/Microsoft.KeyVault/vaults/XXXXXXXX','KeyVaultSecretName':'XXXX-XXXXX-XXXXX','serverFarmId':'/subscriptions/f073334f-240f-4261-9db5-XXXXXXXXXXXXX/resourceGroups/XXXXXXXX/providers/Microsoft.Web/serverfarms/ServicePlan59154b1c-XXXX'}}"
当我跑的时候
armclient put $putparm
在脚本中,我得到这个错误:
“错误”:。{
“code”:“无效请求内容”,
“message”:“请求内容无效,无法反序列化:”“未终止的字符串。”需要分隔符:\”。路径“”,
第1行,位置21。'.“}
但是,当我获取$putparm变量的输出并在服务器上“手动”运行命令时,它就工作了。
我想这与linux存储变量的方式有关,而且api正在请求json(或者其他什么东西)。
乐意接受任何帮助。