I have many B2B and B2C Azure Active Directory instances. How do I assign one to KeyVault?

删除回忆录丶 提交于 2019-12-25 07:34:50

问题


I used the following powershell commands to create an Azure Key Vault:

//https://docs.microsoft.com/en-us/azure/key-vault/key-vault-get-started

Login-AzureRmAccount –Environment (Get-AzureRmEnvironment –Name AzureCloud)
set-azureRMContext -SubscriptionId ( Get-AzureRmSubscription -SubscriptionName "Visual Studio Enterprise").SubscriptionId

// Register-AzureRmResourceProvider -ProviderNamespace "Microsoft.KeyVault" (if error occurs in subscription)
New-AzureRmResourceGroup –Name "VaVaultRG" –Location 'SouthCentralUS' 

New-AzureRmKeyVault -VaultName "VaVault" -ResourceGroupName "VaVaultRG" -Location 'SouthCentralUS' 

The instructions here tell me how to link a web application to KeyVault. This leverages (both? ... either??) Azure AD B2C / B2B

  • How can I make my associate my KeyVault with a specific directory?

回答1:


A Key Vault is associated with the Azure AD associated in the subscription where it was created by default. If you want to switch the Azure AD tenant, you can find guidelines here: https://docs.microsoft.com/en-us/azure/key-vault/key-vault-subscription-move-fix

The example PowerShell script there:

$vaultResourceId = (Get-AzureRmKeyVault -VaultName myvault).ResourceId
$vault = Get-AzureRmResource –ResourceId $vaultResourceId -ExpandProperties
$vault.Properties.TenantId = (Get-AzureRmContext).Tenant.TenantId
$vault.Properties.AccessPolicies = @()
Set-AzureRmResource -ResourceId $vaultResourceId -Properties $vault.Properties

Here the TenantId is switched to the one which is currently active. (Get-AzureRmContext).Tenant.TenantId returns the GUID for the tenant.



来源:https://stackoverflow.com/questions/41451771/i-have-many-b2b-and-b2c-azure-active-directory-instances-how-do-i-assign-one-to

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!