ARM模板中的新AzureRmVpnClientRootCertificate
如何使用Azure ARM模板而不是使用Powershell命令New-AzureRmVpnClientRootCertificate上载客户端根证书?我把整个环境都放在一个模板中,这是唯一缺少的东西。在VM的OSProfile部分,您可以放以下内容:ARM模板中的新AzureRmVpnClientRootCertificate,azure,arm-template,Azure,Arm Template,如何使用Azure ARM模板而不是使用Powershell命令New-AzureRmVpnClientRootCertificate上载客户端根证书?我把整个环境都放在一个模板中,这是唯一缺少的东西。在VM的OSProfile部分,您可以放以下内容: "secrets": [ { "sourceVault": { "id": "[parameters('sourceVaultValue')]"
"secrets": [
{
"sourceVault": {
"id": "[parameters('sourceVaultValue')]"
},
"vaultCertificates": [
{
"certificateStore": "[parameters('certificateStoreValue')]",
"certificateUrl": "[parameters('certificateUrlValue')]"
}
]
}
其中,源vault值为“/subscriptions/subId/resourceGroups/RGName/providers/Microsoft.KeyVault/vaults/KVName”
cert store value是我的或您想要使用的任何存储
证书URL值为“”
因此,您显然需要创建一个密钥库,并将您的证书作为机密添加到其中。您可以通过base 64编码证书并上传该字符串来完成此操作,如下所示:
$flag = [System.Security.Cryptography.X509Certificates.X509KeyStorageFlags]::Exportable
$collection = New-Object System.Security.Cryptography.X509Certificates.X509Certificate2Collection
$collection.Import($pfxFilePath, $pwd, $flag)
$pkcs12ContentType = [System.Security.Cryptography.X509Certificates.X509ContentType]::Pkcs12
$clearBytes = $collection.Export($pkcs12ContentType)
$fileContentEncoded = [System.Convert]::ToBase64String($clearBytes)
$jsonObject = @{
data = $filecontentencoded
dataType = 'pfx'
} | ConvertTo-Json
$jsonObjectBytes = [System.Text.Encoding]::UTF8.GetBytes($jsonObject)
$jsonEncoded = [System.Convert]::ToBase64String($jsonObjectBytes)
$secret = ConvertTo-SecureString -String $jsonEncoded -AsPlainText -Force
return $secret
其中$pfxFilePath和$pwd是证书的路径,pwd是密码
然后使用-SecretValue$secret(和其他参数)上传