Skip to content

Commit 0b556fc

Browse files
authored
Merge pull request #9155 from mojayara/AzAdvisor-GetRec-fix
Az Advisor Cmdlets - optimized utils.
2 parents 5ea221a + 3a24411 commit 0b556fc

File tree

2 files changed

+8
-17
lines changed

2 files changed

+8
-17
lines changed

src/Advisor/Advisor/ChangeLog.md

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1+
12
<!--
23
Please leave this section at the top of the change log.
34
4-
Changes for the current release should go under the section titled "Current Release", and should adhere to the following format:
5+
Changes for the upcoming release should go under the section titled "Upcoming Release", and should adhere to the following format:
56
6-
## Current Release
7+
## Upcoming Release
78
* Overview of change #1
89
- Additional information about change #1
910
* Overview of change #2
@@ -17,14 +18,14 @@
1718
* Overview of change #1
1819
- Additional information about change #1
1920
-->
20-
2121
## Upcoming Release
22+
* Updated utils to be extensible for future changes
2223

2324
## Version 0.1.0
24-
*Added new cmdlets for Advisor Recommendation
25+
* Added new cmdlets for Advisor Recommendation
2526
- Get-AzAdvisorRecommendation
2627
- Enable-AzAdvisorRecommendation
2728
- Disable-AzAdvisorRecommendation
28-
*Added new cmdlets for Advisor Configuration
29+
* Added new cmdlets for Advisor Configuration
2930
- Get-AzAdvisorConfiguration
3031
- Set-AzAdvisorConfiguration

src/Advisor/Advisor/Cmdlets/Utilities/RecommendationHelper.cs

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -35,16 +35,6 @@ public static class RecommendationHelper
3535
/// </summary>
3636
private const int RESOURCEGROUP_VALUE_POSITION = 4;
3737

38-
/// <summary>
39-
/// Position of recommendation-Id string in resource ID
40-
/// </summary>
41-
private const int RECOMMENDATION_STRING_POSITION = 11;
42-
43-
/// <summary>
44-
/// Position of recommendation-Id value in resource ID
45-
/// </summary>
46-
private const int RECOMMENDATION_VALUE_POSITION = 12;
47-
4838
/// <summary>
4939
/// Filter recommendations by given category and resourceGroup name.
5040
/// </summary>
@@ -205,9 +195,9 @@ public static string GetRecommendationIdFromResourceID(string resourceID)
205195
string recommendationId = string.Empty;
206196
string[] resourceIdSplit = resourceID.Split('/');
207197

208-
if (resourceIdSplit[RECOMMENDATION_STRING_POSITION].Equals("recommendations"))
198+
if (resourceIdSplit[resourceIdSplit.Length - 2].Equals("recommendations"))
209199
{
210-
recommendationId = resourceIdSplit[RECOMMENDATION_VALUE_POSITION];
200+
recommendationId = resourceIdSplit[resourceIdSplit.Length - 1];
211201
}
212202

213203
return recommendationId;

0 commit comments

Comments
 (0)