You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Resources/GetAzureResourceCmdlet.cs ShouldConstructResourceId incorrectly uses 'DefaultApiVersion' with parameter set -ResourceGroupName -Name -ResourceType -ExpandProperties
This can cause missing data in returned resources.
This does not occur when using parameters -ResourceGroupName -Name -ExpandProperties
submitting PR with potential fix in ShouldConstructResourceId
Steps to reproduce
Good Output / apiVersion without -ResourceType
# works as GET request uses apiVersion 2019-03-01# response contains resources (addonFeatures) only implemented in newer apiVersions that DefaultApiVersion 2016-03-01<#"addonFeatures": [ "DnsService", "RepairManager" ],#>$resource=get-azresource-ResourceGroupName $resourceGroupName-name $clusterName-ExpandProperties
<#DEBUG: ============================ HTTP REQUEST ============================HTTP Method:GETAbsolute Uri:https://management.azure.com/subscriptions/{{subscription}}/resourceGroups/{{resourceGroupName}}/resources?$filter=name EQ '{{resourceGroupName}}'&api-version=2016-09-01DEBUG: ============================ HTTP REQUEST ============================HTTP Method:GETAbsolute Uri:https://management.azure.com/subscriptions/{{subscription}}/resourceGroups/{{resourceGroupName}}/providers/Microsoft.ServiceFabric/clusters/{{resourceGroupName}}?api-version=2019-03-01#>
Bad output / default apiVersion with -ResourceType
# does not work# one get for ResourceType# one get for resource using 'DefaultApiVersion' for resourceType (=2016-09-01) even though provided parameters build the resourceuri# result is missing resource information (addonFeatures) as resourceType was built with apiVersion (2019-03-01)$resource=get-azresource-ResourceGroupName $resourceGroupName-name $clusterName-ExpandProperties -ResourceType Microsoft.ServiceFabric/clusters
<#DEBUG: ============================ HTTP REQUEST ============================HTTP Method:GETAbsolute Uri:https://management.azure.com/subscriptions/{{subscription}}/providers/Microsoft.ServiceFabric?api-version=2019-07-01DEBUG: ============================ HTTP REQUEST ============================HTTP Method:GETAbsolute Uri:https://management.azure.com//subscriptions/{{subscription}}/resourceGroups/{{resourceGroupName}}/providers/Microsoft.ServiceFabric/clusters/{{resourceGroupName}}?api-version=2016-09-01#>
Environment data
$PSVersionTable
Name Value
---- -----
PSVersion 7.0.0
PSEdition Core
GitCommitId 7.0.0
OS Microsoft Windows 10.0.18363
Platform Win32NT
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0
Module versions
ModuleType Version PreRelease Name ExportedCommands
-----------------------------------------------
Manifest 1.7.3 az.accounts {Add-AzEnvironment,Clear-AzContext,Clear-AzDefau…
Manifest 1.12.0 az.Resources {Add-AzADGroupMember,Export-AzResourceGroup, Get-…
updated issue with http response debug output with apiversions from servicefabric. if thats issue, then pr #11268 not needed though would handle that type of scenario i think
without fix:
this.ApiVersion is null
this.DefaultApiVersion is 2016-09-01 constant
this.DefaultApiVersion = string.IsNullOrWhiteSpace(this.ApiVersion) ? Constants.ResourcesApiVersion : this.ApiVersion;
calls getbyid(resourceid, this.DefaultApiVersion)
function getbyid(resourceid, apiVersion)
if (resourceType != null)
{
apiVersion = resourceType.ApiVersions.Contains(apiVersion) ? apiVersion : resourceType.ApiVersions.FirstOrDefault();
if (!string.IsNullOrEmpty(apiVersion))
{
return new PSResource(ResourceManagementClient.Resources.GetById(resourceId, apiVersion));
}
}
…t-cs
Resources/GetAzureResourceCmdlet.cs fixAzure#11267 get-azresource to use actual apiVersion of resource with parameter set -ResourceGroupName -Name -ExpandProperties -ResourceType
Description
Resources/GetAzureResourceCmdlet.cs ShouldConstructResourceId incorrectly uses 'DefaultApiVersion' with parameter set -ResourceGroupName -Name -ResourceType -ExpandProperties
This can cause missing data in returned resources.
This does not occur when using parameters -ResourceGroupName -Name -ExpandProperties
submitting PR with potential fix in ShouldConstructResourceId
Steps to reproduce
Good Output / apiVersion without -ResourceType
Bad output / default apiVersion with -ResourceType
Environment data
Module versions
Debug output
Bad output with ResourceType
Error output
The text was updated successfully, but these errors were encountered: