code: def applicationinsights_mgmt_plane_client(cli_ctx, _, subscription=None):
      
      from .vendored_sdks.mgmt_applicationinsights import ApplicationInsightsManagementClient
      from azure.cli.core._profile import Profile
      profile = Profile(cli_ctx=cli_ctx)
      # Use subscription from resource_id where possible, otherwise use login.
      if subscription:
          cred, _, _ = profile.get_login_credentials(subscription_id=subscription)
          return ApplicationInsightsManagementClient(
              cred,
              subscription
          )
      cred, sub_id, _ = profile.get_login_credentials()
      return ApplicationInsightsManagementClient(
          cred,
          sub_id
      )
docs: Initialize Log Analytics mgmt client for use with CLI.