Skip to content

Commit

Permalink
Use new entra_group_exists check and raise error if not found
Browse files Browse the repository at this point in the history
  • Loading branch information
craddm committed Sep 25, 2024
1 parent 3fa7058 commit a7809bf
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions data_safe_haven/config/shm_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,13 @@ def from_args(
) -> SHMConfig:
"""Construct an SHMConfig from arguments."""
azure_sdk = AzureSdk(subscription_name=context.subscription_name)
try:
if azure_sdk.entra_directory.entra_group_exists(context.admin_group_name):
admin_group_id = azure_sdk.entra_directory.get_id_from_groupname(
context.admin_group_name
)
except DataSafeHavenMicrosoftGraphError as exc:
msg = f"Failed to get ID for group '{context.admin_group_name}'"
raise DataSafeHavenMicrosoftGraphError(msg) from exc

else:
msg = f"Admin group '{context.admin_group_name}' not found. Check the group name."
raise DataSafeHavenMicrosoftGraphError(msg)
return SHMConfig.model_construct(
azure=ConfigSectionAzure.model_construct(
location=location,
Expand Down

0 comments on commit a7809bf

Please sign in to comment.