Skip to content

Commit 8e0abe0

Browse files
authored
[KeyVault] Supported user assigned identity for MHSM (#23130)
* upgrade sdk for mhsm to 2023-07-01 * Supported user assigned identity for Managed HSM in New/Update-AzKeyVaultManagedHsm * refine output and example * test case wip * fix patch identity * refine examples * record test cases for new API version * fix autorest.powershell in 4.0.631 to avoid comments issue in latst version * code polish * Update src/KeyVault/KeyVault/help/Update-AzKeyVaultManagedHsm.md * Update README.md
1 parent e954237 commit 8e0abe0

30 files changed

+25372
-4702
lines changed

src/KeyVault/KeyVault.Sdk/Generated/MHSMPrivateEndpointConnectionsOperations.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ internal MhsmPrivateEndpointConnectionsOperations (KeyVaultManagementClient clie
8989
throw new Microsoft.Rest.ValidationException(Microsoft.Rest.ValidationRules.CannotBeNull, "name");
9090
}
9191

92-
string apiVersion = "2023-02-01";
92+
string apiVersion = "2023-07-01";
9393
// Tracing
9494
bool _shouldTrace = Microsoft.Rest.ServiceClientTracing.IsEnabled;
9595
string _invocationId = null;
@@ -302,7 +302,7 @@ internal MhsmPrivateEndpointConnectionsOperations (KeyVaultManagementClient clie
302302
throw new Microsoft.Rest.ValidationException(Microsoft.Rest.ValidationRules.CannotBeNull, "privateEndpointConnectionName");
303303
}
304304

305-
string apiVersion = "2023-02-01";
305+
string apiVersion = "2023-07-01";
306306
// Tracing
307307
bool _shouldTrace = Microsoft.Rest.ServiceClientTracing.IsEnabled;
308308
string _invocationId = null;
@@ -525,7 +525,7 @@ internal MhsmPrivateEndpointConnectionsOperations (KeyVaultManagementClient clie
525525
throw new Microsoft.Rest.ValidationException(Microsoft.Rest.ValidationRules.CannotBeNull, "privateEndpointConnectionName");
526526
}
527527

528-
string apiVersion = "2023-02-01";
528+
string apiVersion = "2023-07-01";
529529
// Tracing
530530
bool _shouldTrace = Microsoft.Rest.ServiceClientTracing.IsEnabled;
531531
string _invocationId = null;
@@ -790,7 +790,7 @@ internal MhsmPrivateEndpointConnectionsOperations (KeyVaultManagementClient clie
790790
throw new Microsoft.Rest.ValidationException(Microsoft.Rest.ValidationRules.CannotBeNull, "privateEndpointConnectionName");
791791
}
792792

793-
string apiVersion = "2023-02-01";
793+
string apiVersion = "2023-07-01";
794794
// Tracing
795795
bool _shouldTrace = Microsoft.Rest.ServiceClientTracing.IsEnabled;
796796
string _invocationId = null;

src/KeyVault/KeyVault.Sdk/Generated/MHSMPrivateLinkResourcesOperations.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ internal MhsmPrivateLinkResourcesOperations (KeyVaultManagementClient client)
8989
throw new Microsoft.Rest.ValidationException(Microsoft.Rest.ValidationRules.CannotBeNull, "name");
9090
}
9191

92-
string apiVersion = "2023-02-01";
92+
string apiVersion = "2023-07-01";
9393
// Tracing
9494
bool _shouldTrace = Microsoft.Rest.ServiceClientTracing.IsEnabled;
9595
string _invocationId = null;

src/KeyVault/KeyVault.Sdk/Generated/MHSMRegionsOperations.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ internal MhsmRegionsOperations (KeyVaultManagementClient client)
8989
throw new Microsoft.Rest.ValidationException(Microsoft.Rest.ValidationRules.CannotBeNull, "name");
9090
}
9191

92-
string apiVersion = "2023-02-01";
92+
string apiVersion = "2023-07-01";
9393
// Tracing
9494
bool _shouldTrace = Microsoft.Rest.ServiceClientTracing.IsEnabled;
9595
string _invocationId = null;

