Skip to content

Commit bee4218

Browse files
Fix broken parameter sets (#21082)
Co-authored-by: Beisi Zhou <[email protected]>
1 parent e0a5f0f commit bee4218

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

src/Ssh/Ssh/Common/SshBaseCmdlet.cs

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -369,6 +369,19 @@ protected internal void ValidateParameters()
369369

370370
protected internal void SetResourceType()
371371
{
372+
if (ParameterSetName.Equals(IpAddressParameterSet))
373+
{
374+
ResourceType = "Microsoft.Compute/virtualMachines";
375+
return;
376+
}
377+
if (ParameterSetName.Equals(ResourceIdParameterSet))
378+
{
379+
ResourceIdentifier idParser = new ResourceIdentifier(ResourceId);
380+
ResourceGroupName = idParser.ResourceGroupName;
381+
Name = idParser.ResourceName;
382+
ResourceType = idParser.ResourceType;
383+
}
384+
372385
var resourcetypefilter = supportedResourceTypes.Select(type => $"resourceType eq '{type}'").ToArray();
373386
String filter = $"$filter=name eq '{Name}' and ({String.Join(" or ", resourcetypefilter)})";
374387
ODataQuery<GenericResourceFilter> query = new ODataQuery<GenericResourceFilter>(filter);
@@ -390,7 +403,7 @@ protected internal void SetResourceType()
390403

391404
if (ResourceType != null)
392405
{
393-
if (!types.Contains(ResourceType))
406+
if (!types.Contains(ResourceType, StringComparer.CurrentCultureIgnoreCase))
394407
{
395408
throw new AzPSResourceNotFoundCloudException(String.Format(Resources.ResourceNotFoundTypeProvided,Name, ResourceType, ResourceGroupName));
396409
}

0 commit comments

Comments
 (0)