没有用户名和密码的 Get-ShardMapManager
Get-ShardMapManager without Username and Password
是否可以在创建新的分片映射管理器时调用 Get-ShardMapManager
而不涉及用户名和密码(通过硬编码或将值存储在密钥库中)
这是我目前在 powershell 中的代码
$ShardMapManager = Get-ShardMapManager -Username $DbUsrId -Password $DbPwd
我可以使用令牌或类似的东西吗?只是不涉及用户名和密码的任何内容?谢谢
不,你不能。从Get-ShardMapManager
的source code开始,UserName
和Password
都是Mandatory=$true
。
在这种情况下,如果您只是因为安全问题而想避免使用它们,您可以使用 azure keyvault 通过 Set-AzKeyVaultSecret
as you mentioned. Retrieve them in the commands, then pass them to Get-ShardMapManager
, just user/service principal that added to the access policy of the keyvault is able to get them(or has the Key Vault Administrator
if you select Azure role-based access control
in Access policies
blade 来存储它们密钥库)。
确保你已经安装了Az
powershell模块,然后使用下面的命令。
Connect-AzAccount
$DbUsrId = Get-AzKeyVaultSecret -VaultName "keyvaultname" -Name "username" -AsPlainText
$DbPwd = Get-AzKeyVaultSecret -VaultName "keyvaultname" -Name "password" -AsPlainText
$ShardMapManager = Get-ShardMapManager -Username $DbUsrId -Password $DbPwd
是否可以在创建新的分片映射管理器时调用 Get-ShardMapManager
而不涉及用户名和密码(通过硬编码或将值存储在密钥库中)
这是我目前在 powershell 中的代码
$ShardMapManager = Get-ShardMapManager -Username $DbUsrId -Password $DbPwd
我可以使用令牌或类似的东西吗?只是不涉及用户名和密码的任何内容?谢谢
不,你不能。从Get-ShardMapManager
的source code开始,UserName
和Password
都是Mandatory=$true
。
在这种情况下,如果您只是因为安全问题而想避免使用它们,您可以使用 azure keyvault 通过 Set-AzKeyVaultSecret
as you mentioned. Retrieve them in the commands, then pass them to Get-ShardMapManager
, just user/service principal that added to the access policy of the keyvault is able to get them(or has the Key Vault Administrator
if you select Azure role-based access control
in Access policies
blade 来存储它们密钥库)。
确保你已经安装了Az
powershell模块,然后使用下面的命令。
Connect-AzAccount
$DbUsrId = Get-AzKeyVaultSecret -VaultName "keyvaultname" -Name "username" -AsPlainText
$DbPwd = Get-AzKeyVaultSecret -VaultName "keyvaultname" -Name "password" -AsPlainText
$ShardMapManager = Get-ShardMapManager -Username $DbUsrId -Password $DbPwd