@@ -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+
21682267class NetworkPrivateLinkDigitalTwinsScenarioTest (ScenarioTest ):
21692268 @ResourceGroupPreparer (
21702269 name_prefix = "test_digital_twin_private_endpoint_" , location = "eastus"
0 commit comments