247 check ext env - #248
Conversation
There was a problem hiding this comment.
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.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
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)
giomrella
left a comment
There was a problem hiding this comment.
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)
captures the Azure error info if there is problem getting subscriptions.