Skip to content

Commit

Permalink
Fix the bug that automatically generated name of policy assignment ex…
Browse files Browse the repository at this point in the history
…ceeds the limit (#12352)
  • Loading branch information
zhoxing-ms committed Mar 5, 2020
1 parent b91666c commit 8a93edf
Show file tree
Hide file tree
Showing 3 changed files with 7,444 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/azure-cli/azure/cli/command_modules/resource/custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import ssl
import sys
import uuid
import base64

from six.moves.urllib.request import urlopen # pylint: disable=import-error
from six.moves.urllib.parse import urlparse # pylint: disable=import-error
Expand Down Expand Up @@ -1668,7 +1669,10 @@ def create_policy_assignment(cmd, policy=None, policy_set_definition=None,
identity = _build_identities_info(cmd, assign_identity)
assignment.identity = identity

createdAssignment = policy_client.policy_assignments.create(scope, name or uuid.uuid4(), assignment)
if name is None:
name = (base64.urlsafe_b64encode(uuid.uuid4().bytes).decode())[:-2]

createdAssignment = policy_client.policy_assignments.create(scope, name, assignment)

# Create the identity's role assignment if requested
if assign_identity is not None and identity_scope:
Expand Down
Loading

0 comments on commit 8a93edf

Please sign in to comment.