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

added telemetry code for connect cli #4

Merged
merged 85 commits into from
May 18, 2020
Merged
Show file tree
Hide file tree
Changes from 64 commits
Commits
Show all changes
85 commits
Select commit Hold shift + click to select a range
581cb60
[Breadth Coverage] Onboard Import Export (#1515)
arrownj Apr 22, 2020
54e0ed2
[Monitor]App byos and link la (#1499)
mmyyrroonn Apr 22, 2020
850f6aa
[Release] Update index.json for extension [ application-insights ] (#…
Apr 22, 2020
56a867c
[Release] Update index.json for extension [ support ] (#1569)
Apr 22, 2020
e99c137
[Release] Update index.json for extension [ import-export ] (#1574)
Apr 23, 2020
5b84f75
[HanaOnAzure] Updated HanaOnAzure CLI extension to include SapMonitor…
PakDLiu Apr 23, 2020
8877ae4
[Import Export] add __init__.py for generated package (#1582)
arrownj Apr 23, 2020
81d264d
[Release] Update index.json for extension [ import-export ] (#1583)
Apr 23, 2020
3d97c71
downgrade the version since the service is not ready (#1580)
mmyyrroonn Apr 23, 2020
3360eca
[Breadth Coverage] Datashare (#1476)
fengzhou-msft Apr 23, 2020
73dfe9e
[Release] Update index.json for extension [ datashare ] (#1586)
Apr 23, 2020
5cfc900
[Breadth Coverage] Portal (#1428)
YalinLi0312 Apr 23, 2020
85c8cbf
Change portal README file from rst to markdown (#1589)
YalinLi0312 Apr 23, 2020
4c707a0
[Breadth Coverage] logic apps (#1423)
bquantump Apr 24, 2020
5e3d07c
[Release] Update index.json for extension [ image-copy ] (#1568)
Apr 24, 2020
69c7333
Fix a small error in commands.py and update test sample file (#1595)
YalinLi0312 Apr 25, 2020
12e0bd9
[Release] Update index.json for extension [ portal ] (#1599)
Apr 25, 2020
246ec8e
[Release] Update index.json for extension [ logic ] (#1594)
Apr 25, 2020
f40506c
Fixed bug when hyperV version variable is None (#1553)
swbae31 Apr 26, 2020
285a0b5
[Release] Update index.json for extension [ vm-repair ] (#1601)
Apr 27, 2020
d597d8e
[Portal] Add portal generated module init file (#1609)
YalinLi0312 Apr 27, 2020
9528c6a
[Release] Update index.json for extension [ portal ] (#1610)
Apr 27, 2020
35b244f
{Monitor} refactor the logic (#1596)
mmyyrroonn Apr 27, 2020
3ede273
Update azure-cli-ml version to 1.4.0 (#1615)
j-so Apr 27, 2020
2fc19bd
[Release] Update index.json for extension [ application-insights ] (#…
Apr 28, 2020
14799ae
[Breadth Coverage] Log Analytics Solution (#1545)
zhoxing-ms Apr 29, 2020
e6c21fd
[Release] Update index.json for extension [ log-analytics-solution ] …
Apr 29, 2020
6827793
[Breadth Coverage] Time Series Insights (#1539)
jiasli Apr 29, 2020
71449ed
[Release] Update index.json for extension [ timeseriesinsights ] (#1623)
Apr 29, 2020
0f9aa58
Revert "spring-cloud: add support to enable/disable MSI (#1523)" (#1622)
leonard520 Apr 30, 2020
51f8b5d
[CI] Add wheel preinstallation for job IndexRefDocVerify and fix azur…
Apr 30, 2020
1ce82b0
[CI] Remove wheel usage (#1628)
Apr 30, 2020
13404e3
[storage-ors-preview] Support ORS policy for storage account (#1461)
Juliehzl May 1, 2020
d6aad6c
Adding updated Kusto extension (#1605)
astauben May 1, 2020
78df589
[Release] Update index.json for extension [ kusto ] (#1633)
May 1, 2020
2d844dd
[AKS] fix incorrect usage of ARM without going through the multi-api …
marwanad May 4, 2020
f178285
cli extension for connected kubernetes RP (#1570)
akashkeshari May 5, 2020
1884169
[Release] Update index.json for extension [ aks-preview ] (#1637)
May 5, 2020
2fb2d14
[Release] Update index.json for extension [ storage-ors-preview ] (#1…
May 6, 2020
1eb927c
[AKS] Unblock agentpool min count range check (#1606)
marwanad May 6, 2020
880774b
Fix the persicope version to always point to latest tag. (#1630)
Tatsinnit May 6, 2020
0b1ac90
[IoT] CLI extension release v0.9.2 (#1542)
digimaun May 6, 2020
14ec628
[storage-ors-preview] fix no azext metadata (#1648)
May 6, 2020
5926f06
[Release] Update index.json for extension [ storage-ors-preview ] (#1…
May 6, 2020
3fa9b10
added telemetry code for connect cli
May 6, 2020
5cbe47c
update help context (#1634)
zqingqing1 May 7, 2020
e489082
WIP {KubernetesConfiguration} Add extension CLI (#1550)
NarayanThiru May 7, 2020
9d60981
[storage-or-policy] rename the extension (#1662)
Juliehzl May 8, 2020
fca378c
{CI} temporary disable CredScan since ADO bug (#1666)
May 8, 2020
3d46998
[Release] Update index.json for extension [ storage-or-preview ] (#1665)
May 8, 2020
cf586cc
spring cloud - custom domain - cli (#1419)
1openwindow May 8, 2020
b0872b7
[Release] Update index.json for extension [ spring-cloud ] (#1669)
May 8, 2020
9f022a0
[Release] Update index.json for extension [ k8sconfiguration ] (#1659)
May 8, 2020
df2ecf4
[Release] Update index.json for extension [ connectedk8s ] (#1644)
May 8, 2020
f928d72
Fix extension name in readme (#1672)
ilidemi May 8, 2020
bffd137
[Breadth Coverage] Onboard Custom Providers Commands (#1627)
jsntcy May 9, 2020
5db8ce5
[Release] Update index.json for extension [ custom-providers ] (#1674)
May 9, 2020
01d4407
[TimeSeriesInsights] Fix timeSeriesIdPropertyName is not parsed prope…
jiasli May 9, 2020
5cf8340
[Release] Update index.json for extension [ timeseriesinsights ] (#1676)
May 11, 2020
94df344
update azure-cli-ml version to 1.2.0 (#1682)
j-so May 12, 2020
5c56299
Added exception telemetry for delete operation
May 12, 2020
4ddea41
Updated fork master with latest master
May 12, 2020
47fc01b
Updated with latest master
May 12, 2020
9239f83
Updated setup.py
May 12, 2020
ccdbff0
Changed default kubernetes distro
May 12, 2020
e6333d7
Distro detect.
pasankav May 12, 2020
1ef6cdd
Updated history
May 13, 2020
c1612c2
removed arm resourceid from telemetry
May 13, 2020
db1f4bd
Kubernetes connect cli telemetry integration (#1684)
akashkeshari May 13, 2020
5ed8f5d
bump vmware to 0.6.0 (#1656)
cataggar May 13, 2020
9943139
download from az-csvmware-cli (#1681)
cataggar May 13, 2020
feb1883
[Release] Update index.json for extension [ connectedk8s ] (#1689)
May 14, 2020
fb40791
AKS: add aks-custom-headers for nodepool and update (#1686)
andyzhangx May 14, 2020
3ed99da
Merge branch 'akash/connect_telemetry' into pavan/distro_detect
pasankav May 14, 2020
8a92c0c
[Release] Update index.json for extension [ aks-preview ] (#1699)
May 14, 2020
8b26810
Add kubernetes distro and identifying it.
pasankav May 14, 2020
df6806d
K8s configuration update min cli core version (#1697)
NarayanThiru May 14, 2020
87cbfa1
Add "Did You Mean This" Extension (#1692)
christopher-o-toole May 15, 2020
6bb06a7
[Release] Update index.json for extension [ k8sconfiguration ] (#1700)
May 15, 2020
fdacc2b
Remove additional line.
pasankav May 15, 2020
3860c00
correct indentation.
pasankav May 15, 2020
b9b4915
Merge branch 'master' into pavan/distro_detect
pasankav May 15, 2020
f8c4e04
correct indentation.
pasankav May 15, 2020
b752e92
correct version number.
pasankav May 15, 2020
9404057
Merge pull request #5 from akashkeshari/pavan/distro_detect
akashkeshari May 18, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
20 changes: 20 additions & 0 deletions .github/CODEOWNERS
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,28 @@

/src/blueprint/ @fengzhou-msft

/src/storage-or-preview/ @Juliehzl

/src/logic/ @bquantump

/src/databox/ @jsntcy

/src/hpc-cache/ @qianwens

/src/timeseriesinsights/ @jiasli

/src/portal/ @YalinLi0312

/src/import-export/ @arrownj

/src/account/ @zikalino

/src/datashare/ @fengzhou-msft

/src/k8sconfiguration/ @NarayanThiru

/src/log-analytics-solution/ @zhoxing-ms

/src/kusto/ @ilayr @orhasban @astauben

/src/custom-providers/ @jsntcy
154 changes: 154 additions & 0 deletions azure-cli-extensions.pyproj

Large diffs are not rendered by default.

40 changes: 21 additions & 19 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,25 +13,25 @@ pr:
- '*'

jobs:
- job: CredScan
displayName: "Credential Scan"
pool:
vmImage: "windows-2019"
steps:
- task: ms-codeanalysis.vss-microsoft-security-code-analysis.build-task-credscan.CredScan@2
displayName: 'CredScan'
inputs:
toolVersion: 'Latest'
suppressionsFile: './scripts/ci/credscan/CredScanSuppressions.json'
- task: ms-codeanalysis.vss-microsoft-security-code-analysis.build-task-postanalysis.PostAnalysis@1
displayName: 'Post Analysis'
inputs:
AllTools: false
BinSkim: false
CredScan: true
RoslynAnalyzers: false
TSLint: false
ToolLogsNotFoundAction: 'Standard'
# - job: CredScan
# displayName: "Credential Scan"
# pool:
# vmImage: "windows-2019"
# steps:
# - task: ms-codeanalysis.vss-microsoft-security-code-analysis.build-task-credscan.CredScan@2
# displayName: 'CredScan'
# inputs:
# toolVersion: 'Latest'
# suppressionsFile: './scripts/ci/credscan/CredScanSuppressions.json'
# - task: ms-codeanalysis.vss-microsoft-security-code-analysis.build-task-postanalysis.PostAnalysis@1
# displayName: 'Post Analysis'
# inputs:
# AllTools: false
# BinSkim: false
# CredScan: true
# RoslynAnalyzers: false
# TSLint: false
# ToolLogsNotFoundAction: 'Standard'

- job: CheckLicenseHeader
displayName: "Check License"
Expand Down Expand Up @@ -162,6 +162,8 @@ jobs:
displayName: 'Use Python 3.7'
inputs:
versionSpec: 3.7
- bash: pip install wheel==0.30.0
displayName: 'Install wheel==0.30.0'
- task: Bash@3
displayName: "Verify Extension Ref Docs"
inputs:
Expand Down
9 changes: 8 additions & 1 deletion scripts/ci/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,21 @@
# --------------------------------------------------------------------------------------------

import os
import re
import json
import zipfile
from wheel.install import WHEEL_INFO_RE

# Dependencies that will not be checked.
# This is for packages starting with 'azure-' but do not use the 'azure' namespace.
SKIP_DEP_CHECK = ['azure-batch-extensions']

# copy from wheel==0.30.0
WHEEL_INFO_RE = re.compile(
r"""^(?P<namever>(?P<name>.+?)(-(?P<ver>\d.+?))?)
((-(?P<build>\d.*?))?-(?P<pyver>.+?)-(?P<abi>.+?)-(?P<plat>.+?)
\.whl|\.dist-info)$""",
re.VERBOSE).match


def get_repo_root():
current_dir = os.path.dirname(os.path.abspath(__file__))
Expand Down
4 changes: 4 additions & 0 deletions src/aks-preview/HISTORY.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

Release History
===============
0.4.43
+++++
* Fix issues with monitoring addon enabling with CLI versions 2.4.0+

0.4.43
+++++
* Add support for VMSS node public IP.
Expand Down
18 changes: 9 additions & 9 deletions src/aks-preview/azext_aks_preview/_help.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,10 +181,10 @@
long-summary: If specified, please make sure the kubernetes version is larger than 1.10.6.
- name: --min-count
type: int
short-summary: Minimun nodes count used for autoscaler, when "--enable-cluster-autoscaler" specified. Please specifying the value in the range of [1, 100].
short-summary: Minimun nodes count used for autoscaler, when "--enable-cluster-autoscaler" specified. Please specify the value in the range of [1, 100].
- name: --max-count
type: int
short-summary: Maximum nodes count used for autoscaler, when "--enable-cluster-autoscaler" specified. Please specifying the value in the range of [1, 100].
short-summary: Maximum nodes count used for autoscaler, when "--enable-cluster-autoscaler" specified. Please specify the value in the range of [1, 100].
- name: --cluster-autoscaler-profile
type: list
short-summary: Space-separated list of key=value pairs for configuring cluster autoscaler. Pass an empty string to clear the profile.
Expand All @@ -199,7 +199,7 @@
short-summary: The node resource group is the resource group where all customer's resources will be created in, such as virtual machines.
- name: --uptime-sla
type: bool
short-summary: Enable paid managed cluster service with high availability.
short-summary: Enable a paid managed cluster service with a financially backed SLA.
- name: --attach-acr
type: string
short-summary: Grant the 'acrpull' role assignment to the ACR specified by name or resource ID.
Expand Down Expand Up @@ -307,10 +307,10 @@
short-summary: Update min-count or max-count for cluster autoscaler.
- name: --min-count
type: int
short-summary: Minimun nodes count used for autoscaler, when "--enable-cluster-autoscaler" specified. Please specifying the value in the range of [1, 100]
short-summary: Minimun nodes count used for autoscaler, when "--enable-cluster-autoscaler" specified. Please specify the value in the range of [1, 100]
- name: --max-count
type: int
short-summary: Maximum nodes count used for autoscaler, when "--enable-cluster-autoscaler" specified. Please specifying the value in the range of [1, 100]
short-summary: Maximum nodes count used for autoscaler, when "--enable-cluster-autoscaler" specified. Please specify the value in the range of [1, 100]
- name: --cluster-autoscaler-profile
type: list
short-summary: Space-separated list of key=value pairs for configuring cluster autoscaler. Pass an empty string to clear the profile.
Expand Down Expand Up @@ -486,10 +486,10 @@
short-summary: Enable cluster autoscaler.
- name: --min-count
type: int
short-summary: Minimun nodes count used for autoscaler, when "--enable-cluster-autoscaler" specified. Please specifying the value in the range of [1, 100]
short-summary: Minimun nodes count used for autoscaler, when "--enable-cluster-autoscaler" specified. Please specify the value in the range of [1, 100]
- name: --max-count
type: int
short-summary: Maximum nodes count used for autoscaler, when "--enable-cluster-autoscaler" specified. Please specifying the value in the range of [1, 100]
short-summary: Maximum nodes count used for autoscaler, when "--enable-cluster-autoscaler" specified. Please specify the value in the range of [1, 100]
- name: --node-taints
type: string
short-summary: The node taints for the node pool. You can't change the node taints through CLI after the node pool is created.
Expand Down Expand Up @@ -546,10 +546,10 @@
short-summary: Update min-count or max-count for cluster autoscaler.
- name: --min-count
type: int
short-summary: Minimun nodes count used for autoscaler, when "--enable-cluster-autoscaler" specified. Please specifying the value in the range of [1, 100]
short-summary: Minimun nodes count used for autoscaler, when "--enable-cluster-autoscaler" specified. Please specify the value in the range of [1, 100]
- name: --max-count
type: int
short-summary: Maximum nodes count used for autoscaler, when "--enable-cluster-autoscaler" specified. Please specifying the value in the range of [1, 100]
short-summary: Maximum nodes count used for autoscaler, when "--enable-cluster-autoscaler" specified. Please specify the value in the range of [1, 100]
- name: --mode
type: string
short-summary: The mode for a node pool which defines a node pool's primary function. If set as "System", AKS prefers system pods scheduling to node pools with mode `System`. Learn more at https://aka.ms/aks/nodepool/mode.
Expand Down
23 changes: 8 additions & 15 deletions src/aks-preview/azext_aks_preview/custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -262,11 +262,11 @@ def load_service_principals(config_path):

def _invoke_deployment(cli_ctx, resource_group_name, deployment_name, template, parameters, validate, no_wait,
subscription_id=None):
from azure.mgmt.resource.resources import ResourceManagementClient
from azure.mgmt.resource.resources.models import DeploymentProperties

from azure.cli.core.profiles import ResourceType, get_sdk
DeploymentProperties = get_sdk(cli_ctx, ResourceType.MGMT_RESOURCE_RESOURCES, 'DeploymentProperties', mod='models')
properties = DeploymentProperties(template=template, parameters=parameters, mode='incremental')
smc = get_mgmt_service_client(cli_ctx, ResourceManagementClient, subscription_id=subscription_id).deployments
smc = get_mgmt_service_client(cli_ctx, ResourceType.MGMT_RESOURCE_RESOURCES,
subscription_id=subscription_id).deployments
if validate:
logger.info('==== BEGIN TEMPLATE ====')
logger.info(json.dumps(template, indent=2))
Expand Down Expand Up @@ -1136,18 +1136,14 @@ def aks_update(cmd, # pylint: disable=too-many-statements,too-many-branches,
raise CLIError('There is more than one node pool in the cluster. Please use "az aks nodepool" command '
'to update per node pool auto scaler settings')

node_count = instance.agent_pool_profiles[0].count

if min_count is None or max_count is None:
if enable_cluster_autoscaler or update_cluster_autoscaler:
raise CLIError('Please specifying both min-count and max-count when --enable-cluster-autoscaler or '
raise CLIError('Please specify both min-count and max-count when --enable-cluster-autoscaler or '
'--update-cluster-autoscaler set.')

if min_count is not None and max_count is not None:
if int(min_count) > int(max_count):
raise CLIError('value of min-count should be less than or equal to value of max-count.')
if int(node_count) < int(min_count) or int(node_count) > int(max_count):
raise CLIError("current node count '{}' is not in the range of min-count and max-count.".format(node_count))

if enable_cluster_autoscaler:
if instance.agent_pool_profiles[0].enable_auto_scaling:
Expand Down Expand Up @@ -1416,7 +1412,7 @@ def aks_kollect(cmd, # pylint: disable=too-many-statements,too-many-locals

sas_token = sas_token.strip('?')
deployment_yaml = urlopen(
"https://raw.githubusercontent.com/Azure/aks-periscope/v0.2/deployment/aks-periscope.yaml").read().decode()
"https://raw.githubusercontent.com/Azure/aks-periscope/latest/deployment/aks-periscope.yaml").read().decode()
deployment_yaml = deployment_yaml.replace("# <accountName, base64 encoded>",
(base64.b64encode(bytes(storage_account_name, 'ascii'))).decode('ascii'))
deployment_yaml = deployment_yaml.replace("# <saskey, base64 encoded>",
Expand Down Expand Up @@ -1963,7 +1959,7 @@ def _check_cluster_autoscaler_flag(enable_cluster_autoscaler,
agent_pool_profile):
if enable_cluster_autoscaler:
if min_count is None or max_count is None:
raise CLIError('Please specifying both min-count and max-count when --enable-cluster-autoscaler enabled')
raise CLIError('Please specify both min-count and max-count when --enable-cluster-autoscaler enabled')
if int(min_count) > int(max_count):
raise CLIError('value of min-count should be less than or equal to value of max-count')
if int(node_count) < int(min_count) or int(node_count) > int(max_count):
Expand Down Expand Up @@ -2183,17 +2179,14 @@ def aks_agentpool_update(cmd, # pylint: disable=unused-argument
'"--tags" or "--mode"')

instance = client.get(resource_group_name, cluster_name, nodepool_name)
node_count = instance.count

if min_count is None or max_count is None:
if enable_cluster_autoscaler or update_cluster_autoscaler:
raise CLIError('Please specifying both min-count and max-count when --enable-cluster-autoscaler or '
raise CLIError('Please specify both min-count and max-count when --enable-cluster-autoscaler or '
'--update-cluster-autoscaler set.')
if min_count is not None and max_count is not None:
if int(min_count) > int(max_count):
raise CLIError('value of min-count should be less than or equal to value of max-count.')
if int(node_count) < int(min_count) or int(node_count) > int(max_count):
raise CLIError("current node count '{}' is not in the range of min-count and max-count.".format(node_count))

if enable_cluster_autoscaler:
if instance.enable_auto_scaling:
Expand Down
2 changes: 1 addition & 1 deletion src/aks-preview/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from codecs import open as open1
from setuptools import setup, find_packages

VERSION = "0.4.43"
VERSION = "0.4.44"
CLASSIFIERS = [
'Development Status :: 4 - Beta',
'Intended Audience :: Developers',
Expand Down
8 changes: 8 additions & 0 deletions src/application-insights/HISTORY.rst
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
0.1.7
++++++++++++++++++

* support linked storage account for application insights component.
* support link one log analytics workspace to application insights component.
* support setting public network access for application insights component.
* one fix for api-key creation.

0.1.6
++++++++++++++++++

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def cf_events(cli_ctx, _):


def cf_components(cli_ctx, _):
return applicationinsights_mgmt_plane_client(cli_ctx).components
return applicationinsights_mgmt_plane_client(cli_ctx, api_version='2018-05-01-preview').components


def cf_component_billing(cli_ctx, _):
Expand All @@ -45,3 +45,7 @@ def cf_component_billing(cli_ctx, _):

def cf_api_key(cli_ctx, _):
return applicationinsights_mgmt_plane_client(cli_ctx).api_keys


def cf_component_linked_storage_accounts(cli_ctx, _):
return applicationinsights_mgmt_plane_client(cli_ctx).component_linked_storage_accounts
25 changes: 25 additions & 0 deletions src/application-insights/azext_applicationinsights/_help.py
Original file line number Diff line number Diff line change
Expand Up @@ -242,3 +242,28 @@
text: |
az monitor app-insights events show --app 578f0e27-12e9-4631-bc02-50b965da2633 --type availabilityResults --offset 24h
"""

helps['monitor app-insights component linked-storage'] = """
type: group
short-summary: Manage linked storage account for an Application Insights component.
"""

helps['monitor app-insights component linked-storage show'] = """
type: command
short-summary: Show the details of linked storage account for an Application Insights component.
"""

helps['monitor app-insights component linked-storage link'] = """
type: command
short-summary: Link a storage account with an Application Insights component.
"""

helps['monitor app-insights component linked-storage update'] = """
type: command
short-summary: Update the linked storage account for an Application Insights component.
"""

helps['monitor app-insights component linked-storage unlink'] = """
type: command
short-summary: Unlink a storage account with an Application Insights component.
"""
19 changes: 16 additions & 3 deletions src/application-insights/azext_applicationinsights/_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
# Licensed under the MIT License. See License.txt in the project root for license information.
# --------------------------------------------------------------------------------------------

# pylint: disable=line-too-long
from azure.cli.core.commands.parameters import get_datetime_type, get_location_type, tags_type, get_three_state_flag
# pylint: disable=line-too-long, too-many-statements
from azure.cli.core.commands.parameters import get_datetime_type, get_location_type, tags_type, get_three_state_flag, get_enum_type
from azure.cli.command_modules.monitor.actions import get_period_type
from ._validators import validate_applications
from ._validators import validate_applications, validate_storage_account_name_or_id, validate_log_analytic_workspace_name_or_id


def load_arguments(self, _):
Expand All @@ -24,6 +24,15 @@ def load_arguments(self, _):
c.argument('application-type', options_list=['application-type', '--type', '-t'], help="Type of application being monitored. Possible values include: 'web', 'other'. Default value: 'web' .")
c.argument('kind', options_list=['--kind', '-k'], help='The kind of application that this component refers to, used to customize UI. This value is a freeform string, values should typically be one of the following: web, ios, other, store, java, phone.')

with self.argument_context('monitor app-insights component') as c:
c.argument('workspace_resource_id', options_list=['--workspace'], validator=validate_log_analytic_workspace_name_or_id,
help='Name or resource ID of a log analytics workspace')
from .vendored_sdks.mgmt_applicationinsights.models import PublicNetworkAccessType
c.argument('public_network_access_for_ingestion', options_list=['--ingestion-access'], help='The public network access type for accessing Application Insights ingestion.',
arg_type=get_enum_type(PublicNetworkAccessType))
c.argument('public_network_access_for_query', options_list=['--query-access'], help='The public network access type for accessing Application Insights query.',
arg_type=get_enum_type(PublicNetworkAccessType))

with self.argument_context('monitor app-insights component update-tags') as c:
c.argument('tags', tags_type)

Expand Down Expand Up @@ -65,3 +74,7 @@ def load_arguments(self, _):
c.argument('start_time', arg_type=get_datetime_type(help='Start-time of time range for which to retrieve data.'))
c.argument('end_time', arg_type=get_datetime_type(help='End of time range for current operation. Defaults to the current time.'))
c.argument('offset', help='Filter results based on UTC hour offset.', type=get_period_type(as_timedelta=True))

with self.argument_context('monitor app-insights component linked-storage') as c:
c.argument('storage_account_id', options_list=['--storage-account', '-s'], validator=validate_storage_account_name_or_id,
help='Name or ID of a linked storage account.')
28 changes: 28 additions & 0 deletions src/application-insights/azext_applicationinsights/_validators.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,31 @@ def validate_applications(namespace):
raise CLIError("Specify either a full resource id or an application name and resource group.")
else:
raise CLIError("Resource group only allowed with a single application name.")


def validate_storage_account_name_or_id(cmd, namespace):
if namespace.storage_account_id:
from msrestazure.tools import resource_id
from azure.cli.core.commands.client_factory import get_subscription_id
if not is_valid_resource_id(namespace.storage_account_id):
namespace.storage_account_id = resource_id(
subscription=get_subscription_id(cmd.cli_ctx),
resource_group=namespace.resource_group_name,
namespace='Microsoft.Storage',
type='storageAccounts',
name=namespace.storage_account_id
)


def validate_log_analytic_workspace_name_or_id(cmd, namespace):
if namespace.workspace_resource_id:
from msrestazure.tools import resource_id
from azure.cli.core.commands.client_factory import get_subscription_id
if not is_valid_resource_id(namespace.workspace_resource_id):
namespace.workspace_resource_id = resource_id(
subscription=get_subscription_id(cmd.cli_ctx),
resource_group=namespace.resource_group_name,
namespace='microsoft.OperationalInsights',
type='workspaces',
name=namespace.workspace_resource_id
)
Loading