Skip to content

Commit f87ee9f

Browse files
author
Ami Hollander
committed
Add provider Microsoft.Security/privateLinks
1 parent bb18a2b commit f87ee9f

File tree

4 files changed

+121
-0
lines changed

4 files changed

+121
-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
@@ -86,6 +86,7 @@ def register_providers():
8686
_register_one_provider('Microsoft.App/managedEnvironments', '2024-02-02-preview', True)
8787
_register_one_provider('Microsoft.FluidRelay/fluidRelayServers', '2025-03-10-preview', True)
8888
_register_one_provider('Microsoft.VideoIndexer/accounts', '2025-04-01', True)
89+
_register_one_provider('Microsoft.Security/privateLinks', '2025-09-01-preview', True)
8990

9091

9192
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,9 @@
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": "clitestsecuritypl"
7+
}
8+
}
9+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
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+
},
10+
"variables": {},
11+
"resources": [
12+
{
13+
"type": "Microsoft.Security/privateLinks",
14+
"apiVersion": "2025-09-01-preview",
15+
"name": "[parameters('target_resource_name')]",
16+
"location": "global",
17+
"properties": {}
18+
}
19+
]
20+
}

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

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2265,6 +2265,97 @@ def test_private_endpoint_connection_video_indexer(self, resource_group, storage
22652265
vi_name = self.create_random_name(prefix='clitestvideoindexer', length=24)
22662266
self._test_private_endpoint_connection_scenario(resource_group, storage_account, vi_name)
22672267

2268+
class SecurityPrivateLinkNetworkARMTemplateBasedScenarioTest(ScenarioTest):
2269+
def _test_private_endpoint_connection_scenario(self, resource_group, target_resource_name):
2270+
from azure.mgmt.core.tools import resource_id
2271+
resource_type = 'Microsoft.Security/privateLinks'
2272+
self.kwargs.update({
2273+
'target_resource_name': target_resource_name,
2274+
'target_resource_id': resource_id(subscription=self.get_subscription_id(),
2275+
resource_group=resource_group,
2276+
namespace=resource_type.split('/')[0],
2277+
type=resource_type.split('/')[1],
2278+
name=target_resource_name),
2279+
'rg': resource_group,
2280+
'resource_type': resource_type,
2281+
'vnet': self.create_random_name('cli-vnet-', 24),
2282+
'subnet': self.create_random_name('cli-subnet-', 24),
2283+
'pe': self.create_random_name('cli-pe-', 24),
2284+
'pe_connection': self.create_random_name('cli-pec-', 24)
2285+
})
2286+
2287+
split_resource_type = resource_type.split('/')
2288+
resource_type_name = split_resource_type[0].split('.')[1].lower()
2289+
resource_type_kind = split_resource_type[1].lower()
2290+
param_file_name = "{}_{}_parameters.json".format(resource_type_name, resource_type_kind)
2291+
template_file_name = "{}_{}_template.json".format(resource_type_name, resource_type_kind)
2292+
self.kwargs.update({
2293+
'param_path': os.path.join(TEST_DIR, 'private_endpoint_arm_templates', param_file_name),
2294+
'template_path': os.path.join(TEST_DIR, 'private_endpoint_arm_templates', template_file_name)
2295+
})
2296+
self.cmd('az deployment group create -g {rg} -p "@{param_path}" target_resource_name={target_resource_name} -f "{template_path}"')
2297+
2298+
self.cmd('az network vnet create -n {vnet} -g {rg} --subnet-name {subnet} -o json',
2299+
checks=self.check('length(newVNet.subnets)', 1))
2300+
self.cmd('az network vnet subnet update -n {subnet} --vnet-name {vnet} -g {rg} '
2301+
'--disable-private-endpoint-network-policies true -o json',
2302+
checks=self.check('privateEndpointNetworkPolicies', 'Disabled'))
2303+
2304+
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()
2305+
self.kwargs.update({
2306+
'group_id': target_private_link_resource[0]['properties']['groupId']
2307+
})
2308+
# Create a private endpoint connection
2309+
pe = self.cmd(
2310+
'az network private-endpoint create -g {rg} -n {pe} --vnet-name {vnet} --subnet {subnet} '
2311+
'--connection-name {pe_connection} --private-connection-resource-id {target_resource_id} '
2312+
'--group-id {group_id} -o json').get_output_in_json()
2313+
self.kwargs['pe_id'] = pe['id']
2314+
self.kwargs['pe_name'] = self.kwargs['pe_id'].split('/')[-1]
2315+
2316+
# Show the connection at cosmos db side
2317+
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()
2318+
self.kwargs.update({
2319+
"pec_id": list_private_endpoint_conn[0]['id']
2320+
})
2321+
2322+
self.kwargs.update({
2323+
"pec_name": self.kwargs['pec_id'].split('/')[-1]
2324+
})
2325+
self.cmd('az network private-endpoint-connection show --id {pec_id} -o json',
2326+
checks=self.check('id', '{pec_id}'))
2327+
self.cmd('az network private-endpoint-connection show --resource-name {target_resource_name} --name {pec_name} --resource-group {rg} --type {resource_type} -o json')
2328+
self.cmd('az network private-endpoint-connection show --resource-name {target_resource_name} -n {pec_name} -g {rg} --type {resource_type} -o json')
2329+
2330+
# Test approval/rejection
2331+
self.kwargs.update({
2332+
'approval_desc': 'You are approved!',
2333+
'rejection_desc': 'You are rejected!'
2334+
})
2335+
self.cmd(
2336+
'az network private-endpoint-connection approve --resource-name {target_resource_name} --resource-group {rg} --name {pec_name} --type {resource_type} '
2337+
'--description "{approval_desc}" -o json', checks=[
2338+
self.check('properties.privateLinkServiceConnectionState.status', 'Approved')
2339+
])
2340+
self.cmd('az network private-endpoint-connection reject --id {pec_id} '
2341+
'--description "{rejection_desc}" -o json',
2342+
checks=[
2343+
self.check('properties.privateLinkServiceConnectionState.status', 'Rejected')
2344+
])
2345+
self.cmd(
2346+
'az network private-endpoint-connection list --name {target_resource_name} --resource-group {rg} --type {resource_type} -o json',
2347+
checks=[
2348+
self.check('length(@)', 1)
2349+
])
2350+
2351+
# Test delete
2352+
self.cmd('az network private-endpoint-connection delete --id {pec_id} -y -o json')
2353+
2354+
@live_only()
2355+
@ResourceGroupPreparer(name_prefix="test_private_endpoint_connection_security_privatelink", location="westus")
2356+
def test_private_endpoint_connection_security_privatelink(self, resource_group):
2357+
name = self.create_random_name(prefix='clitestsecuritypl', length=24)
2358+
self._test_private_endpoint_connection_scenario(resource_group, name)
22682359

22692360
class NetworkPrivateLinkDigitalTwinsScenarioTest(ScenarioTest):
22702361
@ResourceGroupPreparer(

0 commit comments

Comments
 (0)