Skip to content

[Az.Ssh] Bug Fix #21082

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

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion src/Ssh/Ssh/Common/SshBaseCmdlet.cs
Original file line number Diff line number Diff line change
Expand Up @@ -369,6 +369,19 @@ protected internal void ValidateParameters()

protected internal void SetResourceType()
{
if (ParameterSetName.Equals(IpAddressParameterSet))
{
ResourceType = "Microsoft.Compute/virtualMachines";
return;
}
if (ParameterSetName.Equals(ResourceIdParameterSet))
{
ResourceIdentifier idParser = new ResourceIdentifier(ResourceId);
ResourceGroupName = idParser.ResourceGroupName;
Name = idParser.ResourceName;
ResourceType = idParser.ResourceType;
}

var resourcetypefilter = supportedResourceTypes.Select(type => $"resourceType eq '{type}'").ToArray();
String filter = $"$filter=name eq '{Name}' and ({String.Join(" or ", resourcetypefilter)})";
ODataQuery<GenericResourceFilter> query = new ODataQuery<GenericResourceFilter>(filter);
Expand All @@ -390,7 +403,7 @@ protected internal void SetResourceType()

if (ResourceType != null)
{
if (!types.Contains(ResourceType))
if (!types.Contains(ResourceType, StringComparer.CurrentCultureIgnoreCase))
{
throw new AzPSResourceNotFoundCloudException(String.Format(Resources.ResourceNotFoundTypeProvided,Name, ResourceType, ResourceGroupName));
}
Expand Down