-
Notifications
You must be signed in to change notification settings - Fork 3.1k
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
{Compute} Set audience
when creating LogsQueryClient
#30787
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -130,10 +130,10 @@ def cf_log_analytics_data_plane(cli_ctx, _): | |
from azure.monitor.query import LogsQueryClient | ||
from azure.cli.core._profile import Profile | ||
profile = Profile(cli_ctx=cli_ctx) | ||
cred, _, _ = profile.get_login_credentials( | ||
resource=cli_ctx.cloud.endpoints.log_analytics_resource_id) | ||
cred, _, _ = profile.get_login_credentials() | ||
api_version = 'v1' | ||
return LogsQueryClient(cred, endpoint=cli_ctx.cloud.endpoints.log_analytics_resource_id + '/' + api_version) | ||
return LogsQueryClient(cred, endpoint=cli_ctx.cloud.endpoints.log_analytics_resource_id + '/' + api_version, | ||
audience=cli_ctx.cloud.endpoints.log_analytics_resource_id) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The naming of Also, according to def get_authentication_policy(credential: TokenCredential, audience: str) -> BearerTokenCredentialPolicy:
"""Returns the correct authentication policy"""
if credential is None:
raise ValueError("Parameter 'credential' must not be None.")
scope = audience.rstrip("/") + "/.default" the value of There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. When def __init__(self, credential: TokenCredential, **kwargs: Any) -> None:
endpoint = kwargs.pop("endpoint", "https://api.loganalytics.io/v1")
if not endpoint.startswith("https://") and not endpoint.startswith("http://"):
endpoint = "https://" + endpoint
parsed_endpoint = urlparse(endpoint)
audience = kwargs.pop("audience", f"{parsed_endpoint.scheme}://{parsed_endpoint.netloc}")
self._endpoint = endpoint
auth_policy = kwargs.pop("authentication_policy", None)
self._client = MonitorQueryClient(
credential=credential,
authentication_policy=auth_policy or get_authentication_policy(credential, audience), So passing There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Shall we still add There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Setting For example, for Dogfood cloud, ARM's resource ID is |
||
|
||
|
||
def cf_disk_encryption_set(cli_ctx, _): | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I currently lack some domain knowledge about Auth, may I ask why the resource attribute need to be removed for
profile.get_login_credentials
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a very good question. I wrote a detailed explanation at #29631 (comment).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great! thanks for the detailed explanation