azure-cli icon indicating copy to clipboard operation
azure-cli copied to clipboard

`az vm format-secret` does not work

Open chiyao-ms opened this issue 8 years ago • 5 comments


Environment summary

Install Method (e.g. pip, interactive script, apt-get, Docker, MSI, edge build) : MSI

CLI version (az --version) chi@Azure:~$ az --version azure-cli (2.0.27)

OS version : Windows 10 Shell Type (e.g. bash, cmd.exe, Bash on Windows) : bash on windows

I am following these steps to try to build a LINUX VM with SSL certificate.

https://docs.microsoft.com/en-us/azure/virtual-machines/linux/tutorial-secure-web-server

But I am failing at following step.

$ secret=$(az keyvault secret list-versions --vault-name WebSvrCert --name WebCert --query "[?attributes.enabled].id" --output tsv)

$ echo $secret
https://websvrcert.vault.azure.net/secrets/WebCert/d79e98486c5f42a6a12c863608b3a6e8

$ vm_secret=$(az vm secret format --secret "$secret")
Parameter 'resource_group_name' can not be None.
Traceback (most recent call last):
File "/opt/az/lib/python3.6/site-packages/knack/cli.py", line 194, in invoke
cmd_result = self.invocation.execute(args)
File "/opt/az/lib/python3.6/site-packages/azure/cli/core/commands/init.py", line 331, in execute
six.reraise(*sys.exc_info())
File "/opt/az/lib/python3.6/site-packages/six.py", line 693, in reraise
raise value
File "/opt/az/lib/python3.6/site-packages/azure/cli/core/commands/init.py", line 304, in execute
result = cmd(params)
File "/opt/az/lib/python3.6/site-packages/azure/cli/core/commands/init.py", line 168, in call
return super(AzCliCommand, self).call(*args, **kwargs)
File "/opt/az/lib/python3.6/site-packages/knack/commands.py", line 109, in call
return self.handler(*args, **kwargs)
File "/opt/az/lib/python3.6/site-packages/azure/cli/core/init.py", line 348, in default_command_handler
result = op(**command_args)
File "/opt/az/lib/python3.6/site-packages/azure/cli/command_modules/vm/custom.py", line 1429, in get_vm_format_secret
'id': _get_vault_id_from_name(cmd.cli_ctx, client, vault_name)
File "/opt/az/lib/python3.6/site-packages/azure/cli/command_modules/vm/custom.py", line 1406, in _get_vault_id_from_name
vault = client.get(group_name, vault_name)
File "/opt/az/lib/python3.6/site-packages/azure/mgmt/keyvault/operations/vaults_operations.py", line 193, in get
'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'),
File "/opt/az/lib/python3.6/site-packages/msrest/serialization.py", line 488, in url
data = self.validate(data, name, required=True, **kwargs)
File "/opt/az/lib/python3.6/site-packages/msrest/serialization.py", line 558, in validate
raise ValidationError("required", name, True)
msrest.exceptions.ValidationError: Parameter 'resource_group_name' can not be None.
chi@Azure:~/clouddrive$

chiyao-ms avatar Mar 02 '18 04:03 chiyao-ms

My suspicion is that the keyvault is not visible to the subscription you are logged into. Regardless, it should not throw up a stack trace.

tjprescott avatar Mar 02 '18 16:03 tjprescott

Thank you for the advice,

But I am creating the key vault and run this command against the same subscription…

Do you have any other suggestions?

Thank you. -chiyao-

From: Travis Prescott [email protected] Sent: Saturday, March 3, 2018 1:46 AM To: Azure/azure-cli [email protected] Cc: Chi Yao [email protected]; Author [email protected] Subject: Re: [Azure/azure-cli] az vm format-secret does not work (#5718)

My suspicion is that the keyvault is not visible to the subscription you are logged into. Regardless, it should not throw up a stack trace.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHubhttps://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2FAzure%2Fazure-cli%2Fissues%2F5718%23issuecomment-369978598&data=04%7C01%7Cchiyao%40microsoft.com%7C233eeca4833a49dd630808d5805d0dfe%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C636556059511671323%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwifQ%3D%3D%7C-1&sdata=LlHcbQXoipvBgAq3lzeKh1t5ouCnIgffWZ5KQfc4Jzs%3D&reserved=0, or mute the threadhttps://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FAa5ywcAZ_nw6in-XO0SNXj7uqUgKcJqSks5taXc7gaJpZM4SZZO0&data=04%7C01%7Cchiyao%40microsoft.com%7C233eeca4833a49dd630808d5805d0dfe%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C636556059511671323%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwifQ%3D%3D%7C-1&sdata=Ly4fA%2F7hshI3uJfxDoS4LkIpmjV%2BZqvGtt6kbdwaMwo%3D&reserved=0.

chiyao-ms avatar Mar 13 '18 12:03 chiyao-ms

I get the same stack trace using your secret ID, but that's because the vault isn't in a subscription I can access. I'll take a look.

tjprescott avatar Mar 13 '18 16:03 tjprescott

It's scheduled to be addressed next sprint.

tjprescott avatar Mar 20 '18 16:03 tjprescott