diff --git a/.gitignore b/.gitignore index 1c235329480..7af160a1183 100644 --- a/.gitignore +++ b/.gitignore @@ -116,3 +116,4 @@ pip.log *.exe az_command_coverage.txt + diff --git a/src/azure-cli/azure/cli/command_modules/synapse/_client_factory.py b/src/azure-cli/azure/cli/command_modules/synapse/_client_factory.py index 7ebcd9bce4f..b0344696270 100644 --- a/src/azure-cli/azure/cli/command_modules/synapse/_client_factory.py +++ b/src/azure-cli/azure/cli/command_modules/synapse/_client_factory.py @@ -210,3 +210,23 @@ def cf_synapse_notebook(cli_ctx, workspace_name): def cf_synapse_spark_pool(cli_ctx, workspace_name): return cf_synapse_client_artifacts_factory(cli_ctx, workspace_name).big_data_pools + + +def cf_synapse_client_managedprivateendpoints_factory(cli_ctx, workspace_name): + from azure.synapse.managedprivateendpoints import ManagedPrivateEndpointsClient + from azure.cli.core._profile import Profile + from azure.cli.core.commands.client_factory import get_subscription_id + subscription_id = get_subscription_id(cli_ctx) + profile = Profile(cli_ctx=cli_ctx) + cred, _, _ = profile.get_login_credentials( + resource=cli_ctx.cloud.endpoints.synapse_analytics_resource_id, + subscription_id=subscription_id + ) + return ManagedPrivateEndpointsClient( + credential=cred, + endpoint='{}{}{}'.format("https://", workspace_name, cli_ctx.cloud.suffixes.synapse_analytics_endpoint) + ) + + +def cf_synapse_managedprivateendpoints_factory(cli_ctx, workspace_name): + return cf_synapse_client_managedprivateendpoints_factory(cli_ctx, workspace_name).managed_private_endpoints diff --git a/src/azure-cli/azure/cli/command_modules/synapse/_help.py b/src/azure-cli/azure/cli/command_modules/synapse/_help.py index 014a84de752..1daf9f53841 100644 --- a/src/azure-cli/azure/cli/command_modules/synapse/_help.py +++ b/src/azure-cli/azure/cli/command_modules/synapse/_help.py @@ -1678,3 +1678,49 @@ az synapse integration-runtime-node get-ip-address --workspace-name testsynapseworkspace --resource-group rg \\ --name selfhostedintegrationruntime --node-name testnode """ + +helps['synapse managed-private-endpoints'] = """ +type: group +short-summary: Manage synapse managed private endpoints. +""" + +helps['synapse managed-private-endpoints show'] = """ +type: command +short-summary: Get a synapse managed private endpoints. +examples: + - name: Get a synapse managed private endpoints. + text: |- + az synapse managed-private-endpoints show --workspace-name testsynapseworkspace \\ + --pe-name testendpointname +""" + +helps['synapse managed-private-endpoints create'] = """ +type: command +short-summary: Create a synapse managed private endpoints. +examples: + - name: Create a synapse managed private endpoints. + text: |- + az synapse managed-private-endpoints create --workspace-name testsynapseworkspace \\ + --pe-name testendpointname \\ + --resource-id '/subscriptions/yoursub/resourceGroups/myResourceGroup/providers/Microsoft.Storage/accounts/myStorageAccount' \\ + --group-Id blob +""" + +helps['synapse managed-private-endpoints list'] = """ +type: command +short-summary: List synapse managed private endpoints in a workspace. +examples: + - name: List a synapse managed private endpoints. + text: |- + az synapse managed-private-endpoints list --workspace-name testsynapseworkspace +""" + +helps['synapse managed-private-endpoints delete'] = """ +type: command +short-summary: delete synapse managed private endpoints in a workspace. +examples: + - name: Delete a synapse managed private endpoints. + text: |- + az synapse managed-private-endpoints delete --workspace-name testsynapseworkspace \\ + --pe-name testendpointname +""" diff --git a/src/azure-cli/azure/cli/command_modules/synapse/_params.py b/src/azure-cli/azure/cli/command_modules/synapse/_params.py index 160a65cc78e..b7d1e8b4f2e 100644 --- a/src/azure-cli/azure/cli/command_modules/synapse/_params.py +++ b/src/azure-cli/azure/cli/command_modules/synapse/_params.py @@ -732,3 +732,16 @@ def load_arguments(self, _): help='Enable or disable the self-hosted integration runtime auto-update.') c.argument('update_delay_offset', help='The time of the day for the self-hosted integration runtime auto-update.') + + # synapse managed private endpoints + for scope in ['show', 'create', 'delete']: + with self.argument_context('synapse managed-private-endpoints ' + scope) as c: + c.argument('workspace_name', arg_type=workspace_name_arg_type, id_part='name') + c.argument('managed_private_endpoint_name', options_list=['--pe-name'], help='The managed private endpoint name.') + + with self.argument_context('synapse managed-private-endpoints list') as c: + c.argument('workspace_name', arg_type=workspace_name_arg_type) + + with self.argument_context('synapse managed-private-endpoints create') as c: + c.argument('private_Link_Resource_Id', options_list=['--resource-id'], help='The ARM resource ID of the resource to which the managed private endpoint is created. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}') + c.argument('group_Id', help='The groupId to which the managed private endpoint is created') diff --git a/src/azure-cli/azure/cli/command_modules/synapse/commands.py b/src/azure-cli/azure/cli/command_modules/synapse/commands.py index 8cb2150d346..9840e98d104 100644 --- a/src/azure-cli/azure/cli/command_modules/synapse/commands.py +++ b/src/azure-cli/azure/cli/command_modules/synapse/commands.py @@ -179,6 +179,10 @@ def get_custom_sdk(custom_module, client_factory): operation_tmpl='azure.synapse.artifacts.operations#NotebookOperations.{}', client_factory=None) + synapse_managed_private_endpoints_sdk = CliCommandType( + operations_tmpl='azure.synapse.managedprivateendpoints.operations#ManagedPrivateEndpoints.{}', + client_factory=None) + # Management Plane Commands --Workspace with self.command_group('synapse workspace', command_type=synapse_workspace_sdk, custom_command_type=get_custom_sdk('workspace', cf_synapse_client_workspace_factory), @@ -478,5 +482,13 @@ def get_custom_sdk(custom_module, client_factory): g.custom_command('export', 'export_notebook') g.custom_command('delete', 'delete_notebook', confirmation=True, supports_no_wait=True) + # Data Plane Commands --Managed private endpoints operations + with self.command_group('synapse managed-private-endpoints', synapse_managed_private_endpoints_sdk, + custom_command_type=get_custom_sdk('managedprivateendpoints', None)) as g: + g.custom_show_command('show', 'get_Managed_private_endpoints') + g.custom_command('create', 'create_Managed_private_endpoints') + g.custom_command('list', 'list_Managed_private_endpoints') + g.custom_command('delete', 'delete_Managed_private_endpoints', confirmation=True) + with self.command_group('synapse', is_preview=True): pass diff --git a/src/azure-cli/azure/cli/command_modules/synapse/operations/managedprivateendpoints.py b/src/azure-cli/azure/cli/command_modules/synapse/operations/managedprivateendpoints.py new file mode 100644 index 00000000000..a76188ea2d2 --- /dev/null +++ b/src/azure-cli/azure/cli/command_modules/synapse/operations/managedprivateendpoints.py @@ -0,0 +1,36 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# -------------------------------------------------------------------------------------------- +# pylint: disable=line-too-long, too-many-statements, too-many-locals +from azure.cli.core.util import sdk_no_wait +from .._client_factory import cf_synapse_managedprivateendpoints_factory + + +def create_Managed_private_endpoints(cmd, workspace_name, managed_private_endpoint_name, private_Link_Resource_Id, group_Id, no_wait=False): + client = cf_synapse_managedprivateendpoints_factory(cmd.cli_ctx, workspace_name) + property_files = {} + property_files['privateLinkResourceId'] = private_Link_Resource_Id + property_files['groupId'] = group_Id + properties = property_files + managed_virtual_network_name = "default" + return sdk_no_wait(no_wait, client.create, + managed_private_endpoint_name, managed_virtual_network_name, properties) + + +def get_Managed_private_endpoints(cmd, workspace_name, managed_private_endpoint_name): + client = cf_synapse_managedprivateendpoints_factory(cmd.cli_ctx, workspace_name) + managed_virtual_network_name = "default" + return client.get(managed_private_endpoint_name, managed_virtual_network_name) + + +def list_Managed_private_endpoints(cmd, workspace_name): + client = cf_synapse_managedprivateendpoints_factory(cmd.cli_ctx, workspace_name) + managed_virtual_network_name = "default" + return client.list(managed_virtual_network_name) + + +def delete_Managed_private_endpoints(cmd, workspace_name, managed_private_endpoint_name, no_wait=False): + client = cf_synapse_managedprivateendpoints_factory(cmd.cli_ctx, workspace_name) + managed_virtual_network_name = "default" + return sdk_no_wait(no_wait, client.delete, managed_private_endpoint_name, managed_virtual_network_name) diff --git a/src/azure-cli/azure/cli/command_modules/synapse/tests/latest/recordings/test_managed_private_endpoints.yaml b/src/azure-cli/azure/cli/command_modules/synapse/tests/latest/recordings/test_managed_private_endpoints.yaml new file mode 100644 index 00000000000..f66bb009ecb --- /dev/null +++ b/src/azure-cli/azure/cli/command_modules/synapse/tests/latest/recordings/test_managed_private_endpoints.yaml @@ -0,0 +1,196 @@ +interactions: +- request: + body: '{"properties": {"privateLinkResourceId": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/bigdataqa/providers/Microsoft.Storage/storageAccounts/hozhao0917gen2", + "groupId": "dfs"}}' + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Content-Length: + - '198' + Content-Type: + - application/json + User-Agent: + - azsdk-python-synapse-managedprivateendpoints/0.3.0 Python/3.6.4 (Windows-10-10.0.19041-SP0) + method: PUT + uri: https://testsynapseworkspacepe.dev.azuresynapse.net/managedVirtualNetworks/default/managedPrivateEndpoints/AzureDataLakeStoragePE?api-version=2019-06-01-preview + response: + body: + string: '{"name":"AzureDataLakeStoragePE","id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/bigdataqa/providers/Microsoft.Synapse/workspaces/testsynapseworkspacepe/managedVirtualNetworks/default/managedPrivateEndpoints/AzureDataLakeStoragePE","type":"Microsoft.Synapse/workspaces/managedVirtualNetworks/managedPrivateEndpoints","properties":{"privateLinkResourceId":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/bigdataqa/providers/Microsoft.Storage/storageAccounts/hozhao0917gen2","groupId":"dfs","provisioningState":"Provisioning","connectionState":{},"isReserved":false,"fqdns":[],"isCompliant":true}}' + headers: + access-control-allow-headers: + - Location + access-control-expose-headers: + - Location + content-length: + - '640' + content-type: + - application/json; charset=utf-8 + date: + - Thu, 05 Aug 2021 07:33:58 GMT + location: + - https://testsynapseworkspacepe.dev.azuresynapse.net/managedVirtualNetworks/default/managedPrivateEndpoints/AzureDataLakeStoragePE?api-version=2019-06-01-preview + server: + - Microsoft-HTTPAPI/2.0 + strict-transport-security: + - max-age=31536000; includeSubDomains + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + User-Agent: + - azsdk-python-synapse-managedprivateendpoints/0.3.0 Python/3.6.4 (Windows-10-10.0.19041-SP0) + method: GET + uri: https://testsynapseworkspacepe.dev.azuresynapse.net/managedVirtualNetworks/default/managedPrivateEndpoints/AzureDataLakeStoragePE?api-version=2019-06-01-preview + response: + body: + string: '{"name":"AzureDataLakeStoragePE","id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/bigdataqa/providers/Microsoft.Synapse/workspaces/testsynapseworkspacepe/managedVirtualNetworks/default/managedPrivateEndpoints/AzureDataLakeStoragePE","type":"Microsoft.Synapse/workspaces/managedVirtualNetworks/managedPrivateEndpoints","properties":{"privateLinkResourceId":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/bigdataqa/providers/Microsoft.Storage/storageAccounts/hozhao0917gen2","groupId":"dfs","provisioningState":"Succeeded","connectionState":{"status":"Pending","description":"","actionsRequired":"None"},"isReserved":false,"fqdns":[],"isCompliant":true}}' + headers: + content-length: + - '697' + content-type: + - application/json; charset=utf-8 + date: + - Thu, 05 Aug 2021 07:35:30 GMT + server: + - Microsoft-HTTPAPI/2.0 + strict-transport-security: + - max-age=31536000; includeSubDomains + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + User-Agent: + - azsdk-python-synapse-managedprivateendpoints/0.3.0 Python/3.6.4 (Windows-10-10.0.19041-SP0) + method: GET + uri: https://testsynapseworkspacepe.dev.azuresynapse.net/managedVirtualNetworks/default/managedPrivateEndpoints?api-version=2019-06-01-preview + response: + body: + string: '{"value":[{"name":"AzureDataLakeStoragePE","id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/bigdataqa/providers/Microsoft.Synapse/workspaces/testsynapseworkspacepe/managedVirtualNetworks/default/managedPrivateEndpoints/AzureDataLakeStoragePE","type":"Microsoft.Synapse/workspaces/managedVirtualNetworks/managedPrivateEndpoints","properties":{"privateLinkResourceId":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/bigdataqa/providers/Microsoft.Storage/storageAccounts/hozhao0917gen2","groupId":"dfs","provisioningState":"Succeeded","connectionState":{"status":"Pending","description":"","actionsRequired":"None"},"isReserved":false,"fqdns":[],"isCompliant":true}},{"name":"synapse-ws-sqlOnDemand--testsynapseworkspacepe","id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/bigdataqa/providers/Microsoft.Synapse/workspaces/testsynapseworkspacepe/managedVirtualNetworks/default/managedPrivateEndpoints/synapse-ws-sqlOnDemand--testsynapseworkspacepe","type":"Microsoft.Synapse/workspaces/managedVirtualNetworks/managedPrivateEndpoints","properties":{"privateLinkResourceId":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/bigdataqa/providers/Microsoft.Synapse/workspaces/testsynapseworkspacepe","groupId":"sqlOnDemand","provisioningState":"Succeeded","connectionState":{"status":"Approved","description":"Approved + by Microsoft.Synapse Resource Provider","actionsRequired":""},"isReserved":true,"fqdns":["testsynapseworkspacepe-ondemand.1e9ee269-bc80-4cf5-b6f5-4a11573722c0.sql.azuresynapse.net"],"isCompliant":true}},{"name":"synapse-ws-sql--testsynapseworkspacepe","id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/bigdataqa/providers/Microsoft.Synapse/workspaces/testsynapseworkspacepe/managedVirtualNetworks/default/managedPrivateEndpoints/synapse-ws-sql--testsynapseworkspacepe","type":"Microsoft.Synapse/workspaces/managedVirtualNetworks/managedPrivateEndpoints","properties":{"privateLinkResourceId":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/bigdataqa/providers/Microsoft.Synapse/workspaces/testsynapseworkspacepe","groupId":"sql","provisioningState":"Succeeded","connectionState":{"status":"Approved","description":"Approved + by Microsoft.Synapse Resource Provider","actionsRequired":""},"isReserved":true,"fqdns":["testsynapseworkspacepe.1e9ee269-bc80-4cf5-b6f5-4a11573722c0.sql.azuresynapse.net"],"isCompliant":true}}]}' + headers: + content-length: + - '2458' + content-type: + - application/json; charset=utf-8 + date: + - Thu, 05 Aug 2021 07:35:31 GMT + server: + - Microsoft-HTTPAPI/2.0 + strict-transport-security: + - max-age=31536000; includeSubDomains + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Content-Length: + - '0' + User-Agent: + - azsdk-python-synapse-managedprivateendpoints/0.3.0 Python/3.6.4 (Windows-10-10.0.19041-SP0) + method: DELETE + uri: https://testsynapseworkspacepe.dev.azuresynapse.net/managedVirtualNetworks/default/managedPrivateEndpoints/AzureDataLakeStoragePE?api-version=2019-06-01-preview + response: + body: + string: '' + headers: + content-length: + - '0' + date: + - Thu, 05 Aug 2021 07:35:32 GMT + server: + - Microsoft-HTTPAPI/2.0 + strict-transport-security: + - max-age=31536000; includeSubDomains + status: + code: 202 + message: Accepted +- request: + body: null + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + User-Agent: + - azsdk-python-synapse-managedprivateendpoints/0.3.0 Python/3.6.4 (Windows-10-10.0.19041-SP0) + method: GET + uri: https://testsynapseworkspacepe.dev.azuresynapse.net/managedVirtualNetworks/default/managedPrivateEndpoints/AzureDataLakeStoragePE?api-version=2019-06-01-preview + response: + body: + string: '{"error":{"code":"UnknownError","message":"{\"CorrelationId\":\"\",\"StatusCode\":404,\"Message\":\"Resource + not found: Message=PrivateEndpoint has been deleted: ClientId=a3e71284-e705-4538-86f6-6c04f9d5badf, + ReferenceName=AzureDataLakeStoragePE, Cluster: .\",\"ExceptionDetail\":\"Microsoft.Analytics.Clusters.Common.NetworkServiceException: + PrivateEndpoint has been deleted: ClientId=a3e71284-e705-4538-86f6-6c04f9d5badf, + ReferenceName=AzureDataLakeStoragePE, Cluster: .\\r\\n at Microsoft.Analytics.Clusters.Services.NetworkService.NetworkServiceImpl.GetPrivateEndpointAsync(String + clientId, String referenceName, AbstractMetadataContext dbContext) in C:\\\\source\\\\Services\\\\NetworkService\\\\Service\\\\NetworkServiceImpl.cs:line + 4089\\r\\n at Microsoft.Analytics.Clusters.Services.NetworkService.StatefulBE.Controllers.NetworkController.GetPrivateEndpointAsync(String + clientId, String referenceName) in C:\\\\source\\\\Services\\\\NetworkService\\\\NetworkServiceBE\\\\Controllers\\\\NetworkController.cs:line + 263\\r\\n at lambda_method(Closure , Object )\\r\\n at Microsoft.AspNetCore.Mvc.Infrastructure.ActionMethodExecutor.AwaitableObjectResultExecutor.Execute(IActionResultTypeMapper + mapper, ObjectMethodExecutor executor, Object controller, Object[] arguments)\\r\\n at + Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.g__Awaited|12_0(ControllerActionInvoker + invoker, ValueTask`1 actionResultValueTask)\\r\\n at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.g__Awaited|10_0(ControllerActionInvoker + invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)\\r\\n at + Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Rethrow(ActionExecutedContextSealed + context)\\r\\n at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Next(State& + next, Scope& scope, Object& state, Boolean& isCompleted)\\r\\n at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.InvokeInnerFilterAsync()\\r\\n--- + End of stack trace from previous location where exception was thrown ---\\r\\n at + Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.g__Awaited|24_0(ResourceInvoker + invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)\\r\\n at + Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Rethrow(ResourceExecutedContextSealed + context)\\r\\n at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Next(State& + next, Scope& scope, Object& state, Boolean& isCompleted)\\r\\n at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.InvokeFilterPipelineAsync()\\r\\n--- + End of stack trace from previous location where exception was thrown ---\\r\\n at + Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.g__Awaited|17_0(ResourceInvoker + invoker, Task task, IDisposable scope)\\r\\n at Microsoft.AspNetCore.Builder.RouterMiddleware.Invoke(HttpContext + httpContext)\\r\\n at Microsoft.Analytics.Clusters.Services.NetworkService.StatefulBE.ActivePartitionInstanceMiddleware.InvokeAsync(HttpContext + context) in C:\\\\source\\\\Services\\\\NetworkService\\\\NetworkServiceBE\\\\ActivePartitionInstanceMiddleware.cs:line + 90\\r\\n at Microsoft.Analytics.Clusters.Common.Web.ServiceFabricResourceNotFoundMiddleware.InvokeAsync(HttpContext + httpContext) in C:\\\\source\\\\Shared\\\\Web\\\\ServiceFabricResourceNotFoundMiddleware.cs:line + 50\\r\\n at Microsoft.Analytics.Clusters.Common.Web.ExceptionMiddleware.InvokeAsync(HttpContext + httpContext) in C:\\\\source\\\\Shared\\\\Web\\\\ExceptionMiddleware.cs:line + 54\",\"ErrorType\":\"PrivateEndpointNotFound\",\"ErrorNumber\":2145,\"ErrorOn\":\"2021-08-05T07:36:33.5377226+00:00\"}"}}' + headers: + content-length: + - '3782' + content-type: + - application/json; charset=utf-8 + date: + - Thu, 05 Aug 2021 07:36:33 GMT + server: + - Microsoft-HTTPAPI/2.0 + strict-transport-security: + - max-age=31536000; includeSubDomains + status: + code: 404 + message: Not Found +version: 1 diff --git a/src/azure-cli/azure/cli/command_modules/synapse/tests/latest/test_synapse_scenario.py b/src/azure-cli/azure/cli/command_modules/synapse/tests/latest/test_synapse_scenario.py index ee32b47c833..6261505909f 100644 --- a/src/azure-cli/azure/cli/command_modules/synapse/tests/latest/test_synapse_scenario.py +++ b/src/azure-cli/azure/cli/command_modules/synapse/tests/latest/test_synapse_scenario.py @@ -1362,3 +1362,47 @@ def test_integration_runtime(self): checks=[ self.check('name', self.kwargs['selfhosted-integration-runtime']) ]) + + @record_only() + @ResourceGroupPreparer(name_prefix='synapse-cli', random_name_length=16) + def test_managed_private_endpoints(self): + self.kwargs.update({ + 'workspace': 'testsynapseworkspacepe', + 'name': 'AzureDataLakeStoragePE', + 'privateLinkResourceId': '/subscriptions/051ddeca-1ed6-4d8b-ba6f-1ff561e5f3b3/resourceGroups/bigdataqa/providers/Microsoft.Storage/storageAccounts/hozhao0917gen2', + 'groupId': 'dfs'}) + + # create managed private endpoint + self.cmd( + 'az synapse managed-private-endpoints create --workspace-name {workspace} --pe-name {name} --resource-id {privateLinkResourceId} --group-Id {groupId}', + checks=[ + self.check('name', self.kwargs['name']) + ]) + + # wait some time to improve robustness + if self.is_live or self.in_recording: + import time + time.sleep(90) + # get managed private endpoint + self.cmd( + 'az synapse managed-private-endpoints show --workspace-name {workspace} --pe-name {name}', + checks=[ + self.check('name', self.kwargs['name']) + ]) + + # list managed private endpoint + self.cmd( + 'az synapse managed-private-endpoints list --workspace-name {workspace}', + checks=[ + self.check('[0].type', 'Microsoft.Synapse/workspaces/managedVirtualNetworks/managedPrivateEndpoints') + ]) + + # delete managed private endpoint + self.cmd( + 'az synapse managed-private-endpoints delete --workspace-name {workspace} --pe-name {name} -y') + if self.is_live or self.in_recording: + import time + time.sleep(60) + self.cmd( + 'az synapse managed-private-endpoints show --workspace-name {workspace} --pe-name {name}', + expect_failure=True) \ No newline at end of file diff --git a/src/azure-cli/requirements.py3.Darwin.txt b/src/azure-cli/requirements.py3.Darwin.txt index 48e1662a837..a76167e63cf 100644 --- a/src/azure-cli/requirements.py3.Darwin.txt +++ b/src/azure-cli/requirements.py3.Darwin.txt @@ -91,6 +91,7 @@ azure-storage-common==1.4.2 azure-synapse-accesscontrol==0.5.0 azure-synapse-artifacts==0.6.0 azure-synapse-spark==0.2.0 +azure-synapse-managedprivateendpoints==0.3.0 bcrypt==3.2.0 certifi==2019.6.16 cffi==1.14.4 diff --git a/src/azure-cli/requirements.py3.Linux.txt b/src/azure-cli/requirements.py3.Linux.txt index 960a1ad2e7a..b7f98554d14 100644 --- a/src/azure-cli/requirements.py3.Linux.txt +++ b/src/azure-cli/requirements.py3.Linux.txt @@ -91,6 +91,7 @@ azure-storage-common==1.4.2 azure-synapse-accesscontrol==0.5.0 azure-synapse-artifacts==0.6.0 azure-synapse-spark==0.2.0 +azure-synapse-managedprivateendpoints==0.3.0 bcrypt==3.2.0 certifi==2019.6.16 cffi==1.14.4 diff --git a/src/azure-cli/requirements.py3.windows.txt b/src/azure-cli/requirements.py3.windows.txt index 1d4360e6f66..be802a7966c 100644 --- a/src/azure-cli/requirements.py3.windows.txt +++ b/src/azure-cli/requirements.py3.windows.txt @@ -91,6 +91,7 @@ azure-storage-common==1.4.2 azure-synapse-accesscontrol==0.5.0 azure-synapse-artifacts==0.6.0 azure-synapse-spark==0.2.0 +azure-synapse-managedprivateendpoints==0.3.0 bcrypt==3.2.0 certifi==2019.6.16 cffi==1.14.4 diff --git a/src/azure-cli/setup.py b/src/azure-cli/setup.py index 99e09cb05c4..9230d52a2c0 100644 --- a/src/azure-cli/setup.py +++ b/src/azure-cli/setup.py @@ -134,6 +134,7 @@ 'azure-synapse-accesscontrol~=0.5.0', 'azure-synapse-artifacts~=0.6.0', 'azure-synapse-spark~=0.2.0', + 'azure-synapse-managedprivateendpoints~=0.3.0', 'fabric~=2.4', 'javaproperties==0.5.1', 'jsmin~=2.2.2',