diff --git a/src/azure-cli/azure/cli/command_modules/monitor/_params.py b/src/azure-cli/azure/cli/command_modules/monitor/_params.py index c36b37644c5..6c02aac625d 100644 --- a/src/azure-cli/azure/cli/command_modules/monitor/_params.py +++ b/src/azure-cli/azure/cli/command_modules/monitor/_params.py @@ -232,6 +232,11 @@ def load_arguments(self, _): c.resource_parameter('resource_uri', required=True, arg_group='Target Resource', skip_validator=True) c.argument('logs', type=get_json_object) c.argument('metrics', type=get_json_object) + c.argument('export_to_specific_resource', arg_type=get_three_state_flag(), + help='Indicate that the export to LA must be done to a resource specific table, ' + 'a.k.a. dedicated or fixed schema table, ' + 'as opposed to the default dynamic schema table called AzureDiagnostics. ' + 'This argument is effective only when the argument --workspace is also given.') with self.argument_context('monitor diagnostic-settings categories list') as c: c.resource_parameter('resource_uri', required=True) diff --git a/src/azure-cli/azure/cli/command_modules/monitor/operations/diagnostics_settings.py b/src/azure-cli/azure/cli/command_modules/monitor/operations/diagnostics_settings.py index 9b6ba1ef53d..dfb88c85e30 100644 --- a/src/azure-cli/azure/cli/command_modules/monitor/operations/diagnostics_settings.py +++ b/src/azure-cli/azure/cli/command_modules/monitor/operations/diagnostics_settings.py @@ -4,20 +4,25 @@ # -------------------------------------------------------------------------------------------- -# pylint: disable=unused-argument +# pylint: disable=unused-argument, line-too-long def create_diagnostics_settings(client, name, resource_uri, logs=None, metrics=None, event_hub=None, event_hub_rule=None, storage_account=None, - workspace=None): + workspace=None, + export_to_specific_resource=None): from azure.mgmt.monitor.models import DiagnosticSettingsResource + from knack.util import CLIError + if export_to_specific_resource and workspace is None: + raise CLIError('usage error: --workspace and --export-to-specific-resource') parameters = DiagnosticSettingsResource(storage_account_id=storage_account, workspace_id=workspace, event_hub_name=event_hub, event_hub_authorization_rule_id=event_hub_rule, metrics=metrics, - logs=logs) + logs=logs, + log_analytics_destination_type='Dedicated' if export_to_specific_resource else None) return client.create_or_update(resource_uri=resource_uri, parameters=parameters, name=name) diff --git a/src/azure-cli/azure/cli/command_modules/monitor/tests/latest/recordings/test_monitor_diagnostic_settings_scenario.yaml b/src/azure-cli/azure/cli/command_modules/monitor/tests/latest/recordings/test_monitor_diagnostic_settings_scenario.yaml index 3922e38b649..82a3695f752 100644 --- a/src/azure-cli/azure/cli/command_modules/monitor/tests/latest/recordings/test_monitor_diagnostic_settings_scenario.yaml +++ b/src/azure-cli/azure/cli/command_modules/monitor/tests/latest/recordings/test_monitor_diagnostic_settings_scenario.yaml @@ -13,15 +13,15 @@ interactions: ParameterSetName: - -n -g User-Agent: - - python/3.7.4 (Windows-10-10.0.18362-SP0) msrest/0.6.9 msrest_azure/0.6.3 azure-mgmt-resource/8.0.1 - Azure-SDK-For-Python AZURECLI/2.3.1 + - python/3.8.0 (Windows-10-10.0.18362-SP0) msrest/0.6.10 msrest_azure/0.6.3 + azure-mgmt-resource/9.0.0 Azure-SDK-For-Python AZURECLI/2.6.0 accept-language: - en-US method: GET uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/clitest.rg000001?api-version=2019-07-01 response: body: - string: '{"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clitest.rg000001","name":"clitest.rg000001","type":"Microsoft.Resources/resourceGroups","location":"southcentralus","tags":{"product":"azurecli","cause":"automation","date":"2020-04-07T00:32:45Z","StorageType":"Standard_LRS","type":"test"},"properties":{"provisioningState":"Succeeded"}}' + string: '{"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clitest.rg000001","name":"clitest.rg000001","type":"Microsoft.Resources/resourceGroups","location":"southcentralus","tags":{"product":"azurecli","cause":"automation","date":"2020-05-18T07:33:43Z","StorageType":"Standard_LRS","type":"test"},"properties":{"provisioningState":"Succeeded"}}' headers: cache-control: - no-cache @@ -30,7 +30,7 @@ interactions: content-type: - application/json; charset=utf-8 date: - - Tue, 07 Apr 2020 00:33:22 GMT + - Mon, 18 May 2020 07:34:16 GMT expires: - '-1' pragma: @@ -62,8 +62,8 @@ interactions: ParameterSetName: - -n -g User-Agent: - - python/3.7.4 (Windows-10-10.0.18362-SP0) msrest/0.6.9 msrest_azure/0.6.3 azure-mgmt-network/10.0.0 - Azure-SDK-For-Python AZURECLI/2.3.1 + - python/3.8.0 (Windows-10-10.0.18362-SP0) msrest/0.6.10 msrest_azure/0.6.3 + azure-mgmt-network/10.1.0 Azure-SDK-For-Python AZURECLI/2.6.0 accept-language: - en-US method: PUT @@ -71,13 +71,13 @@ interactions: response: body: string: "{\r\n \"name\": \"nsg000003\",\r\n \"id\": \"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clitest.rg000001/providers/Microsoft.Network/networkSecurityGroups/nsg000003\",\r\n - \ \"etag\": \"W/\\\"ec63a2b1-410a-4a49-bb24-a6042c523179\\\"\",\r\n \"type\": + \ \"etag\": \"W/\\\"49b9898a-8923-4c4e-a028-73ac79c1a019\\\"\",\r\n \"type\": \"Microsoft.Network/networkSecurityGroups\",\r\n \"location\": \"southcentralus\",\r\n \ \"properties\": {\r\n \"provisioningState\": \"Updating\",\r\n \"resourceGuid\": - \"140821df-357a-4727-8a9a-9a2e6f7ecaf3\",\r\n \"securityRules\": [],\r\n + \"4b76f7a0-7fae-49e6-bcd8-fbe561aa82e6\",\r\n \"securityRules\": [],\r\n \ \"defaultSecurityRules\": [\r\n {\r\n \"name\": \"AllowVnetInBound\",\r\n \ \"id\": \"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clitest.rg000001/providers/Microsoft.Network/networkSecurityGroups/nsg000003/defaultSecurityRules/AllowVnetInBound\",\r\n - \ \"etag\": \"W/\\\"ec63a2b1-410a-4a49-bb24-a6042c523179\\\"\",\r\n + \ \"etag\": \"W/\\\"49b9898a-8923-4c4e-a028-73ac79c1a019\\\"\",\r\n \ \"type\": \"Microsoft.Network/networkSecurityGroups/defaultSecurityRules\",\r\n \ \"properties\": {\r\n \"provisioningState\": \"Updating\",\r\n \ \"description\": \"Allow inbound traffic from all VMs in VNET\",\r\n @@ -89,7 +89,7 @@ interactions: [],\r\n \"sourceAddressPrefixes\": [],\r\n \"destinationAddressPrefixes\": []\r\n }\r\n },\r\n {\r\n \"name\": \"AllowAzureLoadBalancerInBound\",\r\n \ \"id\": \"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clitest.rg000001/providers/Microsoft.Network/networkSecurityGroups/nsg000003/defaultSecurityRules/AllowAzureLoadBalancerInBound\",\r\n - \ \"etag\": \"W/\\\"ec63a2b1-410a-4a49-bb24-a6042c523179\\\"\",\r\n + \ \"etag\": \"W/\\\"49b9898a-8923-4c4e-a028-73ac79c1a019\\\"\",\r\n \ \"type\": \"Microsoft.Network/networkSecurityGroups/defaultSecurityRules\",\r\n \ \"properties\": {\r\n \"provisioningState\": \"Updating\",\r\n \ \"description\": \"Allow inbound traffic from azure load balancer\",\r\n @@ -101,7 +101,7 @@ interactions: [],\r\n \"sourceAddressPrefixes\": [],\r\n \"destinationAddressPrefixes\": []\r\n }\r\n },\r\n {\r\n \"name\": \"DenyAllInBound\",\r\n \ \"id\": \"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clitest.rg000001/providers/Microsoft.Network/networkSecurityGroups/nsg000003/defaultSecurityRules/DenyAllInBound\",\r\n - \ \"etag\": \"W/\\\"ec63a2b1-410a-4a49-bb24-a6042c523179\\\"\",\r\n + \ \"etag\": \"W/\\\"49b9898a-8923-4c4e-a028-73ac79c1a019\\\"\",\r\n \ \"type\": \"Microsoft.Network/networkSecurityGroups/defaultSecurityRules\",\r\n \ \"properties\": {\r\n \"provisioningState\": \"Updating\",\r\n \ \"description\": \"Deny all inbound traffic\",\r\n \"protocol\": @@ -112,7 +112,7 @@ interactions: \ \"destinationPortRanges\": [],\r\n \"sourceAddressPrefixes\": [],\r\n \"destinationAddressPrefixes\": []\r\n }\r\n },\r\n \ {\r\n \"name\": \"AllowVnetOutBound\",\r\n \"id\": \"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clitest.rg000001/providers/Microsoft.Network/networkSecurityGroups/nsg000003/defaultSecurityRules/AllowVnetOutBound\",\r\n - \ \"etag\": \"W/\\\"ec63a2b1-410a-4a49-bb24-a6042c523179\\\"\",\r\n + \ \"etag\": \"W/\\\"49b9898a-8923-4c4e-a028-73ac79c1a019\\\"\",\r\n \ \"type\": \"Microsoft.Network/networkSecurityGroups/defaultSecurityRules\",\r\n \ \"properties\": {\r\n \"provisioningState\": \"Updating\",\r\n \ \"description\": \"Allow outbound traffic from all VMs to all VMs @@ -124,7 +124,7 @@ interactions: [],\r\n \"sourceAddressPrefixes\": [],\r\n \"destinationAddressPrefixes\": []\r\n }\r\n },\r\n {\r\n \"name\": \"AllowInternetOutBound\",\r\n \ \"id\": \"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clitest.rg000001/providers/Microsoft.Network/networkSecurityGroups/nsg000003/defaultSecurityRules/AllowInternetOutBound\",\r\n - \ \"etag\": \"W/\\\"ec63a2b1-410a-4a49-bb24-a6042c523179\\\"\",\r\n + \ \"etag\": \"W/\\\"49b9898a-8923-4c4e-a028-73ac79c1a019\\\"\",\r\n \ \"type\": \"Microsoft.Network/networkSecurityGroups/defaultSecurityRules\",\r\n \ \"properties\": {\r\n \"provisioningState\": \"Updating\",\r\n \ \"description\": \"Allow outbound traffic from all VMs to Internet\",\r\n @@ -136,7 +136,7 @@ interactions: [],\r\n \"sourceAddressPrefixes\": [],\r\n \"destinationAddressPrefixes\": []\r\n }\r\n },\r\n {\r\n \"name\": \"DenyAllOutBound\",\r\n \ \"id\": \"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clitest.rg000001/providers/Microsoft.Network/networkSecurityGroups/nsg000003/defaultSecurityRules/DenyAllOutBound\",\r\n - \ \"etag\": \"W/\\\"ec63a2b1-410a-4a49-bb24-a6042c523179\\\"\",\r\n + \ \"etag\": \"W/\\\"49b9898a-8923-4c4e-a028-73ac79c1a019\\\"\",\r\n \ \"type\": \"Microsoft.Network/networkSecurityGroups/defaultSecurityRules\",\r\n \ \"properties\": {\r\n \"provisioningState\": \"Updating\",\r\n \ \"description\": \"Deny all outbound traffic\",\r\n \"protocol\": @@ -151,7 +151,7 @@ interactions: azure-asyncnotification: - Enabled azure-asyncoperation: - - https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Network/locations/southcentralus/operations/cfaa724b-450f-45bd-851a-cc7b1475541e?api-version=2020-03-01 + - https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Network/locations/southcentralus/operations/c147b131-5521-4970-9858-9bce2d349ca4?api-version=2020-03-01 cache-control: - no-cache content-length: @@ -159,7 +159,7 @@ interactions: content-type: - application/json; charset=utf-8 date: - - Tue, 07 Apr 2020 00:33:32 GMT + - Mon, 18 May 2020 07:34:25 GMT expires: - '-1' pragma: @@ -172,9 +172,9 @@ interactions: x-content-type-options: - nosniff x-ms-arm-service-request-id: - - 28adaea9-5a04-471e-bc09-83b29df6fa53 + - 7b2843d4-dec8-429b-bb70-f7ef891abcbc x-ms-ratelimit-remaining-subscription-writes: - - '1158' + - '1191' status: code: 201 message: Created @@ -192,60 +192,10 @@ interactions: ParameterSetName: - -n -g User-Agent: - - python/3.7.4 (Windows-10-10.0.18362-SP0) msrest/0.6.9 msrest_azure/0.6.3 azure-mgmt-network/10.0.0 - Azure-SDK-For-Python AZURECLI/2.3.1 + - python/3.8.0 (Windows-10-10.0.18362-SP0) msrest/0.6.10 msrest_azure/0.6.3 + azure-mgmt-network/10.1.0 Azure-SDK-For-Python AZURECLI/2.6.0 method: GET - uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Network/locations/southcentralus/operations/cfaa724b-450f-45bd-851a-cc7b1475541e?api-version=2020-03-01 - response: - body: - string: "{\r\n \"status\": \"InProgress\"\r\n}" - headers: - cache-control: - - no-cache - content-length: - - '30' - content-type: - - application/json; charset=utf-8 - date: - - Tue, 07 Apr 2020 00:33:37 GMT - expires: - - '-1' - pragma: - - no-cache - server: - - Microsoft-HTTPAPI/2.0 - - Microsoft-HTTPAPI/2.0 - strict-transport-security: - - max-age=31536000; includeSubDomains - transfer-encoding: - - chunked - vary: - - Accept-Encoding - x-content-type-options: - - nosniff - x-ms-arm-service-request-id: - - 025c09e3-5ca1-4378-b0ec-566fbc60d025 - status: - code: 200 - message: OK -- request: - body: null - headers: - Accept: - - application/json - Accept-Encoding: - - gzip, deflate - CommandName: - - network nsg create - Connection: - - keep-alive - ParameterSetName: - - -n -g - User-Agent: - - python/3.7.4 (Windows-10-10.0.18362-SP0) msrest/0.6.9 msrest_azure/0.6.3 azure-mgmt-network/10.0.0 - Azure-SDK-For-Python AZURECLI/2.3.1 - method: GET - uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Network/locations/southcentralus/operations/cfaa724b-450f-45bd-851a-cc7b1475541e?api-version=2020-03-01 + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Network/locations/southcentralus/operations/c147b131-5521-4970-9858-9bce2d349ca4?api-version=2020-03-01 response: body: string: "{\r\n \"status\": \"Succeeded\"\r\n}" @@ -257,7 +207,7 @@ interactions: content-type: - application/json; charset=utf-8 date: - - Tue, 07 Apr 2020 00:33:47 GMT + - Mon, 18 May 2020 07:34:30 GMT expires: - '-1' pragma: @@ -274,7 +224,7 @@ interactions: x-content-type-options: - nosniff x-ms-arm-service-request-id: - - 3053f332-f6a5-4b56-ad0a-9d6e8e4774dd + - 86b252e5-0565-4e8d-8cf3-93d7af8edfe6 status: code: 200 message: OK @@ -292,20 +242,20 @@ interactions: ParameterSetName: - -n -g User-Agent: - - python/3.7.4 (Windows-10-10.0.18362-SP0) msrest/0.6.9 msrest_azure/0.6.3 azure-mgmt-network/10.0.0 - Azure-SDK-For-Python AZURECLI/2.3.1 + - python/3.8.0 (Windows-10-10.0.18362-SP0) msrest/0.6.10 msrest_azure/0.6.3 + azure-mgmt-network/10.1.0 Azure-SDK-For-Python AZURECLI/2.6.0 method: GET uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clitest.rg000001/providers/Microsoft.Network/networkSecurityGroups/nsg000003?api-version=2020-03-01 response: body: string: "{\r\n \"name\": \"nsg000003\",\r\n \"id\": \"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clitest.rg000001/providers/Microsoft.Network/networkSecurityGroups/nsg000003\",\r\n - \ \"etag\": \"W/\\\"5786d3a1-5002-4f01-a21c-cb423b01ecdf\\\"\",\r\n \"type\": + \ \"etag\": \"W/\\\"d7517753-5803-4541-a0bb-4bc557c2c566\\\"\",\r\n \"type\": \"Microsoft.Network/networkSecurityGroups\",\r\n \"location\": \"southcentralus\",\r\n \ \"properties\": {\r\n \"provisioningState\": \"Succeeded\",\r\n \"resourceGuid\": - \"140821df-357a-4727-8a9a-9a2e6f7ecaf3\",\r\n \"securityRules\": [],\r\n + \"4b76f7a0-7fae-49e6-bcd8-fbe561aa82e6\",\r\n \"securityRules\": [],\r\n \ \"defaultSecurityRules\": [\r\n {\r\n \"name\": \"AllowVnetInBound\",\r\n \ \"id\": \"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clitest.rg000001/providers/Microsoft.Network/networkSecurityGroups/nsg000003/defaultSecurityRules/AllowVnetInBound\",\r\n - \ \"etag\": \"W/\\\"5786d3a1-5002-4f01-a21c-cb423b01ecdf\\\"\",\r\n + \ \"etag\": \"W/\\\"d7517753-5803-4541-a0bb-4bc557c2c566\\\"\",\r\n \ \"type\": \"Microsoft.Network/networkSecurityGroups/defaultSecurityRules\",\r\n \ \"properties\": {\r\n \"provisioningState\": \"Succeeded\",\r\n \ \"description\": \"Allow inbound traffic from all VMs in VNET\",\r\n @@ -317,7 +267,7 @@ interactions: [],\r\n \"sourceAddressPrefixes\": [],\r\n \"destinationAddressPrefixes\": []\r\n }\r\n },\r\n {\r\n \"name\": \"AllowAzureLoadBalancerInBound\",\r\n \ \"id\": \"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clitest.rg000001/providers/Microsoft.Network/networkSecurityGroups/nsg000003/defaultSecurityRules/AllowAzureLoadBalancerInBound\",\r\n - \ \"etag\": \"W/\\\"5786d3a1-5002-4f01-a21c-cb423b01ecdf\\\"\",\r\n + \ \"etag\": \"W/\\\"d7517753-5803-4541-a0bb-4bc557c2c566\\\"\",\r\n \ \"type\": \"Microsoft.Network/networkSecurityGroups/defaultSecurityRules\",\r\n \ \"properties\": {\r\n \"provisioningState\": \"Succeeded\",\r\n \ \"description\": \"Allow inbound traffic from azure load balancer\",\r\n @@ -329,7 +279,7 @@ interactions: [],\r\n \"sourceAddressPrefixes\": [],\r\n \"destinationAddressPrefixes\": []\r\n }\r\n },\r\n {\r\n \"name\": \"DenyAllInBound\",\r\n \ \"id\": \"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clitest.rg000001/providers/Microsoft.Network/networkSecurityGroups/nsg000003/defaultSecurityRules/DenyAllInBound\",\r\n - \ \"etag\": \"W/\\\"5786d3a1-5002-4f01-a21c-cb423b01ecdf\\\"\",\r\n + \ \"etag\": \"W/\\\"d7517753-5803-4541-a0bb-4bc557c2c566\\\"\",\r\n \ \"type\": \"Microsoft.Network/networkSecurityGroups/defaultSecurityRules\",\r\n \ \"properties\": {\r\n \"provisioningState\": \"Succeeded\",\r\n \ \"description\": \"Deny all inbound traffic\",\r\n \"protocol\": @@ -340,7 +290,7 @@ interactions: \ \"destinationPortRanges\": [],\r\n \"sourceAddressPrefixes\": [],\r\n \"destinationAddressPrefixes\": []\r\n }\r\n },\r\n \ {\r\n \"name\": \"AllowVnetOutBound\",\r\n \"id\": \"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clitest.rg000001/providers/Microsoft.Network/networkSecurityGroups/nsg000003/defaultSecurityRules/AllowVnetOutBound\",\r\n - \ \"etag\": \"W/\\\"5786d3a1-5002-4f01-a21c-cb423b01ecdf\\\"\",\r\n + \ \"etag\": \"W/\\\"d7517753-5803-4541-a0bb-4bc557c2c566\\\"\",\r\n \ \"type\": \"Microsoft.Network/networkSecurityGroups/defaultSecurityRules\",\r\n \ \"properties\": {\r\n \"provisioningState\": \"Succeeded\",\r\n \ \"description\": \"Allow outbound traffic from all VMs to all VMs @@ -352,7 +302,7 @@ interactions: [],\r\n \"sourceAddressPrefixes\": [],\r\n \"destinationAddressPrefixes\": []\r\n }\r\n },\r\n {\r\n \"name\": \"AllowInternetOutBound\",\r\n \ \"id\": \"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clitest.rg000001/providers/Microsoft.Network/networkSecurityGroups/nsg000003/defaultSecurityRules/AllowInternetOutBound\",\r\n - \ \"etag\": \"W/\\\"5786d3a1-5002-4f01-a21c-cb423b01ecdf\\\"\",\r\n + \ \"etag\": \"W/\\\"d7517753-5803-4541-a0bb-4bc557c2c566\\\"\",\r\n \ \"type\": \"Microsoft.Network/networkSecurityGroups/defaultSecurityRules\",\r\n \ \"properties\": {\r\n \"provisioningState\": \"Succeeded\",\r\n \ \"description\": \"Allow outbound traffic from all VMs to Internet\",\r\n @@ -364,7 +314,7 @@ interactions: [],\r\n \"sourceAddressPrefixes\": [],\r\n \"destinationAddressPrefixes\": []\r\n }\r\n },\r\n {\r\n \"name\": \"DenyAllOutBound\",\r\n \ \"id\": \"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clitest.rg000001/providers/Microsoft.Network/networkSecurityGroups/nsg000003/defaultSecurityRules/DenyAllOutBound\",\r\n - \ \"etag\": \"W/\\\"5786d3a1-5002-4f01-a21c-cb423b01ecdf\\\"\",\r\n + \ \"etag\": \"W/\\\"d7517753-5803-4541-a0bb-4bc557c2c566\\\"\",\r\n \ \"type\": \"Microsoft.Network/networkSecurityGroups/defaultSecurityRules\",\r\n \ \"properties\": {\r\n \"provisioningState\": \"Succeeded\",\r\n \ \"description\": \"Deny all outbound traffic\",\r\n \"protocol\": @@ -383,9 +333,9 @@ interactions: content-type: - application/json; charset=utf-8 date: - - Tue, 07 Apr 2020 00:33:48 GMT + - Mon, 18 May 2020 07:34:30 GMT etag: - - W/"5786d3a1-5002-4f01-a21c-cb423b01ecdf" + - W/"d7517753-5803-4541-a0bb-4bc557c2c566" expires: - '-1' pragma: @@ -402,7 +352,177 @@ interactions: x-content-type-options: - nosniff x-ms-arm-service-request-id: - - 874679d5-b958-4f51-a666-895460d04e5e + - 916afa90-95c6-41f2-b0e0-960dccc660ff + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - monitor log-analytics workspace create + Connection: + - keep-alive + ParameterSetName: + - -g -n + User-Agent: + - python/3.8.0 (Windows-10-10.0.18362-SP0) msrest/0.6.10 msrest_azure/0.6.3 + azure-mgmt-resource/9.0.0 Azure-SDK-For-Python AZURECLI/2.6.0 + accept-language: + - en-US + method: GET + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/clitest.rg000001?api-version=2019-07-01 + response: + body: + string: '{"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clitest.rg000001","name":"clitest.rg000001","type":"Microsoft.Resources/resourceGroups","location":"southcentralus","tags":{"product":"azurecli","cause":"automation","date":"2020-05-18T07:33:43Z","StorageType":"Standard_LRS","type":"test"},"properties":{"provisioningState":"Succeeded"}}' + headers: + cache-control: + - no-cache + content-length: + - '479' + content-type: + - application/json; charset=utf-8 + date: + - Mon, 18 May 2020 07:34:33 GMT + expires: + - '-1' + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + vary: + - Accept-Encoding + x-content-type-options: + - nosniff + status: + code: 200 + message: OK +- request: + body: '{"location": "southcentralus", "properties": {"sku": {"name": "PerGB2018"}, + "retentionInDays": 30}}' + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - monitor log-analytics workspace create + Connection: + - keep-alive + Content-Length: + - '99' + Content-Type: + - application/json; charset=utf-8 + ParameterSetName: + - -g -n + User-Agent: + - python/3.8.0 (Windows-10-10.0.18362-SP0) msrest/0.6.10 msrest_azure/0.6.3 + azure-mgmt-loganalytics/0.5.0 Azure-SDK-For-Python AZURECLI/2.6.0 + accept-language: + - en-US + method: PUT + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/clitest.rg000001/providers/Microsoft.OperationalInsights/workspaces/ws000004?api-version=2020-03-01-preview + response: + body: + string: "{\r\n \"properties\": {\r\n \"source\": \"Azure\",\r\n \"customerId\": + \"00d2fcca-0068-478a-bc48-3402934588e5\",\r\n \"provisioningState\": \"Creating\",\r\n + \ \"sku\": {\r\n \"name\": \"pergb2018\",\r\n \"maxCapacityReservationLevel\": + 1000,\r\n \"lastSkuUpdate\": \"Mon, 18 May 2020 07:34:41 GMT\"\r\n },\r\n + \ \"retentionInDays\": 30,\r\n \"features\": {\r\n \"legacy\": 0,\r\n + \ \"searchVersion\": 1,\r\n \"enableLogAccessUsingOnlyResourcePermissions\": + true\r\n },\r\n \"workspaceCapping\": {\r\n \"dailyQuotaGb\": -1.0,\r\n + \ \"quotaNextResetTime\": \"Mon, 18 May 2020 18:00:00 GMT\",\r\n \"dataIngestionStatus\": + \"RespectQuota\"\r\n },\r\n \"publicNetworkAccessForIngestion\": \"Enabled\",\r\n + \ \"publicNetworkAccessForQuery\": \"Enabled\"\r\n },\r\n \"id\": \"/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/clitest.rg000001/providers/microsoft.operationalinsights/workspaces/ws000004\",\r\n + \ \"name\": \"ws000004\",\r\n \"type\": \"Microsoft.OperationalInsights/workspaces\",\r\n + \ \"location\": \"southcentralus\"\r\n}" + headers: + cache-control: + - no-cache + content-length: + - '1070' + content-type: + - application/json + date: + - Mon, 18 May 2020 07:34:42 GMT + pragma: + - no-cache + server: + - Microsoft-IIS/10.0 + - Microsoft-IIS/10.0 + strict-transport-security: + - max-age=31536000; includeSubDomains + x-content-type-options: + - nosniff + x-ms-ratelimit-remaining-subscription-writes: + - '1193' + x-powered-by: + - ASP.NET + - ASP.NET + status: + code: 201 + message: Created +- request: + body: null + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - monitor log-analytics workspace create + Connection: + - keep-alive + ParameterSetName: + - -g -n + User-Agent: + - python/3.8.0 (Windows-10-10.0.18362-SP0) msrest/0.6.10 msrest_azure/0.6.3 + azure-mgmt-loganalytics/0.5.0 Azure-SDK-For-Python AZURECLI/2.6.0 + method: GET + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/clitest.rg000001/providers/Microsoft.OperationalInsights/workspaces/ws000004?api-version=2020-03-01-preview + response: + body: + string: "{\r\n \"properties\": {\r\n \"source\": \"Azure\",\r\n \"customerId\": + \"00d2fcca-0068-478a-bc48-3402934588e5\",\r\n \"provisioningState\": \"Succeeded\",\r\n + \ \"sku\": {\r\n \"name\": \"pergb2018\",\r\n \"maxCapacityReservationLevel\": + 1000,\r\n \"lastSkuUpdate\": \"Mon, 18 May 2020 07:34:41 GMT\"\r\n },\r\n + \ \"retentionInDays\": 30,\r\n \"features\": {\r\n \"legacy\": 0,\r\n + \ \"searchVersion\": 1,\r\n \"enableLogAccessUsingOnlyResourcePermissions\": + true\r\n },\r\n \"workspaceCapping\": {\r\n \"dailyQuotaGb\": -1.0,\r\n + \ \"quotaNextResetTime\": \"Mon, 18 May 2020 18:00:00 GMT\",\r\n \"dataIngestionStatus\": + \"RespectQuota\"\r\n },\r\n \"publicNetworkAccessForIngestion\": \"Enabled\",\r\n + \ \"publicNetworkAccessForQuery\": \"Enabled\"\r\n },\r\n \"id\": \"/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/clitest.rg000001/providers/microsoft.operationalinsights/workspaces/ws000004\",\r\n + \ \"name\": \"ws000004\",\r\n \"type\": \"Microsoft.OperationalInsights/workspaces\",\r\n + \ \"location\": \"southcentralus\"\r\n}" + headers: + cache-control: + - no-cache + content-length: + - '1071' + content-type: + - application/json + date: + - Mon, 18 May 2020 07:35:14 GMT + pragma: + - no-cache + server: + - Microsoft-IIS/10.0 + - Microsoft-IIS/10.0 + strict-transport-security: + - max-age=31536000; includeSubDomains + transfer-encoding: + - chunked + vary: + - Accept-Encoding + x-content-type-options: + - nosniff + x-powered-by: + - ASP.NET + - ASP.NET status: code: 200 message: OK @@ -420,8 +540,8 @@ interactions: ParameterSetName: - -g --resource-type --resource User-Agent: - - python/3.7.4 (Windows-10-10.0.18362-SP0) msrest/0.6.9 msrest_azure/0.6.3 azure-mgmt-monitor/0.7.0 - Azure-SDK-For-Python AZURECLI/2.3.1 + - python/3.8.0 (Windows-10-10.0.18362-SP0) msrest/0.6.10 msrest_azure/0.6.3 + azure-mgmt-monitor/0.9.0 Azure-SDK-For-Python AZURECLI/2.6.0 accept-language: - en-US method: GET @@ -437,7 +557,7 @@ interactions: content-type: - application/json; charset=utf-8 date: - - Tue, 07 Apr 2020 00:33:51 GMT + - Mon, 18 May 2020 07:35:18 GMT expires: - '-1' pragma: @@ -476,8 +596,8 @@ interactions: ParameterSetName: - -n --resource --resource-type --resource-group --storage-account --log -o User-Agent: - - python/3.7.4 (Windows-10-10.0.18362-SP0) msrest/0.6.9 msrest_azure/0.6.3 azure-mgmt-monitor/0.7.0 - Azure-SDK-For-Python AZURECLI/2.3.1 + - python/3.8.0 (Windows-10-10.0.18362-SP0) msrest/0.6.10 msrest_azure/0.6.3 + azure-mgmt-monitor/0.9.0 Azure-SDK-For-Python AZURECLI/2.6.0 accept-language: - en-US method: PUT @@ -493,7 +613,7 @@ interactions: content-type: - application/json; charset=utf-8 date: - - Tue, 07 Apr 2020 00:33:57 GMT + - Mon, 18 May 2020 07:35:24 GMT expires: - '-1' pragma: @@ -527,8 +647,8 @@ interactions: ParameterSetName: - --resource --resource-type --resource-group -o User-Agent: - - python/3.7.4 (Windows-10-10.0.18362-SP0) msrest/0.6.9 msrest_azure/0.6.3 azure-mgmt-monitor/0.7.0 - Azure-SDK-For-Python AZURECLI/2.3.1 + - python/3.8.0 (Windows-10-10.0.18362-SP0) msrest/0.6.10 msrest_azure/0.6.3 + azure-mgmt-monitor/0.9.0 Azure-SDK-For-Python AZURECLI/2.6.0 accept-language: - en-US method: GET @@ -544,7 +664,7 @@ interactions: content-type: - application/json; charset=utf-8 date: - - Tue, 07 Apr 2020 00:34:01 GMT + - Mon, 18 May 2020 07:35:28 GMT expires: - '-1' pragma: @@ -576,8 +696,8 @@ interactions: ParameterSetName: - -n --resource --resource-type --resource-group -o User-Agent: - - python/3.7.4 (Windows-10-10.0.18362-SP0) msrest/0.6.9 msrest_azure/0.6.3 azure-mgmt-monitor/0.7.0 - Azure-SDK-For-Python AZURECLI/2.3.1 + - python/3.8.0 (Windows-10-10.0.18362-SP0) msrest/0.6.10 msrest_azure/0.6.3 + azure-mgmt-monitor/0.9.0 Azure-SDK-For-Python AZURECLI/2.6.0 accept-language: - en-US method: GET @@ -593,7 +713,7 @@ interactions: content-type: - application/json; charset=utf-8 date: - - Tue, 07 Apr 2020 00:34:05 GMT + - Mon, 18 May 2020 07:35:31 GMT expires: - '-1' pragma: @@ -627,8 +747,8 @@ interactions: ParameterSetName: - -n --resource --resource-type --resource-group -o User-Agent: - - python/3.7.4 (Windows-10-10.0.18362-SP0) msrest/0.6.9 msrest_azure/0.6.3 azure-mgmt-monitor/0.7.0 - Azure-SDK-For-Python AZURECLI/2.3.1 + - python/3.8.0 (Windows-10-10.0.18362-SP0) msrest/0.6.10 msrest_azure/0.6.3 + azure-mgmt-monitor/0.9.0 Azure-SDK-For-Python AZURECLI/2.6.0 accept-language: - en-US method: DELETE @@ -642,7 +762,7 @@ interactions: content-length: - '0' date: - - Tue, 07 Apr 2020 00:34:11 GMT + - Mon, 18 May 2020 07:35:34 GMT expires: - '-1' pragma: @@ -654,7 +774,7 @@ interactions: x-content-type-options: - nosniff x-ms-ratelimit-remaining-subscription-deletes: - - '14997' + - '14995' status: code: 200 message: OK @@ -672,8 +792,8 @@ interactions: ParameterSetName: - --resource --resource-type --resource-group -o User-Agent: - - python/3.7.4 (Windows-10-10.0.18362-SP0) msrest/0.6.9 msrest_azure/0.6.3 azure-mgmt-monitor/0.7.0 - Azure-SDK-For-Python AZURECLI/2.3.1 + - python/3.8.0 (Windows-10-10.0.18362-SP0) msrest/0.6.10 msrest_azure/0.6.3 + azure-mgmt-monitor/0.9.0 Azure-SDK-For-Python AZURECLI/2.6.0 accept-language: - en-US method: GET @@ -689,7 +809,7 @@ interactions: content-type: - application/json; charset=utf-8 date: - - Tue, 07 Apr 2020 00:34:14 GMT + - Mon, 18 May 2020 07:35:38 GMT expires: - '-1' pragma: @@ -707,4 +827,64 @@ interactions: status: code: 200 message: OK +- request: + body: 'b''{"properties": {"logs": [{"category": "NetworkSecurityGroupEvent", "enabled": + true, "retentionPolicy": {"enabled": false, "days": 0}}, {"category": "NetworkSecurityGroupRuleCounter", + "enabled": true, "retentionPolicy": {"enabled": false, "days": 0}}], "workspaceId": + "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clitest.rg000001/providers/microsoft.OperationalInsights/workspaces/ws000004", + "logAnalyticsDestinationType": "Dedicated"}}''' + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - monitor diagnostic-settings create + Connection: + - keep-alive + Content-Length: + - '525' + Content-Type: + - application/json; charset=utf-8 + ParameterSetName: + - -n --resource --resource-type --resource-group --workspace --export-to-specific-resource + --log -o + User-Agent: + - python/3.8.0 (Windows-10-10.0.18362-SP0) msrest/0.6.10 msrest_azure/0.6.3 + azure-mgmt-monitor/0.9.0 Azure-SDK-For-Python AZURECLI/2.6.0 + accept-language: + - en-US + method: PUT + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clitest.rg000001/providers/Microsoft.Network/networkSecurityGroups/nsg000003/providers/microsoft.insights/diagnosticSettings/test02?api-version=2017-05-01-preview + response: + body: + string: '{"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/clitest.rg000001/providers/microsoft.network/networksecuritygroups/nsg000003/providers/microsoft.insights/diagnosticSettings/test02","type":null,"name":"test02","location":null,"kind":null,"tags":null,"properties":{"storageAccountId":null,"serviceBusRuleId":null,"workspaceId":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clitest.rg000001/providers/microsoft.OperationalInsights/workspaces/ws000004","eventHubAuthorizationRuleId":null,"eventHubName":null,"metrics":[],"logs":[{"category":"NetworkSecurityGroupEvent","enabled":true,"retentionPolicy":{"enabled":false,"days":0}},{"category":"NetworkSecurityGroupRuleCounter","enabled":true,"retentionPolicy":{"enabled":false,"days":0}}],"logAnalyticsDestinationType":"Dedicated"},"identity":null}' + headers: + cache-control: + - no-cache + content-length: + - '974' + content-type: + - application/json; charset=utf-8 + date: + - Mon, 18 May 2020 07:35:42 GMT + expires: + - '-1' + pragma: + - no-cache + server: + - Microsoft-IIS/10.0 + strict-transport-security: + - max-age=31536000; includeSubDomains + transfer-encoding: + - chunked + vary: + - Accept-Encoding + x-content-type-options: + - nosniff + x-ms-ratelimit-remaining-subscription-resource-requests: + - '149' + status: + code: 200 + message: OK version: 1 diff --git a/src/azure-cli/azure/cli/command_modules/monitor/tests/latest/test_monitor_diagnostic_settings.py b/src/azure-cli/azure/cli/command_modules/monitor/tests/latest/test_monitor_diagnostic_settings.py index 51f27b9a8ad..6bba9565ec2 100644 --- a/src/azure-cli/azure/cli/command_modules/monitor/tests/latest/test_monitor_diagnostic_settings.py +++ b/src/azure-cli/azure/cli/command_modules/monitor/tests/latest/test_monitor_diagnostic_settings.py @@ -13,9 +13,11 @@ class TestMonitorDiagnosticSettings(ScenarioTest): def test_monitor_diagnostic_settings_scenario(self, resource_group, storage_account): self.kwargs.update({ - 'nsg': self.create_random_name(prefix='nsg', length=16) + 'nsg': self.create_random_name(prefix='nsg', length=16), + 'ws': self.create_random_name(prefix='ws', length=16) }) self.cmd('network nsg create -n {nsg} -g {rg}') + self.cmd('monitor log-analytics workspace create -g {rg} -n {ws}') self.cmd('monitor diagnostic-settings categories list -g {rg} --resource-type Microsoft.Network/networkSecurityGroups --resource {nsg}', checks=[ self.check('length(value)', 2) @@ -50,6 +52,12 @@ def test_monitor_diagnostic_settings_scenario(self, resource_group, storage_acco self.cmd('monitor diagnostic-settings list --resource {nsg} --resource-type Microsoft.Network/networkSecurityGroups --resource-group {rg} -o json', checks=self.check('length(value)', 0)) + self.cmd('monitor diagnostic-settings create -n test02 --resource {nsg} --resource-type Microsoft.Network/networkSecurityGroups --resource-group {rg} --workspace {ws} --export-to-specific-resource --log \'{log_config}\' -o json', + checks=[ + self.check('name', 'test02'), + self.check('logAnalyticsDestinationType', 'Dedicated') + ]) + if __name__ == '__main__': import unittest