src/KeyVault/KeyVault.Sdk/Generated/ManagedHsmsOperations.cs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ internal ManagedHsmsOperations (KeyVaultManagementClient client)
161161
throw new Microsoft.Rest.ValidationException(Microsoft.Rest.ValidationRules.CannotBeNull, "this.Client.SubscriptionId");
162162
}
163163

164-
string apiVersion = "2023-02-01";
164+
string apiVersion = "2023-07-01";
165165
// Tracing
166166
bool _shouldTrace = Microsoft.Rest.ServiceClientTracing.IsEnabled;
167167
string _invocationId = null;
@@ -362,7 +362,7 @@ internal ManagedHsmsOperations (KeyVaultManagementClient client)
362362
throw new Microsoft.Rest.ValidationException(Microsoft.Rest.ValidationRules.CannotBeNull, "this.Client.SubscriptionId");
363363
}
364364

365-
string apiVersion = "2023-02-01";
365+
string apiVersion = "2023-07-01";
366366
// Tracing
367367
bool _shouldTrace = Microsoft.Rest.ServiceClientTracing.IsEnabled;
368368
string _invocationId = null;
@@ -558,7 +558,7 @@ internal ManagedHsmsOperations (KeyVaultManagementClient client)
558558
throw new Microsoft.Rest.ValidationException(Microsoft.Rest.ValidationRules.CannotBeNull, "this.Client.SubscriptionId");
559559
}
560560

561-
string apiVersion = "2023-02-01";
561+
string apiVersion = "2023-07-01";
562562
// Tracing
563563
bool _shouldTrace = Microsoft.Rest.ServiceClientTracing.IsEnabled;
564564
string _invocationId = null;
@@ -748,7 +748,7 @@ internal ManagedHsmsOperations (KeyVaultManagementClient client)
748748
throw new Microsoft.Rest.ValidationException(Microsoft.Rest.ValidationRules.CannotBeNull, "this.Client.SubscriptionId");
749749
}
750750

751-
string apiVersion = "2023-02-01";
751+
string apiVersion = "2023-07-01";
752752
// Tracing
753753
bool _shouldTrace = Microsoft.Rest.ServiceClientTracing.IsEnabled;
754754
string _invocationId = null;
@@ -949,7 +949,7 @@ internal ManagedHsmsOperations (KeyVaultManagementClient client)
949949
throw new Microsoft.Rest.ValidationException(Microsoft.Rest.ValidationRules.CannotBeNull, "this.Client.SubscriptionId");
950950
}
951951

952-
string apiVersion = "2023-02-01";
952+
string apiVersion = "2023-07-01";
953953
// Tracing
954954
bool _shouldTrace = Microsoft.Rest.ServiceClientTracing.IsEnabled;
955955
string _invocationId = null;
@@ -1171,7 +1171,7 @@ internal ManagedHsmsOperations (KeyVaultManagementClient client)
11711171
throw new Microsoft.Rest.ValidationException(Microsoft.Rest.ValidationRules.CannotBeNull, "this.Client.SubscriptionId");
11721172
}
11731173

1174-
string apiVersion = "2023-02-01";
1174+
string apiVersion = "2023-07-01";
11751175
// Tracing
11761176
bool _shouldTrace = Microsoft.Rest.ServiceClientTracing.IsEnabled;
11771177
string _invocationId = null;
@@ -1395,7 +1395,7 @@ internal ManagedHsmsOperations (KeyVaultManagementClient client)
13951395
throw new Microsoft.Rest.ValidationException(Microsoft.Rest.ValidationRules.CannotBeNull, "this.Client.SubscriptionId");
13961396
}
13971397

1398-
string apiVersion = "2023-02-01";
1398+
string apiVersion = "2023-07-01";
13991399
// Tracing
14001400
bool _shouldTrace = Microsoft.Rest.ServiceClientTracing.IsEnabled;
14011401
string _invocationId = null;
@@ -1645,7 +1645,7 @@ internal ManagedHsmsOperations (KeyVaultManagementClient client)
16451645
throw new Microsoft.Rest.ValidationException(Microsoft.Rest.ValidationRules.CannotBeNull, "this.Client.SubscriptionId");
16461646
}
16471647

1648-
string apiVersion = "2023-02-01";
1648+
string apiVersion = "2023-07-01";
16491649
// Tracing
16501650
bool _shouldTrace = Microsoft.Rest.ServiceClientTracing.IsEnabled;
16511651
string _invocationId = null;
@@ -1885,7 +1885,7 @@ internal ManagedHsmsOperations (KeyVaultManagementClient client)
18851885
throw new Microsoft.Rest.ValidationException(Microsoft.Rest.ValidationRules.CannotBeNull, "this.Client.SubscriptionId");
18861886
}
18871887

1888-
string apiVersion = "2023-02-01";
1888+
string apiVersion = "2023-07-01";
18891889
// Tracing
18901890
bool _shouldTrace = Microsoft.Rest.ServiceClientTracing.IsEnabled;
18911891
string _invocationId = null;
@@ -2082,7 +2082,7 @@ internal ManagedHsmsOperations (KeyVaultManagementClient client)
20822082
throw new Microsoft.Rest.ValidationException(Microsoft.Rest.ValidationRules.CannotBeNull, "this.Client.SubscriptionId");
20832083
}
20842084

2085-
string apiVersion = "2023-02-01";
2085+
string apiVersion = "2023-07-01";
20862086
// Tracing
20872087
bool _shouldTrace = Microsoft.Rest.ServiceClientTracing.IsEnabled;
20882088
string _invocationId = null;

src/KeyVault/KeyVault.Sdk/Generated/Models/ManagedHsm.cs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,11 +46,14 @@ public ManagedHsm()
4646
/// resource.
4747
/// </param>
4848

49+
/// <param name="identity">Managed service identity (system assigned and/or user assigned identities)
50+
/// </param>
51+
4952
/// <param name="properties">Properties of the managed HSM
5053
/// </param>
51-
public ManagedHsm(string id = default(string), string name = default(string), string type = default(string), string location = default(string), ManagedHsmSku sku = default(ManagedHsmSku), System.Collections.Generic.IDictionary<string, string> tags = default(System.Collections.Generic.IDictionary<string, string>), SystemData systemData = default(SystemData), ManagedHsmProperties properties = default(ManagedHsmProperties))
54+
public ManagedHsm(string id = default(string), string name = default(string), string type = default(string), string location = default(string), ManagedHsmSku sku = default(ManagedHsmSku), System.Collections.Generic.IDictionary<string, string> tags = default(System.Collections.Generic.IDictionary<string, string>), SystemData systemData = default(SystemData), ManagedServiceIdentity identity = default(ManagedServiceIdentity), ManagedHsmProperties properties = default(ManagedHsmProperties))
5255

53-
: base(id, name, type, location, sku, tags, systemData)
56+
: base(id, name, type, location, sku, tags, systemData, identity)
5457
{
5558
this.Properties = properties;
5659
CustomInit();

src/KeyVault/KeyVault.Sdk/Generated/Models/ManagedHsmResource.cs

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,10 @@ public ManagedHsmResource()
4545
/// <param name="systemData">Metadata pertaining to creation and last modification of the key vault
4646
/// resource.
4747
/// </param>
48-
public ManagedHsmResource(string id = default(string), string name = default(string), string type = default(string), string location = default(string), ManagedHsmSku sku = default(ManagedHsmSku), System.Collections.Generic.IDictionary<string, string> tags = default(System.Collections.Generic.IDictionary<string, string>), SystemData systemData = default(SystemData))
48+
49+
/// <param name="identity">Managed service identity (system assigned and/or user assigned identities)
50+
/// </param>
51+
public ManagedHsmResource(string id = default(string), string name = default(string), string type = default(string), string location = default(string), ManagedHsmSku sku = default(ManagedHsmSku), System.Collections.Generic.IDictionary<string, string> tags = default(System.Collections.Generic.IDictionary<string, string>), SystemData systemData = default(SystemData), ManagedServiceIdentity identity = default(ManagedServiceIdentity))
4952

5053
{
5154
this.Id = id;
@@ -55,6 +58,7 @@ public ManagedHsmResource()
5558
this.Sku = sku;
5659
this.Tags = tags;
5760
this.SystemData = systemData;
61+
this.Identity = identity;
5862
CustomInit();
5963
}
6064

@@ -107,6 +111,13 @@ public ManagedHsmResource()
107111
/// </summary>
108112
[Newtonsoft.Json.JsonProperty(PropertyName = "systemData")]
109113
public SystemData SystemData {get; private set; }
114+
115+
/// <summary>
116+
/// Gets or sets managed service identity (system assigned and/or user assigned
117+
/// identities)
118+
/// </summary>
119+
[Newtonsoft.Json.JsonProperty(PropertyName = "identity")]
120+
public ManagedServiceIdentity Identity {get; set; }
110121
/// <summary>
111122
/// Validate the object.
112123
/// </summary>
@@ -125,6 +136,10 @@ public virtual void Validate()
125136
}
126137

127138

139+
if (this.Identity != null)
140+
{
141+
this.Identity.Validate();
142+
}
128143
}
129144
}
130145
}
Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
// Copyright (c) Microsoft Corporation. All rights reserved.
2+
// Licensed under the MIT License. See License.txt in the project root for license information.
3+
// Code generated by Microsoft (R) AutoRest Code Generator.
4+
// Changes may cause incorrect behavior and will be lost if the code is regenerated.
5+
6+
namespace Microsoft.Azure.Management.KeyVault.Models
7+
{
8+
using System.Linq;
9+
10+
/// <summary>
11+
/// Managed service identity (system assigned and/or user assigned identities)
12+
/// </summary>
13+
public partial class ManagedServiceIdentity
14+
{
15+
/// <summary>
16+
/// Initializes a new instance of the ManagedServiceIdentity class.
17+
/// </summary>
18+
public ManagedServiceIdentity()
19+
{
20+
CustomInit();
21+
}
22+
23+
/// <summary>
24+
/// Initializes a new instance of the ManagedServiceIdentity class.
25+
/// </summary>
26+
27+
/// <param name="principalId">The service principal ID of the system assigned identity. This property
28+
/// will only be provided for a system assigned identity.
29+
/// </param>
30+
31+
/// <param name="tenantId">The tenant ID of the system assigned identity. This property will only be
32+
/// provided for a system assigned identity.
33+
/// </param>
34+
35+
/// <param name="type">Type of managed service identity (where both SystemAssigned and
36+
/// UserAssigned types are allowed).
37+
/// Possible values include: 'None', 'SystemAssigned', 'UserAssigned',
38+
/// 'SystemAssigned,UserAssigned'</param>
39+
40+
/// <param name="userAssignedIdentities">The set of user assigned identities associated with the resource. The
41+
/// userAssignedIdentities dictionary keys will be ARM resource ids in the
42+
/// form:
43+
/// &#39;/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{identityName}.
44+
/// The dictionary values can be empty objects ({}) in requests.
45+
/// </param>
46+
public ManagedServiceIdentity(string type, System.Guid? principalId = default(System.Guid?), System.Guid? tenantId = default(System.Guid?), System.Collections.Generic.IDictionary<string, UserAssignedIdentity> userAssignedIdentities = default(System.Collections.Generic.IDictionary<string, UserAssignedIdentity>))
47+
48+
{
49+
this.PrincipalId = principalId;
50+
this.TenantId = tenantId;
51+
this.Type = type;
52+
this.UserAssignedIdentities = userAssignedIdentities;
53+
CustomInit();
54+
}
55+
56+
/// <summary>
57+
/// An initialization method that performs custom operations like setting defaults
58+
/// </summary>
59+
partial void CustomInit();
60+
61+
62+
/// <summary>
63+
/// Gets the service principal ID of the system assigned identity. This
64+
/// property will only be provided for a system assigned identity.
65+
/// </summary>
66+
[Newtonsoft.Json.JsonProperty(PropertyName = "principalId")]
67+
public System.Guid? PrincipalId {get; private set; }
68+
69+
/// <summary>
70+
/// Gets the tenant ID of the system assigned identity. This property will only
71+
/// be provided for a system assigned identity.
72+
/// </summary>
73+
[Newtonsoft.Json.JsonProperty(PropertyName = "tenantId")]
74+
public System.Guid? TenantId {get; private set; }
75+
76+
/// <summary>
77+
/// Gets or sets type of managed service identity (where both SystemAssigned
78+
/// and UserAssigned types are allowed). Possible values include: &#39;None&#39;, &#39;SystemAssigned&#39;, &#39;UserAssigned&#39;, &#39;SystemAssigned,UserAssigned&#39;
79+
/// </summary>
80+
[Newtonsoft.Json.JsonProperty(PropertyName = "type")]
81+
public string Type {get; set; }
82+
83+
/// <summary>
84+
/// Gets or sets the set of user assigned identities associated with the
85+
/// resource. The userAssignedIdentities dictionary keys will be ARM resource
86+
/// ids in the form:
87+
/// &#39;/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{identityName}.
88+
/// The dictionary values can be empty objects ({}) in requests.
89+
/// </summary>
90+
[Newtonsoft.Json.JsonProperty(PropertyName = "userAssignedIdentities")]
91+
public System.Collections.Generic.IDictionary<string, UserAssignedIdentity> UserAssignedIdentities {get; set; }
92+
/// <summary>
93+
/// Validate the object.
94+
/// </summary>
95+
/// <exception cref="Microsoft.Rest.ValidationException">
96+
/// Thrown if validation fails
97+
/// </exception>
98+
public virtual void Validate()
99+
{
100+
if (this.Type == null)
101+
{
102+
throw new Microsoft.Rest.ValidationException(Microsoft.Rest.ValidationRules.CannotBeNull, "Type");
103+
}
104+
105+
106+
}
107+
}
108+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
// Copyright (c) Microsoft Corporation. All rights reserved.
2+
// Licensed under the MIT License. See License.txt in the project root for license information.
3+
// Code generated by Microsoft (R) AutoRest Code Generator.
4+
// Changes may cause incorrect behavior and will be lost if the code is regenerated.
5+
6+
namespace Microsoft.Azure.Management.KeyVault.Models
7+
{
8+
9+
/// <summary>
10+
/// Defines values for ManagedServiceIdentityType.
11+
/// </summary>
12+
13+
14+
public static class ManagedServiceIdentityType
15+
{
16+
public const string None = "None";
17+
public const string SystemAssigned = "SystemAssigned";
18+
public const string UserAssigned = "UserAssigned";
19+
public const string SystemAssignedUserAssigned = "SystemAssigned,UserAssigned";
20+
}
21+
}

src/KeyVault/KeyVault.Sdk/Generated/Models/MhsmPrivateLinkResource.cs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,9 @@ public MhsmPrivateLinkResource()
4747
/// resource.
4848
/// </param>
4949

50+
/// <param name="identity">Managed service identity (system assigned and/or user assigned identities)
51+
/// </param>
52+
5053
/// <param name="groupId">Group identifier of private link resource.
5154
/// </param>
5255

@@ -55,9 +58,9 @@ public MhsmPrivateLinkResource()
5558

5659
/// <param name="requiredZoneNames">Required DNS zone names of the the private link resource.
5760
/// </param>
58-
public MhsmPrivateLinkResource(string id = default(string), string name = default(string), string type = default(string), string location = default(string), ManagedHsmSku sku = default(ManagedHsmSku), System.Collections.Generic.IDictionary<string, string> tags = default(System.Collections.Generic.IDictionary<string, string>), SystemData systemData = default(SystemData), string groupId = default(string), System.Collections.Generic.IList<string> requiredMembers = default(System.Collections.Generic.IList<string>), System.Collections.Generic.IList<string> requiredZoneNames = default(System.Collections.Generic.IList<string>))
61+
public MhsmPrivateLinkResource(string id = default(string), string name = default(string), string type = default(string), string location = default(string), ManagedHsmSku sku = default(ManagedHsmSku), System.Collections.Generic.IDictionary<string, string> tags = default(System.Collections.Generic.IDictionary<string, string>), SystemData systemData = default(SystemData), ManagedServiceIdentity identity = default(ManagedServiceIdentity), string groupId = default(string), System.Collections.Generic.IList<string> requiredMembers = default(System.Collections.Generic.IList<string>), System.Collections.Generic.IList<string> requiredZoneNames = default(System.Collections.Generic.IList<string>))
5962

60-
: base(id, name, type, location, sku, tags, systemData)
63+
: base(id, name, type, location, sku, tags, systemData, identity)
6164
{
6265
this.GroupId = groupId;
6366
this.RequiredMembers = requiredMembers;

0 commit comments

Comments
 (0)