Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[AKS] az aks create/update: Support UserAssigned Managed Identity for grafana linking in managed prometheus #7886

Merged
merged 4 commits into from
Aug 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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":
yanzhudd marked this conversation as resolved.
Show resolved Hide resolved
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
Loading