@@ -1293,8 +1293,6 @@ private Task AssignVmAsContributorToAppInsightsAsync(IIdentity managedIdentity,
1293
1293
1294
1294
vnetDefinition = vnetDefinition . DefineSubnet ( configuration . BatchSubnetName )
1295
1295
. WithAddressPrefix ( configuration . BatchNodesSubnetAddressSpace )
1296
- . WithAccessFromService ( ServiceEndpointType . MicrosoftStorage )
1297
- . WithAccessFromService ( ServiceEndpointType . MicrosoftSql )
1298
1296
. Attach ( ) ;
1299
1297
1300
1298
var vnet = await vnetDefinition . CreateAsync ( ) ;
@@ -1303,10 +1301,7 @@ private Task AssignVmAsContributorToAppInsightsAsync(IIdentity managedIdentity,
1303
1301
// Use the new ResourceManager sdk to add the ACR service endpoint since it is absent from the fluent sdk.
1304
1302
var armBatchSubnet = ( await armClient . GetSubnetResource ( new ResourceIdentifier ( batchSubnet . Inner . Id ) ) . GetAsync ( ) ) . Value ;
1305
1303
1306
- armBatchSubnet . Data . ServiceEndpoints . Add ( new ServiceEndpointProperties ( )
1307
- {
1308
- Service = "Microsoft.ContainerRegistry" ,
1309
- } ) ;
1304
+ AddServiceEndpointsToSubnet ( armBatchSubnet . Data ) ;
1310
1305
1311
1306
await armBatchSubnet . UpdateAsync ( Azure . WaitUntil . Completed , armBatchSubnet . Data ) ;
1312
1307
@@ -1825,27 +1820,37 @@ private Task<string> UpdateVnetWithBatchSubnet()
1825
1820
AddressPrefix = configuration . BatchNodesSubnetAddressSpace ,
1826
1821
} ;
1827
1822
1828
- batchSubnet . ServiceEndpoints . Add ( new ServiceEndpointProperties ( )
1829
- {
1830
- Service = "Microsoft.Storage" ,
1831
- } ) ;
1832
-
1833
- batchSubnet . ServiceEndpoints . Add ( new ServiceEndpointProperties ( )
1834
- {
1835
- Service = "Microsoft.Sql" ,
1836
- } ) ;
1837
-
1838
- batchSubnet . ServiceEndpoints . Add ( new ServiceEndpointProperties ( )
1839
- {
1840
- Service = "Microsoft.ContainerRegistry" ,
1841
- } ) ;
1823
+ AddServiceEndpointsToSubnet ( batchSubnet ) ;
1842
1824
1843
1825
vnetData . Subnets . Add ( batchSubnet ) ;
1844
1826
var updatedVnet = ( await vnetCollection . CreateOrUpdateAsync ( Azure . WaitUntil . Completed , vnetData . Name , vnetData ) ) . Value ;
1845
1827
1846
1828
return ( await updatedVnet . GetSubnetAsync ( configuration . DefaultBatchSubnetName ) ) . Value . Id . ToString ( ) ;
1847
1829
} ) ;
1848
1830
1831
+ private void AddServiceEndpointsToSubnet ( SubnetData subnet )
1832
+ {
1833
+ subnet . ServiceEndpoints . Add ( new ServiceEndpointProperties ( )
1834
+ {
1835
+ Service = "Microsoft.Storage.Global" ,
1836
+ } ) ;
1837
+
1838
+ subnet . ServiceEndpoints . Add ( new ServiceEndpointProperties ( )
1839
+ {
1840
+ Service = "Microsoft.Sql" ,
1841
+ } ) ;
1842
+
1843
+ subnet . ServiceEndpoints . Add ( new ServiceEndpointProperties ( )
1844
+ {
1845
+ Service = "Microsoft.ContainerRegistry" ,
1846
+ } ) ;
1847
+
1848
+ subnet . ServiceEndpoints . Add ( new ServiceEndpointProperties ( )
1849
+ {
1850
+ Service = "Microsoft.KeyVault" ,
1851
+ } ) ;
1852
+ }
1853
+
1849
1854
private async Task ValidateVmAsync ( )
1850
1855
{
1851
1856
var computeSkus = ( await generalRetryPolicy . ExecuteAsync ( ( ) =>
0 commit comments