Skip to content

Commit 088ca11

Browse files
authored
[Network] az network private-endpoint-connection: Add provider Microsoft.VideoIndexer/accounts (#31549)
1 parent 775d9d1 commit 088ca11

File tree

4 files changed

+143
-0
lines changed

4 files changed

+143
-0
lines changed

src/azure-cli/azure/cli/command_modules/network/private_link_resource_and_endpoint_connections/custom.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ def register_providers():
8585
_register_one_provider('Microsoft.DBforPostgreSQL/flexibleServers', '2023-06-01-preview', False)
8686
_register_one_provider('Microsoft.App/managedEnvironments', '2024-02-02-preview', True)
8787
_register_one_provider('Microsoft.FluidRelay/fluidRelayServers', '2025-03-10-preview', True)
88+
_register_one_provider('Microsoft.VideoIndexer/accounts', '2025-04-01', True)
8889

8990

9091
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
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentParameters.json#",
3+
"contentVersion": "1.0.0.0",
4+
"parameters": {
5+
"target_resource_name": {
6+
"value": "clitestvideoindexer"
7+
},
8+
"storage_account": {
9+
"value": "clitestvideoindexersa"
10+
}
11+
}
12+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
{
2+
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
3+
"contentVersion": "1.0.0.0",
4+
"parameters": {
5+
"target_resource_name": {
6+
"defaultValue": "videoindexer-privatelink",
7+
"type": "String"
8+
},
9+
"storage_account": {
10+
"defaultValue": "/subscriptions/24237b72-8546-4da5-b204-8c3cb76dd930/resourceGroups/yaeld-rg/providers/Microsoft.Storage/storageAccounts/yaeldeastussa",
11+
"type": "String"
12+
}
13+
},
14+
"variables": {},
15+
"resources": [
16+
{
17+
"type": "Microsoft.VideoIndexer/accounts",
18+
"apiVersion": "2024-06-01-preview",
19+
"name": "[parameters('target_resource_name')]",
20+
"location": "eastus",
21+
"identity": {
22+
"type": "SystemAssigned"
23+
},
24+
"properties": {
25+
"storageServices": {
26+
"resourceId": "[parameters('storage_account')]"
27+
}
28+
}
29+
}
30+
]
31+
}

src/azure-cli/azure/cli/command_modules/network/tests/latest/test_private_endpoint_commands.py

Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2165,6 +2165,105 @@ def test_private_endpoint_connection_app_configuration(self, resource_group):
21652165
self._test_private_endpoint_connection_scenario(resource_group, 'clitestappconfig', 'Microsoft.AppConfiguration/configurationStores')
21662166

21672167

2168+
class VideoIndexerNetworkARMTemplateBasedScenarioTest(ScenarioTest):
2169+
def _test_private_endpoint_connection_scenario(self, resource_group, storage_account, target_resource_name):
2170+
from azure.mgmt.core.tools import resource_id
2171+
resource_type = 'Microsoft.VideoIndexer/accounts'
2172+
self.kwargs.update({
2173+
'target_resource_name': target_resource_name,
2174+
'storage_account': resource_id(subscription=self.get_subscription_id(),
2175+
resource_group=resource_group,
2176+
namespace='Microsoft.Storage',
2177+
type='storageAccounts',
2178+
name=storage_account),
2179+
'target_resource_id': resource_id(subscription=self.get_subscription_id(),
2180+
resource_group=resource_group,
2181+
namespace=resource_type.split('/')[0],
2182+
type=resource_type.split('/')[1],
2183+
name=target_resource_name),
2184+
'rg': resource_group,
2185+
'resource_type': resource_type,
2186+
'vnet': self.create_random_name('cli-vnet-', 24),
2187+
'subnet': self.create_random_name('cli-subnet-', 24),
2188+
'pe': self.create_random_name('cli-pe-', 24),
2189+
'pe_connection': self.create_random_name('cli-pec-', 24)
2190+
})
2191+
2192+
split_resource_type = resource_type.split('/')
2193+
resource_type_name = split_resource_type[0].split('.')[1].lower()
2194+
resource_type_kind = split_resource_type[1].lower()
2195+
param_file_name = "{}_{}_parameters.json".format(resource_type_name, resource_type_kind)
2196+
template_file_name = "{}_{}_template.json".format(resource_type_name, resource_type_kind)
2197+
self.kwargs.update({
2198+
'param_path': os.path.join(TEST_DIR, 'private_endpoint_arm_templates', param_file_name),
2199+
'template_path': os.path.join(TEST_DIR, 'private_endpoint_arm_templates', template_file_name)
2200+
})
2201+
self.cmd('az deployment group create -g {rg} -p "@{param_path}" target_resource_name={target_resource_name} storage_account={storage_account} -f "{template_path}"')
2202+
2203+
self.cmd('az network vnet create -n {vnet} -g {rg} --subnet-name {subnet} -o json',
2204+
checks=self.check('length(newVNet.subnets)', 1))
2205+
self.cmd('az network vnet subnet update -n {subnet} --vnet-name {vnet} -g {rg} '
2206+
'--disable-private-endpoint-network-policies true -o json',
2207+
checks=self.check('privateEndpointNetworkPolicies', 'Disabled'))
2208+
2209+
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()
2210+
self.kwargs.update({
2211+
'group_id': target_private_link_resource[0]['properties']['groupId']
2212+
})
2213+
# Create a private endpoint connection
2214+
pe = self.cmd(
2215+
'az network private-endpoint create -g {rg} -n {pe} --vnet-name {vnet} --subnet {subnet} '
2216+
'--connection-name {pe_connection} --private-connection-resource-id {target_resource_id} '
2217+
'--group-id {group_id} -o json').get_output_in_json()
2218+
self.kwargs['pe_id'] = pe['id']
2219+
self.kwargs['pe_name'] = self.kwargs['pe_id'].split('/')[-1]
2220+
2221+
# Show the connection at cosmos db side
2222+
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()
2223+
self.kwargs.update({
2224+
"pec_id": list_private_endpoint_conn[0]['id']
2225+
})
2226+
2227+
self.kwargs.update({
2228+
"pec_name": self.kwargs['pec_id'].split('/')[-1]
2229+
})
2230+
self.cmd('az network private-endpoint-connection show --id {pec_id} -o json',
2231+
checks=self.check('id', '{pec_id}'))
2232+
self.cmd('az network private-endpoint-connection show --resource-name {target_resource_name} --name {pec_name} --resource-group {rg} --type {resource_type} -o json')
2233+
self.cmd('az network private-endpoint-connection show --resource-name {target_resource_name} -n {pec_name} -g {rg} --type {resource_type} -o json')
2234+
2235+
# Test approval/rejection
2236+
self.kwargs.update({
2237+
'approval_desc': 'You are approved!',
2238+
'rejection_desc': 'You are rejected!'
2239+
})
2240+
self.cmd(
2241+
'az network private-endpoint-connection approve --resource-name {target_resource_name} --resource-group {rg} --name {pec_name} --type {resource_type} '
2242+
'--description "{approval_desc}" -o json', checks=[
2243+
self.check('properties.privateLinkServiceConnectionState.status', 'Approved')
2244+
])
2245+
self.cmd('az network private-endpoint-connection reject --id {pec_id} '
2246+
'--description "{rejection_desc}" -o json',
2247+
checks=[
2248+
self.check('properties.privateLinkServiceConnectionState.status', 'Rejected')
2249+
])
2250+
self.cmd(
2251+
'az network private-endpoint-connection list --name {target_resource_name} --resource-group {rg} --type {resource_type} -o json',
2252+
checks=[
2253+
self.check('length(@)', 1)
2254+
])
2255+
2256+
# Test delete
2257+
self.cmd('az network private-endpoint-connection delete --id {pec_id} -y -o json')
2258+
2259+
@live_only()
2260+
@ResourceGroupPreparer(name_prefix="test_private_endpoint_connection_video_indexer", location="westus")
2261+
@StorageAccountPreparer(name_prefix="testpevi", allow_shared_key_access=False)
2262+
def test_private_endpoint_connection_video_indexer(self, resource_group, storage_account):
2263+
vi_name = self.create_random_name(prefix='clitestvideoindexer', length=24)
2264+
self._test_private_endpoint_connection_scenario(resource_group, storage_account, vi_name)
2265+
2266+
21682267
class NetworkPrivateLinkDigitalTwinsScenarioTest(ScenarioTest):
21692268
@ResourceGroupPreparer(
21702269
name_prefix="test_digital_twin_private_endpoint_", location="eastus"

0 commit comments

Comments
 (0)