Skip to content

Commit e4a264b

Browse files
Proxy Agent support for Gallery (Azure#27987)
1 parent 155b6ef commit e4a264b

File tree

47 files changed

+7751
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+7751
-0
lines changed

src/Compute/Compute.Test/ScenarioTests/GalleryTests.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,5 +85,13 @@ public void TestGalleryBlockDeletionBeforeEndOfLife()
8585
{
8686
TestRunner.RunTestScript("TestGen-BlockDeletionBeforeEndOfLife");
8787
}
88+
89+
[Fact]
90+
[Trait(Category.AcceptanceType, Category.CheckIn)]
91+
public void TestInVMAccessControlProfileVersion()
92+
{
93+
TestRunner.RunTestScript("Test-InVMAccessControlProfileVersion");
94+
}
95+
8896
}
8997
}

src/Compute/Compute.Test/ScenarioTests/GalleryTests.ps1

Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1110,3 +1110,118 @@ function TestGen-newazgallery
11101110
Remove-AzResourceGroup -Name $rgname -Force -ErrorAction SilentlyContinue;
11111111
}
11121112
}
1113+
1114+
<#
1115+
.SYNOPSIS
1116+
Tests InVMAccessControlProfileVersions
1117+
#>
1118+
function Test-InVMAccessControlProfileVersion
1119+
{
1120+
# Setup
1121+
$rgname = Get-ComputeTestResourceName;
1122+
$loc = "westus2"
1123+
1124+
try
1125+
{
1126+
1127+
$location = $loc;
1128+
$resourceGroup = $rgname
1129+
1130+
$galleryName = "mspGallery"
1131+
$InVMAccessControlProfileName= "testMspCp"
1132+
1133+
$inVMAccessControlProfileVersionName= "1.0.0"
1134+
$targetLocations= @("EastUS2EUAP", "CentralUSEUAP", "westUS2")
1135+
1136+
# create resource group
1137+
New-AzResourceGroup -Name $rgname -Location $loc -Force;
1138+
1139+
# gallery creation
1140+
New-AzGallery -ResourceGroupName $rgname -GalleryName $galleryName -Location $location -Description "My custom image gallery"
1141+
1142+
# CP creation
1143+
New-AzGalleryInVMAccessControlProfile -ResourceGroupName $rgname -GalleryName $galleryName -GalleryInVMAccessControlProfileName $InVMAccessControlProfileName -Location $location -OsType "Windows" -ApplicableHostEndPoint "WireServer" -Description "this test1"
1144+
$cp = Get-AzGalleryInVMAccessControlProfile -ResourceGroupName $resourceGroup -GalleryName $galleryName -GalleryInVMAccessControlProfileName $InVMAccessControlProfileName
1145+
1146+
# Validate
1147+
Assert-AreEqual $cp.Name $InVMAccessControlProfileName
1148+
Assert-AreEqual $cp.Properties.OsType "Windows"
1149+
Assert-AreEqual $cp.Properties.ApplicableHostEndPoint "WireServer"
1150+
Assert-AreEqual $cp.Properties.Description "this test1"
1151+
1152+
# Update CP
1153+
Update-AzGalleryInVMAccessControlProfile -ResourceGroupName $resourceGroup -GalleryName $galleryName -GalleryInVMAccessControlProfileName $InVMAccessControlProfileName -Location $location -Description "this test2"
1154+
1155+
# Create CPversion config
1156+
$inVMAccessControlProfileVersion = New-AzGalleryInVMAccessControlProfileVersionConfig -Name $inVMAccessControlProfileVersionName -Location $location -Mode "Audit" -DefaultAccess "Deny" -TargetLocation $targetLocations -ExcludeFromLatest
1157+
1158+
# Set AccessRoles
1159+
## Add Privilege
1160+
Add-AzGalleryInVMAccessControlProfileVersionRulesPrivilege -GalleryInVmAccessControlProfileVersion $inVMAccessControlProfileVersion -PrivilegeName "GoalState" -Path "/machine" -QueryParameter @{ comp = "goalstate" }
1161+
Add-AzGalleryInVMAccessControlProfileVersionRulesPrivilege -GalleryInVmAccessControlProfileVersion $inVMAccessControlProfileVersion -PrivilegeName "GoalState2" -Path "/machine" -QueryParameter @{ comp = "goalstate" }
1162+
1163+
## Add Roles
1164+
Add-AzGalleryInVMAccessControlProfileVersionRulesRole -GalleryInVmAccessControlProfileVersion $inVMAccessControlProfileVersion -RoleName "Provisioning" -Privilege @("GoalState")
1165+
Add-AzGalleryInVMAccessControlProfileVersionRulesRole -GalleryInVmAccessControlProfileVersion $inVMAccessControlProfileVersion -RoleName "Provisioning2" -Privilege @("GoalState")
1166+
1167+
## Add Identity
1168+
Add-AzGalleryInVMAccessControlProfileVersionRulesIdentity -GalleryInVmAccessControlProfileVersion $inVMAccessControlProfileVersion -IdentityName "WinPA" -UserName "SYSTEM" -GroupName "Administrators" -ExePath "C:\Windows\System32\cscript.exe" -ProcessName "cscript"
1169+
Add-AzGalleryInVMAccessControlProfileVersionRulesIdentity -GalleryInVmAccessControlProfileVersion $inVMAccessControlProfileVersion -IdentityName "WinPA2" -UserName "SYSTEM" -GroupName "Administrators" -ExePath "C:\Windows\System32\cscript.exe" -ProcessName "cscript"
1170+
1171+
## Add Role Assignment
1172+
Add-AzGalleryInVMAccessControlProfileVersionRulesRoleAssignment -GalleryInVmAccessControlProfileVersion $inVMAccessControlProfileVersion -Role "Provisioning" -Identity @("WinPA")
1173+
Add-AzGalleryInVMAccessControlProfileVersionRulesRoleAssignment -GalleryInVmAccessControlProfileVersion $inVMAccessControlProfileVersion -Role "Provisioning2" -Identity @("WinPA")
1174+
1175+
# Validate CP Version Config
1176+
Assert-AreEqual $inVMAccessControlProfileVersion.TargetLocations.count 3
1177+
Assert-AreEqual $inVMAccessControlProfileVersion.ExcludeFromLatest $true
1178+
Assert-AreEqual $inVMAccessControlProfileVersion.Rules.Roles.count 2
1179+
Assert-AreEqual $inVMAccessControlProfileVersion.Rules.Identities.count 2
1180+
Assert-AreEqual $inVMAccessControlProfileVersion.Rules.Privileges.count 2
1181+
Assert-AreEqual $inVMAccessControlProfileVersion.Rules.RoleAssignments.count 2
1182+
1183+
# Create CP Version
1184+
New-AzGalleryInVMAccessControlProfileVersion -ResourceGroupName $resourceGroup -GalleryName $galleryName -GalleryInVMAccessControlProfileName $InVMAccessControlProfileName -GalleryInVmAccessControlProfileVersion $inVMAccessControlProfileVersion
1185+
1186+
# Get CP version
1187+
$ver = Get-AzGalleryInVMAccessControlProfileVersion -ResourceGroupName $resourceGroup -GalleryName $galleryName -GalleryInVMAccessControlProfileName $InVMAccessControlProfileName -GalleryInVMAccessControlProfileVersionName $inVMAccessControlProfileVersionName
1188+
1189+
# validate CP version
1190+
Assert-AreEqual $ver.TargetLocations.count 3
1191+
Assert-AreEqual $ver.ExcludeFromLatest $true
1192+
Assert-AreEqual $ver.Rules.Roles.count 2
1193+
Assert-AreEqual $ver.Rules.Identities.count 2
1194+
Assert-AreEqual $ver.Rules.Privileges.count 2
1195+
Assert-AreEqual $ver.Rules.RoleAssignments.count 2
1196+
1197+
# update CP version
1198+
$targetLocations = @("westus2")
1199+
Update-AzGalleryInVMAccessControlProfileVersion -GalleryInVMAccessControlProfileVersion $ver -TargetLocation $targetLocations -ExcludeFromLatest $false
1200+
1201+
# validate
1202+
$ver = Get-AzGalleryInVMAccessControlProfileVersion -ResourceGroupName $resourceGroup -GalleryName $galleryName -GalleryInVMAccessControlProfileName $InVMAccessControlProfileName -GalleryInVMAccessControlProfileVersionName $inVMAccessControlProfileVersionName
1203+
Assert-AreEqual $ver.TargetLocations.count 1
1204+
Assert-AreEqual $ver.ExcludeFromLatest $false
1205+
1206+
1207+
# remove CP version
1208+
Remove-AzGalleryInVMAccessControlProfileVersion -ResourceGroupName $resourceGroup -GalleryName $galleryName -GalleryInVMAccessControlProfileName $InVMAccessControlProfileName -GalleryInVMAccessControlProfileVersionName $inVMAccessControlProfileVersionName -Force
1209+
$ver = Get-AzGalleryInVMAccessControlProfileVersion -ResourceGroupName $resourceGroup -GalleryName $galleryName -GalleryInVMAccessControlProfileName $InVMAccessControlProfileName
1210+
1211+
# validate
1212+
Assert-AreEqual $ver.count 0
1213+
1214+
# remove CP
1215+
Remove-AzGalleryInVMAccessControlProfile -ResourceGroupName $resourceGroup -GalleryName $galleryName -GalleryInVMAccessControlProfileName $InVMAccessControlProfileName -Force
1216+
$profile = Get-AzGalleryInVMAccessControlProfile -ResourceGroupName $resourceGroup -GalleryName $galleryName
1217+
1218+
# validate
1219+
Assert-AreEqual $profile.count 0
1220+
1221+
}
1222+
finally
1223+
{
1224+
# Cleanup
1225+
Clean-ResourceGroup $rgname;
1226+
}
1227+
}

