Skip to content

Commit

Permalink
[AKS] az aks create/update: Support UserAssigned Managed Identity f…
Browse files Browse the repository at this point in the history
…or grafana linking in managed prometheus (#7886)
  • Loading branch information
bragi92 authored Aug 23, 2024
1 parent cc1bdd0 commit 820478f
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 2 deletions.
4 changes: 4 additions & 0 deletions src/aks-preview/HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ If there is no rush to release a new version, please just add a description of t

To release a new version, please select a new version number (usually plus 1 to last patch version, X.Y.Z -> Major.Minor.Patch, more details in `\doc <https://semver.org/>`_), and then add a new section named as the new version number in this file, the content should include the new modifications and everything from the *Pending* section. Finally, update the `VERSION` variable in `setup.py` with this new version number.

7.0.0b7
+++++++
* [AKS] `az aks create/update`: Support UserAssigned Managed Identity for grafana linking in managed prometheus

7.0.0b6
+++++++
* Add `--advanced-networking-observability-tls-management` to `az aks create/update` command.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,22 @@ def link_grafana_instance(cmd, raw_parameters, azure_monitor_workspace_resource_
grafanaURI = f"{cmd.cli_ctx.cloud.endpoints.resource_manager}{grafana_resource_id}?api-version={GRAFANA_API}"
headers = ['User-Agent=azuremonitormetrics.link_grafana_instance']
grafanaArmResponse = send_raw_request(cmd.cli_ctx, "GET", grafanaURI, body={}, headers=headers)
servicePrincipalId = grafanaArmResponse.json()["identity"]["principalId"]
# Check if 'identity' and 'type' exist in the response
identity_info = grafanaArmResponse.json().get("identity", {})
identity_type = identity_info.get("type", "").lower()

if identity_type == "systemassigned":
servicePrincipalId = identity_info.get("principalId")
elif identity_type == "userassigned":
user_assigned_identities = identity_info.get("userAssignedIdentities", {})
if not user_assigned_identities:
raise CLIError("No user-assigned identities found.")
servicePrincipalId = list(user_assigned_identities.values())[0]["principalId"]
else:
raise CLIError("Unsupported or missing identity type.")

if not servicePrincipalId:
raise CLIError("No service principal ID found for the specified identity.")
except CLIError as e:
raise CLIError(e) # pylint: disable=raise-missing-from
# Add Role Assignment
Expand Down
2 changes: 1 addition & 1 deletion src/aks-preview/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

from setuptools import setup, find_packages

VERSION = "7.0.0b6"
VERSION = "7.0.0b7"

CLASSIFIERS = [
"Development Status :: 4 - Beta",
Expand Down

0 comments on commit 820478f

Please sign in to comment.