diff --git a/src/azure-cli/azure/cli/command_modules/network/private_link_resource_and_endpoint_connections/custom.py b/src/azure-cli/azure/cli/command_modules/network/private_link_resource_and_endpoint_connections/custom.py index bafde5a4ab3..a035c589247 100644 --- a/src/azure-cli/azure/cli/command_modules/network/private_link_resource_and_endpoint_connections/custom.py +++ b/src/azure-cli/azure/cli/command_modules/network/private_link_resource_and_endpoint_connections/custom.py @@ -85,6 +85,7 @@ def register_providers(): _register_one_provider('Microsoft.DBforPostgreSQL/flexibleServers', '2023-06-01-preview', False) _register_one_provider('Microsoft.App/managedEnvironments', '2024-02-02-preview', True) _register_one_provider('Microsoft.FluidRelay/fluidRelayServers', '2025-03-10-preview', True) + _register_one_provider('Microsoft.VideoIndexer/accounts', '2025-04-01', True) def _register_one_provider(provider, api_version, support_list_or_not, resource_get_api_version=None, support_connection_operation=True): # pylint: disable=line-too-long diff --git a/src/azure-cli/azure/cli/command_modules/network/tests/latest/private_endpoint_arm_templates/videoindexer_accounts_parameters.json b/src/azure-cli/azure/cli/command_modules/network/tests/latest/private_endpoint_arm_templates/videoindexer_accounts_parameters.json new file mode 100644 index 00000000000..82ba6b79d83 --- /dev/null +++ b/src/azure-cli/azure/cli/command_modules/network/tests/latest/private_endpoint_arm_templates/videoindexer_accounts_parameters.json @@ -0,0 +1,12 @@ +{ + "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentParameters.json#", + "contentVersion": "1.0.0.0", + "parameters": { + "target_resource_name": { + "value": "clitestvideoindexer" + }, + "storage_account": { + "value": "clitestvideoindexersa" + } + } +} \ No newline at end of file diff --git a/src/azure-cli/azure/cli/command_modules/network/tests/latest/private_endpoint_arm_templates/videoindexer_accounts_template.json b/src/azure-cli/azure/cli/command_modules/network/tests/latest/private_endpoint_arm_templates/videoindexer_accounts_template.json new file mode 100644 index 00000000000..88f2207f778 --- /dev/null +++ b/src/azure-cli/azure/cli/command_modules/network/tests/latest/private_endpoint_arm_templates/videoindexer_accounts_template.json @@ -0,0 +1,31 @@ +{ + "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#", + "contentVersion": "1.0.0.0", + "parameters": { + "target_resource_name": { + "defaultValue": "videoindexer-privatelink", + "type": "String" + }, + "storage_account": { + "defaultValue": "/subscriptions/24237b72-8546-4da5-b204-8c3cb76dd930/resourceGroups/yaeld-rg/providers/Microsoft.Storage/storageAccounts/yaeldeastussa", + "type": "String" + } + }, + "variables": {}, + "resources": [ + { + "type": "Microsoft.VideoIndexer/accounts", + "apiVersion": "2024-06-01-preview", + "name": "[parameters('target_resource_name')]", + "location": "eastus", + "identity": { + "type": "SystemAssigned" + }, + "properties": { + "storageServices": { + "resourceId": "[parameters('storage_account')]" + } + } + } + ] +} \ No newline at end of file diff --git a/src/azure-cli/azure/cli/command_modules/network/tests/latest/test_private_endpoint_commands.py b/src/azure-cli/azure/cli/command_modules/network/tests/latest/test_private_endpoint_commands.py index 223789c14d0..f796fb57f2d 100644 --- a/src/azure-cli/azure/cli/command_modules/network/tests/latest/test_private_endpoint_commands.py +++ b/src/azure-cli/azure/cli/command_modules/network/tests/latest/test_private_endpoint_commands.py @@ -2165,6 +2165,105 @@ def test_private_endpoint_connection_app_configuration(self, resource_group): self._test_private_endpoint_connection_scenario(resource_group, 'clitestappconfig', 'Microsoft.AppConfiguration/configurationStores') +class VideoIndexerNetworkARMTemplateBasedScenarioTest(ScenarioTest): + def _test_private_endpoint_connection_scenario(self, resource_group, storage_account, target_resource_name): + from azure.mgmt.core.tools import resource_id + resource_type = 'Microsoft.VideoIndexer/accounts' + self.kwargs.update({ + 'target_resource_name': target_resource_name, + 'storage_account': resource_id(subscription=self.get_subscription_id(), + resource_group=resource_group, + namespace='Microsoft.Storage', + type='storageAccounts', + name=storage_account), + 'target_resource_id': resource_id(subscription=self.get_subscription_id(), + resource_group=resource_group, + namespace=resource_type.split('/')[0], + type=resource_type.split('/')[1], + name=target_resource_name), + 'rg': resource_group, + 'resource_type': resource_type, + 'vnet': self.create_random_name('cli-vnet-', 24), + 'subnet': self.create_random_name('cli-subnet-', 24), + 'pe': self.create_random_name('cli-pe-', 24), + 'pe_connection': self.create_random_name('cli-pec-', 24) + }) + + split_resource_type = resource_type.split('/') + resource_type_name = split_resource_type[0].split('.')[1].lower() + resource_type_kind = split_resource_type[1].lower() + param_file_name = "{}_{}_parameters.json".format(resource_type_name, resource_type_kind) + template_file_name = "{}_{}_template.json".format(resource_type_name, resource_type_kind) + self.kwargs.update({ + 'param_path': os.path.join(TEST_DIR, 'private_endpoint_arm_templates', param_file_name), + 'template_path': os.path.join(TEST_DIR, 'private_endpoint_arm_templates', template_file_name) + }) + self.cmd('az deployment group create -g {rg} -p "@{param_path}" target_resource_name={target_resource_name} storage_account={storage_account} -f "{template_path}"') + + self.cmd('az network vnet create -n {vnet} -g {rg} --subnet-name {subnet} -o json', + checks=self.check('length(newVNet.subnets)', 1)) + self.cmd('az network vnet subnet update -n {subnet} --vnet-name {vnet} -g {rg} ' + '--disable-private-endpoint-network-policies true -o json', + checks=self.check('privateEndpointNetworkPolicies', 'Disabled')) + + target_private_link_resource = self.cmd('az network private-link-resource list --name {target_resource_name} --resource-group {rg} --type {resource_type} -o json').get_output_in_json() + self.kwargs.update({ + 'group_id': target_private_link_resource[0]['properties']['groupId'] + }) + # Create a private endpoint connection + pe = self.cmd( + 'az network private-endpoint create -g {rg} -n {pe} --vnet-name {vnet} --subnet {subnet} ' + '--connection-name {pe_connection} --private-connection-resource-id {target_resource_id} ' + '--group-id {group_id} -o json').get_output_in_json() + self.kwargs['pe_id'] = pe['id'] + self.kwargs['pe_name'] = self.kwargs['pe_id'].split('/')[-1] + + # Show the connection at cosmos db side + list_private_endpoint_conn = self.cmd('az network private-endpoint-connection list --name {target_resource_name} --resource-group {rg} --type {resource_type} -o json').get_output_in_json() + self.kwargs.update({ + "pec_id": list_private_endpoint_conn[0]['id'] + }) + + self.kwargs.update({ + "pec_name": self.kwargs['pec_id'].split('/')[-1] + }) + self.cmd('az network private-endpoint-connection show --id {pec_id} -o json', + checks=self.check('id', '{pec_id}')) + self.cmd('az network private-endpoint-connection show --resource-name {target_resource_name} --name {pec_name} --resource-group {rg} --type {resource_type} -o json') + self.cmd('az network private-endpoint-connection show --resource-name {target_resource_name} -n {pec_name} -g {rg} --type {resource_type} -o json') + + # Test approval/rejection + self.kwargs.update({ + 'approval_desc': 'You are approved!', + 'rejection_desc': 'You are rejected!' + }) + self.cmd( + 'az network private-endpoint-connection approve --resource-name {target_resource_name} --resource-group {rg} --name {pec_name} --type {resource_type} ' + '--description "{approval_desc}" -o json', checks=[ + self.check('properties.privateLinkServiceConnectionState.status', 'Approved') + ]) + self.cmd('az network private-endpoint-connection reject --id {pec_id} ' + '--description "{rejection_desc}" -o json', + checks=[ + self.check('properties.privateLinkServiceConnectionState.status', 'Rejected') + ]) + self.cmd( + 'az network private-endpoint-connection list --name {target_resource_name} --resource-group {rg} --type {resource_type} -o json', + checks=[ + self.check('length(@)', 1) + ]) + + # Test delete + self.cmd('az network private-endpoint-connection delete --id {pec_id} -y -o json') + + @live_only() + @ResourceGroupPreparer(name_prefix="test_private_endpoint_connection_video_indexer", location="westus") + @StorageAccountPreparer(name_prefix="testpevi", allow_shared_key_access=False) + def test_private_endpoint_connection_video_indexer(self, resource_group, storage_account): + vi_name = self.create_random_name(prefix='clitestvideoindexer', length=24) + self._test_private_endpoint_connection_scenario(resource_group, storage_account, vi_name) + + class NetworkPrivateLinkDigitalTwinsScenarioTest(ScenarioTest): @ResourceGroupPreparer( name_prefix="test_digital_twin_private_endpoint_", location="eastus"