src/Compute/Compute.Test/SessionRecords/Microsoft.Azure.Commands.Compute.Test.ScenarioTests.GalleryTests/TestInVMAccessControlProfileVersion.json

Lines changed: 2757 additions & 0 deletions
Large diffs are not rendered by default.

src/Compute/Compute/Az.Compute.psd1

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,15 @@ CmdletsToExport = 'Add-AzImageDataDisk', 'Add-AzVhd',
200200
'Update-AzHost', 'Update-AzImage', 'Update-AzRestorePointCollection',
201201
'Update-AzSnapshot', 'Update-AzSshKey', 'Update-AzVM', 'Update-AzVmss',
202202
'Update-AzVmssInstance', 'Update-AzVmssVM',
203+
'New-AzGalleryInVMAccessControlProfile', 'Remove-AzGalleryInVMAccessControlProfile',
204+
'Get-AzGalleryInVMAccessControlProfile',
205+
'New-AzGalleryInVMAccessControlProfileVersion', 'New-AzGalleryInVMAccessControlProfileVersionConfig',
206+
'Remove-AzGalleryInVMAccessControlProfileVersion', 'Get-AzGalleryInVMAccessControlProfileVersion',
207+
'Add-AzGalleryInVMAccessControlProfileVersionRulesPrivilege', 'Remove-AzGalleryInVMAccessControlProfileVersionRulesPrivilege',
208+
'Add-AzGalleryInVMAccessControlProfileVersionRulesRole', 'Remove-AzGalleryInVmAccessControlProfileVersionRulesRole',
209+
'Add-AzGalleryInVMAccessControlProfileVersionRulesIdentity', 'Remove-AzGalleryInVMAccessControlProfileVersionRulesIdentity',
210+
'Add-AzGalleryInVMAccessControlProfileVersionRulesRoleAssignment', 'Remove-AzGalleryInVMAccessControlProfileVersionRulesRoleAssignment',
211+
'Update-AzGalleryInVMAccessControlProfileVersion', 'Update-AzGalleryInVMAccessControlProfile',
203212
'Set-AzVMProxyAgentSetting', 'Set-AzVmssProxyAgentSetting'
204213

