Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/application-insights/HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

Release History
===============
1.2.3
++++++++++++++++++
* `az monitor app-insights events/metrics/query`: Fix error: Profile.get_login_credentials() got an unexpected keyword argument 'resource'

1.2.2
++++++++++++++++++
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,37 @@
# Licensed under the MIT License. See License.txt in the project root for license information.
# --------------------------------------------------------------------------------------------

class _Track1Credential: # pylint: disable=too-few-public-methods

def __init__(self, credential, resource):
"""Track 1 credential that can be fed into Track 1 SDK clients. Exposes signed_session protocol.
:param credential: Track 2 credential that exposes get_token protocol
:param resource: AAD resource
"""
self._credential = credential
self._resource = resource

def signed_session(self, session=None):
import requests
from azure.cli.core.auth.util import resource_to_scopes
session = session or requests.Session()
token = self._credential.get_token(*resource_to_scopes(self._resource))
header = "{} {}".format('Bearer', token.token)
session.headers['Authorization'] = header
return session


def applicationinsights_data_plane_client(cli_ctx, _, subscription=None):
"""Initialize Log Analytics data client for use with CLI."""
from .vendored_sdks.applicationinsights import ApplicationInsightsDataClient
from azure.cli.core._profile import Profile
profile = Profile(cli_ctx=cli_ctx)
cred, _, _ = profile.get_login_credentials(
resource=cli_ctx.cloud.endpoints.app_insights_resource_id,
subscription_id=subscription
)
# Note: temporarily adapt track2 auth to track1 by the guidance:
# https://github.com/Azure/azure-cli/pull/29631#issuecomment-2716799520
# need to be removed after migrated by codegen
cred, _, _ = profile.get_login_credentials(subscription_id=subscription)
return ApplicationInsightsDataClient(
cred,
_Track1Credential(cred, cli_ctx.cloud.endpoints.app_insights_resource_id),
base_url=f'{cli_ctx.cloud.endpoints.app_insights_resource_id}/v1'
)

Expand Down

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
# --------------------------------------------------------------------------------------------

# pylint: disable=line-too-long
import unittest
from azure.cli.testsdk import ResourceGroupPreparer, ScenarioTest, StorageAccountPreparer
from .recording_processors import StorageAccountSASReplacer
from azure.cli.testsdk.scenario_tests import AllowLargeResponse
Expand Down Expand Up @@ -349,6 +350,7 @@ def test_component_with_linked_storage(self, resource_group, location, storage_a
with self.assertRaisesRegex(ResourceNotFoundError, "Operation returned an invalid status 'Not Found'"):
self.cmd('monitor app-insights component linked-storage show --app {name_a} -g {resource_group}')

@unittest.skip("The operation 'action' on resource type 'components' is disallowed for cmd 'monitor app-insights component continues-export create'.")
@AllowLargeResponse()
@ResourceGroupPreparer(parameter_name_for_location='location')
@StorageAccountPreparer(kind='StorageV2')
Expand Down
2 changes: 1 addition & 1 deletion src/application-insights/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from codecs import open
from setuptools import setup, find_packages

VERSION = "1.2.2"
VERSION = "1.2.3"

CLASSIFIERS = [
'Development Status :: 4 - Beta',
Expand Down
Loading