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
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ interactions:
accept-language:
- en-US
method: PUT
uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/clitest.rg000001/providers/Microsoft.OperationalInsights/workspaces/wprkspace000003?api-version=2015-11-01-preview
uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/clitest.rg000001/providers/Microsoft.OperationalInsights/workspaces/wprkspace000003?api-version=2020-03-01-preview
response:
body:
string: "{\r\n \"properties\": {\r\n \"source\": \"Azure\",\r\n \"customerId\":
Expand Down Expand Up @@ -125,7 +125,7 @@ interactions:
- python/3.6.6 (Windows-10-10.0.18362-SP0) msrest/0.6.9 msrest_azure/0.6.2 azure-mgmt-loganalytics/0.2.0
Azure-SDK-For-Python AZURECLI/2.1.0
method: GET
uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/clitest.rg000001/providers/Microsoft.OperationalInsights/workspaces/wprkspace000003?api-version=2015-11-01-preview
uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/clitest.rg000001/providers/Microsoft.OperationalInsights/workspaces/wprkspace000003?api-version=2020-03-01-preview
response:
body:
string: "{\r\n \"properties\": {\r\n \"source\": \"Azure\",\r\n \"customerId\":
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,14 @@ def _log_analytics_client_factory(cli_ctx, *_):
return get_mgmt_service_client(cli_ctx, LogAnalyticsManagementClient)


def cf_log_analytics(cli_ctx, *_):
def cf_log_analytics_workspace(cli_ctx, *_):
return _log_analytics_client_factory(cli_ctx).workspaces


def cf_log_analytics_workspace_shared_keys(cli_ctx, *_):
return _log_analytics_client_factory(cli_ctx).shared_keys


def cf_resource(cli_ctx):
from azure.cli.core.commands.client_factory import get_mgmt_service_client
from azure.cli.core.profiles import ResourceType
Expand Down
10 changes: 6 additions & 4 deletions src/azure-cli/azure/cli/command_modules/container/custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@
GitRepoVolume, LogAnalytics, ContainerGroupDiagnostics, ContainerGroupNetworkProfile,
ContainerGroupIpAddressType, ResourceIdentityType, ContainerGroupIdentity)
from azure.cli.core.util import sdk_no_wait
from ._client_factory import (cf_container_groups, cf_container, cf_log_analytics, cf_resource, cf_network)
from ._client_factory import (cf_container_groups, cf_container, cf_log_analytics_workspace,
cf_log_analytics_workspace_shared_keys, cf_resource, cf_network)

logger = get_logger(__name__)
WINDOWS_NAME = 'Windows'
Expand Down Expand Up @@ -351,11 +352,12 @@ def _get_vnet_network_profile(cmd, location, resource_group_name, vnet, vnet_add

def _get_diagnostics_from_workspace(cli_ctx, log_analytics_workspace):
from msrestazure.tools import parse_resource_id
log_analytics_client = cf_log_analytics(cli_ctx)
log_analytics_workspace_client = cf_log_analytics_workspace(cli_ctx)
log_analytics_workspace_shared_keys_client = cf_log_analytics_workspace_shared_keys(cli_ctx)

for workspace in log_analytics_client.list():
for workspace in log_analytics_workspace_client.list():
if log_analytics_workspace in (workspace.name, workspace.customer_id):
keys = log_analytics_client.get_shared_keys(
keys = log_analytics_workspace_shared_keys_client.get_shared_keys(
parse_resource_id(workspace.id)['resource_group'], workspace.name)

log_analytics = LogAnalytics(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -445,7 +445,8 @@ def enable_hdi_monitoring(cmd, client, resource_group_name, cluster_name, worksp

# Only retrieve primary key when not provided
if not primary_key:
shared_keys = log_analytics_client.workspaces.get_shared_keys(workspace_resource_group_name, workspace_name)
shared_keys = log_analytics_client.shared_keys.get_shared_keys(workspace_resource_group_name,
workspace_name)
if not shared_keys:
raise CLIError('Fails to retrieve shared key for workspace {}'.format(log_analytics_workspace))

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ interactions:
East","UK South","Central India","Canada Central","West US 2","Australia Central","Australia
East","France Central","Korea Central","North Europe","Central US","East Asia","East
US 2","South Central US","North Central US","West US","UK West","South Africa
North","Brazil South","Switzerland North","Switzerland West"],"apiVersions":["2017-04-26-preview","2017-03-15-preview","2017-03-03-preview","2017-01-01-preview","2015-11-01-preview","2015-03-20"],"capabilities":"CrossResourceGroupResourceMove,
North","Brazil South","Switzerland North","Switzerland West"],"apiVersions":["2017-04-26-preview","2017-03-15-preview","2017-03-03-preview","2017-01-01-preview","2020-03-01-preview","2015-03-20"],"capabilities":"CrossResourceGroupResourceMove,
CrossSubscriptionResourceMove, SupportsTags, SupportsLocation"},{"resourceType":"workspaces/query","locations":["West
Central US","Australia Southeast","West Europe","East US","Southeast Asia","Japan
East","UK South","Central India","Canada Central","West US 2","Australia Central","Australia
Expand All @@ -37,13 +37,13 @@ interactions:
East","UK South","Central India","Canada Central","West US 2","Australia Central","Australia
East","France Central","Korea Central","North Europe","Central US","East Asia","East
US 2","South Central US","North Central US","West US","UK West","South Africa
North","Brazil South","Switzerland North","Switzerland West"],"apiVersions":["2015-11-01-preview"],"capabilities":"None"},{"resourceType":"storageInsightConfigs","locations":[],"apiVersions":["2014-10-10"],"capabilities":"SupportsExtension"},{"resourceType":"workspaces/linkedServices","locations":["East
North","Brazil South","Switzerland North","Switzerland West"],"apiVersions":["2020-03-01-preview"],"capabilities":"None"},{"resourceType":"storageInsightConfigs","locations":[],"apiVersions":["2014-10-10"],"capabilities":"SupportsExtension"},{"resourceType":"workspaces/linkedServices","locations":["East
US","West Europe","Southeast Asia","Australia Southeast","West Central US","Japan
East","UK South","Central India","Canada Central","West US 2","Australia Central","Australia
East","France Central","Korea Central","North Europe","Central US","East Asia","East
US 2","South Central US","North Central US","West US","UK West","South Africa
North","Brazil South","Switzerland North","Switzerland West"],"apiVersions":["2015-11-01-preview"],"capabilities":"None"},{"resourceType":"linkTargets","locations":["East
US"],"apiVersions":["2015-03-20"],"capabilities":"None"},{"resourceType":"operations","locations":[],"apiVersions":["2014-11-10"],"capabilities":"None"},{"resourceType":"devices","locations":[],"apiVersions":["2015-11-01-preview"],"capabilities":"None"}],"registrationState":"Registered","registrationPolicy":"RegistrationRequired"}'
North","Brazil South","Switzerland North","Switzerland West"],"apiVersions":["2020-03-01-preview"],"capabilities":"None"},{"resourceType":"linkTargets","locations":["East
US"],"apiVersions":["2015-03-20"],"capabilities":"None"},{"resourceType":"operations","locations":[],"apiVersions":["2014-11-10"],"capabilities":"None"},{"resourceType":"devices","locations":[],"apiVersions":["2020-03-01-preview"],"capabilities":"None"}],"registrationState":"Registered","registrationPolicy":"RegistrationRequired"}'
headers:
cache-control:
- no-cache
Expand Down Expand Up @@ -2158,7 +2158,7 @@ interactions:
accept-language:
- en-US
method: GET
uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/hdicli-000001/providers/Microsoft.OperationalInsights/workspaces/testws000003?api-version=2015-11-01-preview
uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/hdicli-000001/providers/Microsoft.OperationalInsights/workspaces/testws000003?api-version=2020-03-01-preview
response:
body:
string: "{\r\n \"properties\": {\r\n \"source\": \"Azure\",\r\n \"customerId\":
Expand Down Expand Up @@ -2222,7 +2222,7 @@ interactions:
accept-language:
- en-US
method: POST
uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/hdicli-000001/providers/Microsoft.OperationalInsights/workspaces/testws000003/sharedKeys?api-version=2015-11-01-preview
uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/hdicli-000001/providers/Microsoft.OperationalInsights/workspaces/testws000003/sharedKeys?api-version=2020-03-01-preview
response:
body:
string: "{\r\n \"primarySharedKey\": \"ZpSONOTvl/2Adf/PLsZX8enzn5/6DGAnkN1rkHHx8+0cu/f5HpE8m6ZyqCCyB+Ud/jxtnY5BWr29wvXdQjQXTw==\",\r\n
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,3 +91,31 @@ def cf_private_endpoint_connections(cli_ctx, _):

def cf_log_analytics_workspace(cli_ctx, _):
return _log_analytics_client_factory(cli_ctx).workspaces


def cf_log_analytics_workspace_management_groups(cli_ctx, _):
return _log_analytics_client_factory(cli_ctx).management_groups


def cf_log_analytics_workspace_usage(cli_ctx, _):
return _log_analytics_client_factory(cli_ctx).usages


def cf_log_analytics_workspace_schema(cli_ctx, _):
return _log_analytics_client_factory(cli_ctx).schema


def cf_log_analytics_workspace_shared_keys(cli_ctx, _):
return _log_analytics_client_factory(cli_ctx).shared_keys


def cf_log_analytics_workspace_intelligence_packs(cli_ctx, _):
return _log_analytics_client_factory(cli_ctx).intelligence_packs


def cf_log_analytics_workspace_linked_service(cli_ctx, _):
return _log_analytics_client_factory(cli_ctx).linked_services


def cf_log_analytics_cluster(cli_ctx, _):
return _log_analytics_client_factory(cli_ctx).clusters
120 changes: 119 additions & 1 deletion src/azure-cli/azure/cli/command_modules/monitor/_help.py
Original file line number Diff line number Diff line change
Expand Up @@ -866,7 +866,65 @@

helps['monitor log-analytics'] = """
type: group
short-summary: Manage Azure log analytics
short-summary: Manage Azure log analytics.
"""

helps['monitor log-analytics cluster'] = """
type: group
short-summary: Manage Azure log analytics cluster.
"""

helps['monitor log-analytics cluster create'] = """
type: command
short-summary: Create a cluster instance.
examples:
- name: Create a cluster instance.
text: az monitor log-analytics cluster create -g MyResourceGroup -n MyCluster --sku-capacity 1000
"""

helps['monitor log-analytics cluster update'] = """
type: command
short-summary: Update a cluster instance.
examples:
- name: Update a cluster instance.
text: |
az monitor log-analytics cluster update -g MyResourceGroup -n MyCluster \\
--key-vault-uri https://myvault.vault.azure.net/ --key-name my-key \\
--key-version fe0adcedd8014aed9c22e9aefb81a1ds --sku-capacity 1000
"""

helps['monitor log-analytics cluster delete'] = """
type: command
short-summary: Delete a cluster instance.
examples:
- name: Delete a cluster instance.
text: az monitor log-analytics cluster delete -g MyResourceGroup -n MyCluster
"""

helps['monitor log-analytics cluster show'] = """
type: command
short-summary: Show the properties of a cluster instance.
examples:
- name: Show the properties of a cluster instance.
text: az monitor log-analytics cluster show -g MyResourceGroup -n MyCluster
"""

helps['monitor log-analytics cluster list'] = """
type: command
short-summary: Gets all cluster instances in a resource group or in current subscription.
examples:
- name: Gets all cluster instances in a resource group.
text: az monitor log-analytics cluster list -g MyResourceGroup
- name: Gets all cluster instances in current subscription.
text: az monitor log-analytics cluster list
"""

helps['monitor log-analytics cluster wait'] = """
type: command
short-summary: Place the CLI in a waiting state until a condition of the cluster is met.
examples:
- name: Pause executing next line of CLI script until the cluster is successfully provisioned.
text: az monitor log-analytics cluster wait -n MyCluster -g MyResourceGroup --created
"""

helps['monitor log-analytics workspace'] = """
Expand Down Expand Up @@ -985,6 +1043,66 @@
short-summary: Update a workspace instance
"""

helps['monitor log-analytics workspace linked-service'] = """
type: group
short-summary: Manage linked service for log analytics workspace.
"""

helps['monitor log-analytics workspace linked-service create'] = """
type: command
short-summary: Create a linked service.
examples:
- name: Create a linked service.
text: |
az monitor log-analytics workspace linked-service create -g MyResourceGroup -n cluster \\
--workspace-name MyWorkspace --write-access-resource-id /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MyResourceGroup/providers/Microsoft.OperationalInsights/clusters/MyCluster
"""

helps['monitor log-analytics workspace linked-service update'] = """
type: command
short-summary: Update a linked service.
examples:
- name: Update a linked service.
text: |
az monitor log-analytics workspace linked-service update -g MyResourceGroup -n cluster \\
--workspace-name MyWorkspace --write-access-resource-id /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MyResourceGroup/providers/Microsoft.OperationalInsights/clusters/MyCluster
"""

helps['monitor log-analytics workspace linked-service show'] = """
type: command
short-summary: Show the properties of a linked service.
examples:
- name: Show the properties of a linked service.
text: |
az monitor log-analytics workspace linked-service show -g MyResourceGroup -n cluster --workspace-name MyWorkspace
"""

helps['monitor log-analytics workspace linked-service delete'] = """
type: command
short-summary: Delete a linked service.
examples:
- name: Delete a linked service.
text: |
az monitor log-analytics workspace linked-service delete -g MyResourceGroup -n cluster --workspace-name MyWorkspace
"""

helps['monitor log-analytics workspace linked-service list'] = """
type: command
short-summary: Gets all the linked services in a workspace.
examples:
- name: Gets all the linked services in a workspace.
text: |
az monitor log-analytics workspace linked-service list -g MyResourceGroup --workspace-name MyWorkspace
"""

helps['monitor log-analytics workspace linked-service wait'] = """
type: command
short-summary: Place the CLI in a waiting state until a condition of the linked service is met.
examples:
- name: Pause executing next line of CLI script until the linked service is successfully provisioned.
text: az monitor log-analytics workspace linked-service wait -n cluster -g MyResourceGroup --workspace-name MyWorkspace --created
"""

helps['monitor log-profiles'] = """
type: group
short-summary: Manage log profiles.
Expand Down
26 changes: 26 additions & 0 deletions src/azure-cli/azure/cli/command_modules/monitor/_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,32 @@ def load_arguments(self, _):
c.argument('workspace_name', options_list='--workspace-name')
# endregion

# region Log Analytics Workspace Linked Service
with self.argument_context('monitor log-analytics workspace linked-service') as c:
c.argument('linked_service_name', name_arg_type, help='Name of the linkedServices resource. Supported values: cluster, automation.')
c.argument('workspace_name', options_list='--workspace-name')
c.argument('resource_id', help='The resource id of the resource that will be linked to the workspace. This '
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

which kinds of resources are acceptable?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The resource type is defined by linked_service_name which support automation and cluster


In reply to: 413634067 [](ancestors = 413634067)

'should be used for linking resources which require read access.')
c.argument('write_access_resource_id', help='The resource id of the resource that will be linked to the '
'workspace. This should be used for linking resources which '
'require write access.')
# endregion

# region Log Analytics Cluster
with self.argument_context('monitor log-analytics cluster') as c:
c.argument('cluster_name', name_arg_type, help='The name of the Log Analytics cluster.')
c.argument('sku_name', help="The name of the SKU. Currently only support 'CapacityReservation'")
c.argument('sku_capacity', help='The capacity of the SKU. It must be in the range of 1000-2000 per day and must'
' be in multiples of 100. If you want to increase the limit, please contact'
' LAIngestionRate@microsoft.com. It can be decreased only after 31 days.')
c.argument('identity_type', help='The identity type. Supported values: SystemAssigned')

with self.argument_context('monitor log-analytics cluster update') as c:
c.argument('key_vault_uri', help='The Key Vault uri which holds the key associated with the Log Analytics cluster.')
c.argument('key_name', help='The name of the key associated with the Log Analytics cluster.')
c.argument('key_version', help='The version of the key associated with the Log Analytics cluster.')
# endregion

# region monitor clone
with self.argument_context('monitor clone') as c:
c.argument('source_resource', help="Resource ID of the source resource.")
Expand Down
Loading