205214
# Variables to export from this module

src/Compute/Compute/ChangeLog.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,14 @@
2020
2121
-->
2222
## Upcoming Release
23+
* Support for Metadata Security Protocol (MSP) support for Gallery
24+
- Added new cmdlets `New-AzGalleryInVmAccessControlProfile`, `Get-AzGalleryInVmAccessControlProfile`, `Update-AzGalleryInVmAccessControlProfile`, and `Remove-AzGalleryInVmAccessControlProfile` to manage In-VM Access Control Profiles in Azure Compute Gallery.
25+
- Added new cmdlets `New-AzGalleryInVmAccessControlProfileVersion`, `Get-AzGalleryInVmAccessControlProfileVersion`, `Update-AzGalleryInVmAccessControlProfileVersion`, and `Remove-AzGalleryInVmAccessControlProfileVersion` to manage In-VM Access Control Profile Versions in Azure Compute Gallery.
26+
- Added new cmdlet `New0AzGalleryInVmAccessControlProfileVersionConfig` to create a local configuration object for In-VM Access Control Profile Version.
27+
- Added new cmdlets `Add-AzGalleryInVmAccessControlProfileVersionRulesPrivilege` and `Remove-AzGalleryInVmAccessControlProfileVersionRulesPrivilege` to manage privileges in In-VM Access Control Profile Version.
28+
- Added new cmdlets `Add-AzGalleryInVmAccessControlProfileVersionRulesRole` and `Remove-AzGalleryInVmAccessControlProfileVersionRulesRole` to manage roles in In-VM Access Control Profile Version.
29+
- Added new cmdlets `Add-AzGalleryInVmAccessControlProfileVersionRulesIdentity` and `Remove-AzGalleryInVmAccessControlProfileVersionRulesIdentity` to manage identities in In-VM Access Control Profile Version.
30+
- Added new cmdlets `Add-AzGalleryInVmAccessControlProfileVersionRulesRoleAssignment` and `Remove-AzGalleryInVmAccessControlProfileVersionRulesRoleAssignment` to manage role assignments in In-VM Access Control Profile Version.
2331
* Added `-EnableProxyAgent` parameter to `New-AzVM` and `New-AzVmss` simple parameter sets.
2432
* Added `-ProxyAgentKeyIncarnationId`parameter to `Update-AzVmssVM` cmdlet.
2533
* Added new cmdlets `Set-AzVmssProxyAgent` and `Set-AzVMProxyAgent` to set the proxy agent settings for VM and VMSS.`

src/Compute/Compute/Compute.format.ps1xml

Lines changed: 132 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,138 @@
1818
</CustomEntries>
1919
</CustomControl>
2020
</View>
21+
<View>
22+
<Name>Microsoft.Azure.Commands.Compute.Automation.Models.PSGalleryInVMAccessControlProfile</Name>
23+
<ViewSelectedBy>
24+
<TypeName>Microsoft.Azure.Commands.Compute.Automation.Models.PSGalleryInVMAccessControlProfile</TypeName>
25+
</ViewSelectedBy>
26+
<ListControl>
27+
<ListEntries>
28+
<ListEntry>
29+
<ListItems>
30+
<ListItem>
31+
<Label>Id</Label>
32+
<PropertyName>Id</PropertyName>
33+
</ListItem>
34+
<ListItem>
35+
<Label>Name</Label>
36+
<PropertyName>Name</PropertyName>
37+
</ListItem>
38+
<ListItem>
39+
<Label>Type</Label>
40+
<PropertyName>Type</PropertyName>
41+
</ListItem>
42+
<ListItem>
43+
<Label>Location</Label>
44+
<PropertyName>Location</PropertyName>
45+
</ListItem>
46+
<ListItem>
47+
<Label>Tags</Label>
48+
<PropertyName>Tags</PropertyName>
49+
</ListItem>
50+
<ListItem>
51+
<Label>Description</Label>
52+
<ScriptBlock>$_.Properties.Description</ScriptBlock>
53+
</ListItem>
54+
<ListItem>
55+
<Label>OsType</Label>
56+
<ScriptBlock>$_.Properties.OsType</ScriptBlock>
57+
</ListItem>
58+
<ListItem>
59+
<Label>ApplicableHostEndpoint</Label>
60+
<ScriptBlock>$_.Properties.ApplicableHostEndpoint</ScriptBlock>
61+
</ListItem>
62+
<ListItem>
63+
<Label>ProvisioningState</Label>
64+
<ScriptBlock>$_.Properties.ProvisioningState</ScriptBlock>
65+
</ListItem>
66+
</ListItems>
67+
</ListEntry>
68+
</ListEntries>
69+
</ListControl>
70+
</View>
71+
<View>
72+
<Name>Microsoft.Azure.Commands.Compute.Automation.Models.PSGalleryInVMAccessControlProfileVersion</Name>
73+
<ViewSelectedBy>
74+
<TypeName>Microsoft.Azure.Commands.Compute.Automation.Models.PSGalleryInVMAccessControlProfileVersion</TypeName>
75+
</ViewSelectedBy>
76+
<ListControl>
77+
<ListEntries>
78+
<ListEntry>
79+
<ListItems>
80+
<ListItem>
81+
<Label>Id</Label>
82+
<PropertyName>Id</PropertyName>
83+
</ListItem>
84+
<ListItem>
85+
<Label>Name</Label>
86+
<PropertyName>Name</PropertyName>
87+
</ListItem>
88+
<ListItem>
89+
<Label>Type</Label>
90+
<PropertyName>Type</PropertyName>
91+
</ListItem>
92+
<ListItem>
93+
<Label>Location</Label>
94+
<PropertyName>Location</PropertyName>
95+
</ListItem>
96+
<ListItem>
97+
<Label>Tags</Label>
98+
<PropertyName>Tags</PropertyName>
99+
</ListItem>
100+
<ListItem>
101+
<Label>TargetLocations</Label>
102+
<PropertyName>TargetLocations</PropertyName>
103+
</ListItem>
104+
<ListItem>
105+
<Label>ExcludeFromLatest</Label>
106+
<PropertyName>ExcludeFromLatest</PropertyName>
107+
</ListItem>
108+
<ListItem>
109+
<Label>PublishedDate</Label>
110+
<PropertyName>PublishedDate</PropertyName>
111+
</ListItem>
112+
<ListItem>
113+
<Label>ProvisioningState</Label>
114+
<PropertyName>ProvisioningState</PropertyName>
115+
</ListItem>
116+
<ListItem>
117+
<Label>ReplicationStatus</Label>
118+
<PropertyName>ReplicationStatus</PropertyName>
119+
</ListItem>
120+
<ListItem>
121+
<Label>Mode</Label>
122+
<PropertyName>Mode</PropertyName>
123+
</ListItem>
124+
<ListItem>
125+
<Label>DefaultAccess</Label>
126+
<PropertyName>DefaultAccess</PropertyName>
127+
</ListItem>
128+
<ListItem>
129+
<Label>Rules</Label>
130+
<ScriptBlock>""</ScriptBlock>
131+
</ListItem>
132+
<ListItem>
133+
<Label> Privileges</Label>
134+
<ScriptBlock>$_.Rules.Privileges</ScriptBlock>
135+
</ListItem>
136+
<ListItem>
137+
<Label> Roles</Label>
138+
<ScriptBlock>$_.Rules.Roles</ScriptBlock>
139+
</ListItem>
140+
<ListItem>
141+
<Label> Identities</Label>
142+
<ScriptBlock>$_.Rules.Identities</ScriptBlock>
143+
</ListItem>
144+
<ListItem>
145+
<Label> RoleAssignments</Label>
146+
<ScriptBlock>$_.Rules.RoleAssignments</ScriptBlock>
147+
</ListItem>
148+
</ListItems>
149+
</ListEntry>
150+
</ListEntries>
151+
</ListControl>
152+
</View>
21153
<View>
22154
<Name>Microsoft.Azure.Commands.Compute.Models.PSComputeLongRunningOperation</Name>
23155
<ViewSelectedBy>

src/Compute/Compute/Generated/ComputeAutomationBaseCmdlet.cs

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -333,6 +333,20 @@ public IRestorePointsOperations RestorePointClient
333333
return ComputeClient.ComputeManagementClient.RestorePoints;
334334
}
335335
}
336+
public IGalleryInVMAccessControlProfilesOperations GalleryInVMAccessControlProfileClient
337+
{
338+
get
339+
{
340+
return ComputeClient.ComputeManagementClient.GalleryInVMAccessControlProfiles;
341+
}
342+
}
343+
public IGalleryInVMAccessControlProfileVersionsOperations GalleryInVMAccessControlProfileVersionClient
344+
{
345+
get
346+
{
347+
return ComputeClient.ComputeManagementClient.GalleryInVMAccessControlProfileVersions;
348+
}
349+
}
336350

337351
public static string FormatObject(Object obj)
338352
{
@@ -484,6 +498,31 @@ public static string GetVersion(string resourceId, string resourceName, string i
484498
Match m = r.Match(resourceId);
485499
return m.Success ? m.Groups["version"].Value : null;
486500
}
501+
502+
public static string GetGalleryNameFromInVMAccessControlProfileResourceId(string InVMAccessControlProfileResourceId)
503+
{
504+
if (string.IsNullOrEmpty(InVMAccessControlProfileResourceId)) { return null; }
505+
Regex r = new Regex(@"(.*?)/galleries/(?<galleryName>[^/]+)", RegexOptions.IgnoreCase);
506+
Match m = r.Match(InVMAccessControlProfileResourceId);
507+
return m.Success ? m.Groups["galleryName"].Value : null;
508+
}
509+
510+
public static string GetInVMAccessControlProfileNameFromInVMAccessControlProfileResourceId(string InVMAccessControlProfileResourceId)
511+
{
512+
if (string.IsNullOrEmpty(InVMAccessControlProfileResourceId)) { return null; }
513+
Regex r = new Regex(@"(.*?)/galleries/(?<galleryName>[^/]+)/inVMAccessControlProfiles/(?<profileName>[^/]+)", RegexOptions.IgnoreCase);
514+
Match m = r.Match(InVMAccessControlProfileResourceId);
515+
return m.Success ? m.Groups["profileName"].Value : null;
516+
}
517+
518+
public static string GetInVMAccessControlProfileVersionNameFromInVMAccessControlProfileVersionResourceId(string InVMAccessControlProfileVersionResourceId)
519+
{
520+
if (string.IsNullOrEmpty(InVMAccessControlProfileVersionResourceId)) { return null; }
521+
Regex r = new Regex(@"(.*?)/galleries/(?<galleryName>[^/]+)/inVMAccessControlProfiles/(?<profileName>[^/]+)/versions/(?<versionName>[^/]+)", RegexOptions.IgnoreCase);
522+
Match m = r.Match(InVMAccessControlProfileVersionResourceId);
523+
return m.Success ? m.Groups["versionName"].Value : null;
524+
}
525+
487526
}
488527
public static class LocationStringExtensions
489528
{

0 commit comments

Comments
 (0)