Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Azure Keyvault CLI error: The subscription is not registered to use namespace 'Microsoft.KeyVault'

I get the error below when creating a new KeyVault

The subscription is not registered to use namespace 'Microsoft.KeyVault'

For all other products, the solution is to deploy a similar resource in the same region/account using the GUI, however KeyVault isn't available in the portal yet. (classic or preview)

I followed the instructions to create a KeyVault are here. I just happen to be on OSX if that matters, but NPM works on all platforms.

Chris$ sudo npm install azure-cli -g
Chris$ echo '. <(azure --completion)' >> .zshrc
Chris$ echo 'source ~/azure.completion.sh' >> ~/.bash_profile


Chris$ azure login -u [email protected]
Chris$ azure telemetry --enable
Chris$ azure config mode arm
Chris$ azure location list
Chris$ azure group create 'agent77keysRM' 'centralus'
Chris$ azure account list
Chris$ azure account set "AccountDisplayName"


Chris$ azure keyvault create --vault-name "agent77keys" --resource-group 'agent77keysRM' --location 'centralus'
info:    Executing command keyvault create
+ Checking pre-condition                                                       
+ Creating vault agent77keys                                                    
error:   The subscription is not registered to use namespace 'Microsoft.KeyVault'.
error:   Error information has been recorded to /Users/Chris/.azure/azure.err
error:   keyvault create command failed

I'm not dumping the azure.err here, for privacy reasons, but the key info is:

   'x-ms-client-request-id': 'b9991d6f-bd8c-4e62-b887-cac9b90d0281',
    'accept-language': 'en-US',
    'Content-Type': 'application/json; charset=utf-8',
    'user-agent': 'WindowsAzureXplatCLI/0.10.2' 
    ...
    'x-ms-failure-cause': 'gateway',
    'x-ms-request-id': 'fcb04d40-306f-40bd-b8df-f1b42b283010',
    'x-ms-correlation-request-id': 'fcb04d40-306f-40bd-b8df-f1b42b283010',
    'x-ms-routing-request-id': 'EASTUS:20160806T013209Z:fcb04d40-306f-40bd-b8df-f1b42b283010',

Looks like registering fixed it, here is the output if someone wants to see that it tells you HSM keys aren't created... easy fix, just add the SKU

info:    Executing command keyvault create
+ Checking pre-condition                                                       
+ Creating vault xxxxx                                                    
info:    Created vault xxxxx
data:    id "/subscriptions/xxxx/resourceGroups/xxxx/providers/Microsoft.KeyVault/vaults/xxxxxxs"
data:    name "xxxx"
data:    type "Microsoft.KeyVault/vaults"
data:    location "centralus"
data:    properties sku family "A"
data:    properties sku name "Standard"
data:    properties tenantId "xxxx"
data:    properties accessPolicies 0 tenantId "xxxx
data:    properties accessPolicies 0 objectId "xxxx
data:    properties accessPolicies 0 permissions keys 0 "get"
data:    properties accessPolicies 0 permissions keys 1 "create"
data:    properties accessPolicies 0 permissions keys 2 "delete"
data:    properties accessPolicies 0 permissions keys 3 "list"
data:    properties accessPolicies 0 permissions keys 4 "update"
data:    properties accessPolicies 0 permissions keys 5 "import"
data:    properties accessPolicies 0 permissions keys 6 "backup"
data:    properties accessPolicies 0 permissions keys 7 "restore"
data:    properties accessPolicies 0 permissions secrets 0 "all"
data:    properties enabledForDeployment false
data:    properties vaultUri "https://xxxxx.vault.azure.net"
warn:    This vault does not support HSM-protected keys. Please refer to http://go.microsoft.com/fwlink/?linkid=512521 for the vault service tiers.
warn:    When creating a vault, specify the --sku parameter to select a service tier that supports HSM-protected keys.
info:    keyvault create command OK
like image 733
makerofthings7 Avatar asked Aug 06 '16 01:08

makerofthings7


1 Answers

Please see this thread as to why you're getting this error: The subscription is not registered to use namespace 'Microsoft.DataFactory error.

To fix this issue, you would need to register your subscription with Microsoft.KeyVault resource provider. You can do the same by using the following command:

azure provider register --namespace "Microsoft.KeyVault"

With Azure Resource Manager

Register-AzureRmResourceProvider -ProviderNamespace 'Microsoft.KeyVault'
like image 104
Gaurav Mantri Avatar answered Oct 16 '22 17:10

Gaurav Mantri