Skip to content

247 check ext env - #248

Merged
ryanraaschCDC merged 8 commits into
mainfrom
247-check_ext_env
Aug 5, 2026
Merged

247 check ext env#248
ryanraaschCDC merged 8 commits into
mainfrom
247-check_ext_env

Conversation

@ryanraaschCDC

@ryanraaschCDC ryanraaschCDC commented Aug 4, 2026

Copy link
Copy Markdown
Collaborator

captures the Azure error info if there is problem getting subscriptions.

@ryanraaschCDC
ryanraaschCDC requested a lite review from Copilot August 4, 2026 19:59
@ryanraaschCDC ryanraaschCDC linked an issue Aug 4, 2026 that may be closed by this pull request

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR enhances Azure subscription/environment detection diagnostics in cfa.cloudops.util by surfacing exception details during subscription listing and adding debug logging around subscription retrieval for check_ext_env().

Changes:

  • Capture and print the caught exception in get_subscriptions() when subscription lookup fails.
  • Add debug logging of retrieved subscriptions in check_ext_env() before checking for the EXT environment marker.
Suppressed comments (1)

cfa/cloudops/util.py:308

  • This uses the root logger (logging.debug) and logs the full subscription name list, which may be sensitive and can be very noisy. Prefer the module logger and log only a count (or a small/redacted sample) at debug level.
    subs = get_subscriptions()
    logging.debug(f"Retrieved subscriptions: {subs}")
    return any("EXT-EDAV-CFA" in i for i in subs)

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread cfa/cloudops/util.py Outdated
ryanraaschCDC and others added 4 commits August 4, 2026 20:09
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.

Suppressed comments (1)

cfa/cloudops/util.py:307

  • Avoid eager f-string formatting and emitting full subscription names in logs. Even at DEBUG, logging the entire subscription list can be noisy and may expose environment/account details; parameterized logging also avoids unnecessary string building when DEBUG is disabled.
    subs = get_subscriptions()
    logger.debug(f"Retrieved subscriptions: {subs}")
    return any("EXT-EDAV-CFA" in i for i in subs)

Comment thread cfa/cloudops/helpers.py
@ryanraaschCDC
ryanraaschCDC marked this pull request as ready for review August 4, 2026 22:01
@ryanraaschCDC
ryanraaschCDC requested a review from giomrella August 4, 2026 22:01

@giomrella giomrella left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I checked out this branch locally and successfully ran check_ext_env() without errors. Then I ran az account clear on a machine without an identity and reran and confirmed the stack trace shows the underlying azure error as a warning:

>>> from cfa.cloudops.util import check_ext_env
>>> check_ext_env()
True
>>> check_ext_env()
[WARNING] 2026-08-05_10:20:21-0400: DefaultAzureCredential failed to retrieve a token from the included credentials.
Attempted credentials:
	EnvironmentCredential: EnvironmentCredential authentication unavailable. Environment variables are not fully configured.
Visit https://aka.ms/azsdk/python/identity/environmentcredential/troubleshoot to troubleshoot this issue.
	WorkloadIdentityCredential: WorkloadIdentityCredential authentication unavailable. The workload options are not fully configured. See the troubleshooting guide for more information: https://aka.ms/azsdk/python/identity/workloadidentitycredential/troubleshoot. Missing required arguments: 'tenant_id', 'c       lient_id', 'token_file_path'.
	ManagedIdentityCredential: ManagedIdentityCredential authentication unavailable, no response from the IMDS endpoint.
	SharedTokenCacheCredential: SharedTokenCacheCredential authentication unavailable. No accounts were found in the cache.
	VisualStudioCodeCredential: VisualStudioCodeCredential requires the 'azure-identity-broker' package to be installed. You must also ensure you have the Azure Resources extension installed and have signed in to Azure via Visual Studio Code.
	AzureCliCredential: Please run 'az login' to set up an account
	AzurePowerShellCredential: PowerShell is not installed
	AzureDeveloperCliCredential: Azure Developer CLI could not be found. Please visit https://aka.ms/azure-dev for installation instructions and then,once installed, authenticate to your Azure account using 'azd auth login'.
	BrokerCredential: InteractiveBrowserBrokerCredential unavailable. The 'azure-identity-broker' package is required to use brokered authentication.
To mitigate this issue, please refer to the troubleshooting guidelines here at https://aka.ms/azsdk/python/identity/defaultazurecredential/troubleshoot.
[WARNING] 2026-08-05_10:20:21-0400: Could not list Azure subscriptions.
Traceback (most recent call last):
  File "/home/gio/Documents/CDC/cfa-cloudops/cfa/cloudops/util.py", line 298, in get_subscriptions
    return [sub.display_name for sub in subscriptions]
                                        ^^^^^^^^^^^^^
  File "/home/gio/Documents/CDC/cfa-cloudops/.venv/lib/python3.14/site-packages/azure/core/paging.py", line 136, in __next__
    return next(self._page_iterator)
  File "/home/gio/Documents/CDC/cfa-cloudops/.venv/lib/python3.14/site-packages/azure/core/paging.py", line 82, in __next__
    self._response = self._get_next(self.continuation_token)

@ryanraaschCDC
ryanraaschCDC merged commit ed0cae3 into main Aug 5, 2026
2 checks passed
@ryanraaschCDC
ryanraaschCDC deleted the 247-check_ext_env branch August 5, 2026 15:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix check_ext_env

4 participants