Skip to content

az keyvault set-policy: passing a variable to --object-id fails. #11950

@ghstahl

Description

@ghstahl

This is autogenerated. Please review and update as needed.

Describe the bug

Command Name
az keyvault set-policy

Errors:

An invalid value was provided for 'accessPolicies'.

To Reproduce:

Steps to reproduce the behavior. Note that argument values have been redacted, as they may contain sensitive information.

AZ_FUNC_NAME="azfun-oauth2"
APP_FRIENDLY_NAME="organics"
LOCATION="eastus2"
RESOURCE_GROUP_NAME="rg-$APP_FRIENDLY_NAME-openhack"
KEYVAULT_NAME="kv-$APP_FRIENDLY_NAME"



az webapp identity assign \
    --name $AZ_FUNC_NAME  \
    --resource-group $RESOURCE_GROUP_NAME
PRINCIPAL_ID=$(az webapp show -n $AZ_FUNC_NAME -g $RESOURCE_GROUP_NAME --query 'identity.principalId' -o json)
echo "KEYVAULT_NAME:$KEYVAULT_NAME"
echo "principalId:$PRINCIPAL_ID"



az keyvault set-policy \
    --name $KEYVAULT_NAME \
    --object-id $PRINCIPAL_ID \
    --secret-permissions get list \
    --key-permissions get list sign verify create \
    --certificate-permissions get list getissuers listissuers

The Problem

--object-id $PRINCIPAL_ID \

This Works

--object-id "02c27055-efb4-4b9d-bd5d-acd671ea5a10" \

I query for the identity.principalId and assign it to PRINCIPAL_ID.
Passing $PRINCIPAL_ID as the argument to --object-id FAILS.
Hardcoding it works.

Expected Behavior

Passing $PRINCIPAL_ID as the argument to --object-id SHOULD SUCCEED.

Environment Summary

Linux-4.4.0-18362-Microsoft-x86_64-with-debian-buster-sid
Python 3.6.5
Shell: bash

azure-cli 2.0.78 *

Extensions:
azure-devops 0.16.0

Additional Context

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions