-
Notifications
You must be signed in to change notification settings - Fork 4.1k
[Network]Add Microsoft.Network/privateLinkServices configuration to support the private endpoint connection #18000
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 5 commits
c5f8873
9e40299
f1adfcd
12de965
2f832fc
0637d53
99c59f2
c56d6e7
b7db4df
09f1d17
822ca1e
f2ef74e
7bd8a93
6e4633b
be3623f
3874144
2b7b517
0053cea
08dce7f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -60,9 +60,10 @@ public abstract class PrivateEndpointConnectionBaseCmdlet : NetworkBaseCmdlet, I | |
| string NamedContextParameterSet = "ByResource"; | ||
| public new object GetDynamicParameters() | ||
| { | ||
| InvocationInfo invocationInfo = MyInvocation; | ||
| var parameters = new RuntimeDefinedParameterDictionary(); | ||
| RuntimeDefinedParameter namedParameter; | ||
| if (ProviderConfiguration.TryGetProvideServiceParameter(privateEndpointTypeName, NamedContextParameterSet, out namedParameter)) | ||
| if (ProviderConfiguration.TryGetProvideServiceParameter("PEC", privateEndpointTypeName, NamedContextParameterSet, out namedParameter)) | ||
| { | ||
| parameters.Add(privateEndpointTypeName, namedParameter); | ||
| } | ||
|
|
@@ -76,6 +77,8 @@ public abstract class PrivateEndpointConnectionBaseCmdlet : NetworkBaseCmdlet, I | |
|
|
||
| protected IPrivateLinkProvider BuildProvider(string subscription, string privateLinkResourceType) | ||
| { | ||
| if (!GenericProvider.SupportsPrivateLinkResourceType(privateLinkResourceType)) | ||
|
||
| throw new System.Exception($"The {privateLinkResourceType} doesn't support private endpoint connection"); | ||
LucasYao93 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| return PrivateLinkProviderFactory.CreatePrivateLinkProvder(this, subscription, privateLinkResourceType); | ||
| } | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -52,6 +52,7 @@ static ProviderConfiguration() | |
| RegisterConfiguration("Microsoft.Migrate/assessmentProjects", "2020-05-01-preview", false, false); | ||
| RegisterConfiguration("Microsoft.Migrate/migrateProjects", "2020-06-01-preview", false, false); | ||
| RegisterConfiguration("Microsoft.Network/applicationgateways", "2020-05-01", true, false); | ||
| RegisterConfiguration("Microsoft.Network/privateLinkServices", "2020-05-01", true, false, false); | ||
| RegisterConfiguration("Microsoft.OffAzure/masterSites", "2020-07-07", false, false); | ||
| RegisterConfiguration("Microsoft.PowerBI/privateLinkServicesForPowerBI", "2020-06-01", false, true); | ||
| RegisterConfiguration("Microsoft.Purview/accounts", "2020-12-01-preview", true, true); | ||
|
|
@@ -71,50 +72,62 @@ static ProviderConfiguration() | |
| RegisterConfiguration("Microsoft.Web/hostingEnvironments", "2020-10-01", true, false); | ||
| RegisterConfiguration("Microsoft.BotService/botServices", "2021-05-01-preview", true, true); | ||
| } | ||
|
|
||
| private static void RegisterConfiguration(string type, string apiVersion, bool hasConnectionsURI = false, bool hasResourceURI = false) | ||
| /// <summary> | ||
| /// Register private endpoint connection and private link resource configuration | ||
| /// </summary> | ||
| /// <param name="type">Resource type</param> | ||
| /// <param name="apiVersion">Resource api version</param> | ||
| /// <param name="hasConnectionsURI">True if the private endpoint connection can be list by URL <see cref="GenericProvider.BuildPrivateEndpointConnectionsURL(string, string)"/>, otherwise it can be list by URL <see cref="GenericProvider.BuildPrivateEndpointConnectionsOwnerURL(string, string)"/></param> | ||
| /// <param name="supportGetPrivateLinkResource">True if the private link resource can be get by Id, otherwise it can be list</param> | ||
| /// <param name="supportPrivateLinkResource">True if the private link resource be supported, otherwise false</param> | ||
LucasYao93 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| private static void RegisterConfiguration(string type, string apiVersion, bool hasConnectionsURI = false, bool supportGetPrivateLinkResource = false, bool supportPrivateLinkResource = true) | ||
| { | ||
| ProviderConfiguration configuration = new ProviderConfiguration | ||
| { | ||
| Type = type, | ||
| ApiVersion = apiVersion, | ||
| HasConnectionsURI = hasConnectionsURI, | ||
| HasResourceURI = hasResourceURI | ||
| SupportGetPrivateLinkResource = supportGetPrivateLinkResource, | ||
| SupportPrivateLinkResource = supportPrivateLinkResource, | ||
LucasYao93 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| }; | ||
| _configurations.Add(type, configuration); | ||
| } | ||
|
|
||
| public string Type { get; set; } | ||
| public string ApiVersion { get; set; } | ||
| public bool HasConnectionsURI { get; set; } | ||
| public bool HasResourceURI { get; set; } | ||
| public bool SupportGetPrivateLinkResource { get; set; } | ||
| public bool SupportPrivateLinkResource { get; set; } | ||
|
|
||
| public static ProviderConfiguration GetProviderConfiguration(string type) | ||
| { | ||
| return _configurations[type]; | ||
| ProviderConfiguration outProviderConfiguration = null; | ||
| _configurations.TryGetValue(type, out outProviderConfiguration); | ||
| return outProviderConfiguration; | ||
| } | ||
|
|
||
| /// <summary> | ||
| /// Generate a runtime parameter with ValidateSet matching the current context | ||
| /// </summary> | ||
| /// <param name="serviceType">Has two value, PLR => private link resource, PEC => private endpoint connection.</param> | ||
| /// <param name="name">The name of the parameter</param> | ||
| /// <param name="runtimeParameter">The returned runtime parameter for context, with appropriate validate set</param> | ||
| /// <returns>True if one or more contexts were found, otherwise false</returns> | ||
| public static bool TryGetProvideServiceParameter(string name, string parameterSetName, out RuntimeDefinedParameter runtimeParameter) | ||
| public static bool TryGetProvideServiceParameter(string serviceType, string name, string parameterSetName, out RuntimeDefinedParameter runtimeParameter) | ||
|
||
| { | ||
| var result = false; | ||
| runtimeParameter = null; | ||
| if (_configurations != null && _configurations.Values != null) | ||
| { | ||
| var ObjArray = _configurations.Values.ToArray(); | ||
| var ProvideTypeList = ObjArray.Select(c => c.Type).ToArray(); | ||
| var ProvideTypeList = serviceType.ToUpper() == "PLR" ? ObjArray.Where(c => c.SupportPrivateLinkResource).Select(c => c.Type).ToArray() : ObjArray.Select(c => c.Type).ToArray(); | ||
LucasYao93 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| runtimeParameter = new RuntimeDefinedParameter( | ||
| name, typeof(string), | ||
| new Collection<Attribute>() | ||
| { | ||
| new ParameterAttribute { Mandatory = false, | ||
| ValueFromPipeline = true, | ||
| HelpMessage = "The private link resource type.", | ||
| HelpMessage = "The resource provider and resource type which supports private link resource.", | ||
| ParameterSetName = parameterSetName }, | ||
| new ValidateSetAttribute(ProvideTypeList) | ||
| } | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.