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

Inject environment variables for subprocess #38452

Open
morganics opened this issue Nov 11, 2024 · 1 comment
Open

Inject environment variables for subprocess #38452

morganics opened this issue Nov 11, 2024 · 1 comment
Assignees
Labels
customer-reported Issues that are reported by GitHub users external to the Azure organization. needs-team-attention Workflow: This issue needs attention from Azure service team or SDK team question The issue doesn't require a change to the product in order to be resolved. Most issues start as that

Comments

@morganics
Copy link

morganics commented Nov 11, 2024

Is your feature request related to a problem? Please describe.

Using os.environ can cause issues in azure_cli.py, e.g. cannot find the az command even when az is on the path.

Describe the solution you'd like
Inject os environment variables in to the identity module, so that we're not dependent on the global os.environ variables.

e.g. line 223 on azure_cli.py

        working_directory = get_safe_working_dir()

        kwargs: Dict[str, Any] = {
            "stderr": subprocess.PIPE,
            "stdin": subprocess.DEVNULL,
            "cwd": working_directory,
            "universal_newlines": True,
            "timeout": timeout,
            "env": dict(self._environ, AZURE_CORE_NO_COLOR="true"), # rather than using os.environ.
        }
        return subprocess.check_output(args, **kwargs)

Describe alternatives you've considered
Patching os.environ, which isn't great.

Additional context
Messy PATHs can stop the az command being found, despite shutil locating the appropriate path.

@github-actions github-actions bot added customer-reported Issues that are reported by GitHub users external to the Azure organization. needs-triage Workflow: This is a new issue that needs to be triaged to the appropriate team. question The issue doesn't require a change to the product in order to be resolved. Most issues start as that labels Nov 11, 2024
@xiangyan99 xiangyan99 removed the needs-triage Workflow: This is a new issue that needs to be triaged to the appropriate team. label Nov 11, 2024
@github-actions github-actions bot added the needs-team-attention Workflow: This issue needs attention from Azure service team or SDK team label Nov 11, 2024
@xiangyan99
Copy link
Member

Thanks for the feedback, we’ll investigate asap.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
customer-reported Issues that are reported by GitHub users external to the Azure organization. needs-team-attention Workflow: This issue needs attention from Azure service team or SDK team question The issue doesn't require a change to the product in order to be resolved. Most issues start as that
Projects
None yet
Development

No branches or pull requests

3 participants