-
Notifications
You must be signed in to change notification settings - Fork 3.9k
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
Introduce Azure Maps cmdlets #6259
Conversation
@jp94 Looks like the reason the build is failing is because the online help link is not added to the help files: https://azuresdkci.westus2.cloudapp.azure.com/job/powershell/4635/ (ValidateHelpIssues.csv). |
@jp94 Doing a comparison of the file structures: it looks like you have forgotten to remove a folder in the Test/SessionsRecords folder: Previous (correct): https://github.com/Azure/azure-powershell/tree/preview/src/ResourceManager/LocationBasedServices/LocationBasedServices.Test/SessionRecords Looks like you need to remove the LocationBasedServices.Test folder. |
@maddieclayton For second comment, I think you were looking at the wrong branch jp94:preview rather than jp94:maps. Also, I realized that I've submitted a PR with renaming LocationBasedServices to Maps. Thanks. |
# Test | ||
$accountname = 'ps-' + $rgname; | ||
$skuname = 'S0'; | ||
$location = 'West US'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be Get-Location 'Microsoft.Maps' 'accounts' 'West US';
Apply everywhere.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changing to $location = Get-Location -providerNamespace 'Microsoft.Maps' -resourceType 'accounts' -preferredLocation 'West US';
or Get-Location 'Microsoft.Maps' 'accounts' 'West US';
yields this error:
Test Name: Microsoft.Azure.Commands.Maps.Test.ScenarioTests.MapsAccountTests.TestGetAccounts
Test Outcome: Failed
Result Message: System.Management.Automation.ActionPreferenceStopException : The running command stopped because the preference variable "ErrorActionPreference" or common parameter is set to Stop: Exception of type 'System.Management.Automation.PSInvalidOperationException' was thrown.
Perhaps I've mis-configured something? In Maps.Test/bin/Debug/Common.ps1
, Get-Location
function is there, but looks like it's failing to recognize it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, I can't find anything in your code that would cause this error. My recommendation would be to do a git clean -xdf (after committing all local changes, as this will erase all local changes), rebuilding and rerunning the test. I would think that something happened during all the renaming that is causing the function to not be found. Ping me if you are still having problems after this.
--- | ||
Module Name: AzureRM.Maps | ||
Module Guid: bf60f35d-6c0b-42f2-be30-eb333a31279d | ||
Download Help Link: None |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should have the download link: https://docs.microsoft.com/en-us/powershell/module/azurerm.locationbasedservices
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it okay to reference the old locationbasedservices link over maps?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oops no, please use https://docs.microsoft.com/en-us/powershell/module/azurerm.maps
@@ -12,7 +12,7 @@ | |||
# RootModule = '' | |||
|
|||
# Version number of this module. | |||
ModuleVersion = '1.0.1' | |||
ModuleVersion = '2.0.0' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you'd want to start as 1.0.0 for this module (since it will be new to the gallery) - let me know if you disagree.
CmdletsToExport = 'Get-AzureRmMapsAccount', | ||
'New-AzureRmMapsAccount', | ||
'Remove-AzureRmMapsAccount', | ||
'Set-AzureRmMapsAccount', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Was this just missing before?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If there is no Set, it should be removed everywhere.
|
||
# Prerelease string of this module | ||
Prerelease = 'preview' | ||
Prerelease = '' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please comment this out (add a # to the beginning).
@@ -71,11 +75,15 @@ | |||
<Reference Include="Microsoft.IdentityModel.Clients.ActiveDirectory.WindowsForms, Version=2.28.3.860, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL"> | |||
<HintPath>..\..\..\packages\Microsoft.IdentityModel.Clients.ActiveDirectory.2.28.3\lib\net45\Microsoft.IdentityModel.Clients.ActiveDirectory.WindowsForms.dll</HintPath> | |||
</Reference> | |||
<Reference Include="Microsoft.Rest.ClientRuntime, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove this new reference - in common targets.
Assert-AreEqual $createdAccount.Location $createdAccountAgain.Location; | ||
Assert-AreEqual $createdAccount.Sku.Name $createdAccountAgain.Sku.Name; | ||
|
||
Retry-IfException { Remove-AzureRmMapsAccount -ResourceGroupName $rgname -Name $accountname -Confirm:$false; } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add a check here to ensure the account was deleted (make sure get returns nothing)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like the check is in under function Test-RemoveAzureRmMapsAccount
at line 73 & 83. I think this check is good, but I can also add to all other test cases if needed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As long as remove has an assert somewhere in the tests, no need to add the check here. 👍
return context.GetServiceClient<MapsManagementClient>(RestTestFramework.TestEnvironmentFactory.GetTestEnvironment()); | ||
} | ||
|
||
private LegacyResourceManagementClient GetLegacyResourceManagementClient(RestTestFramework.MockContext context) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What changed to mean that you need this? Did you change the tests?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No changes were introduced.
If I recall, it worked ~2 months ago, but broke recently after pulling the latest code from the preview branch. This includes unmodified LocationBasedServices cmdlet tests, that yields the same error like shown below:
Test Name: Microsoft.Azure.Commands.Maps.Test.ScenarioTests.MapsAccountTests.TestRemoveAccount
Test Outcome: Failed
Result Message: System.Management.Automation.ActionPreferenceStopException : The running command stopped because the preference variable "ErrorActionPreference" or common parameter is set to Stop: TestManagementClientHelper class wasn't initialized with the ResourceManagementClient client.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Interesting. This is fine then.
<package id="Microsoft.Bcl" version="1.1.9" targetFramework="net45" /> | ||
<package id="Microsoft.Bcl.Async" version="1.0.168" targetFramework="net45" /> | ||
<package id="Microsoft.Bcl.Build" version="1.0.14" targetFramework="net45" /> | ||
<package id="Microsoft.IdentityModel.Clients.ActiveDirectory" version="2.28.3" targetFramework="net45" /> | ||
<package id="Microsoft.Net.Http" version="2.2.28" targetFramework="net45" /> | ||
<package id="Microsoft.Rest.ClientRuntime" version="2.3.10" targetFramework="net452" /> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove this.
src/ResourceManager/Maps/Maps.sln
Outdated
@@ -6,6 +6,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Commands.ResourceManager.Co | |||
EndProject | |||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Commands.Resources", "..\Resources\Commands.Resources\Commands.Resources.csproj", "{E1F5201D-6067-430E-B303-4E367652991B}" | |||
EndProject | |||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Commands.Tags", "..\Tags\Commands.Tags\Commands.Tags.csproj", "{2493A8F7-1949-4F29-8D53-9D459046C3B8}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why was this added?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed.
@jp94 To answer questions from above: No need to open a new PR in docs. Once the release is live, the docs team will pull the docs from our repo. You just need to add the links (what you said about which links to add is correct). The current PR removing the old module and adding the new simulataneous is much easier to review because it only shows the changes. Please keep like this. |
@@ -47,6 +47,6 @@ | |||
// You can specify all the values or you can default the Build and Revision Numbers | |||
// by using the '*' as shown below: | |||
|
|||
[assembly: AssemblyVersion("1.0.0")] | |||
[assembly: AssemblyFileVersion("1.0.0")] | |||
[assembly: AssemblyVersion("2.0.0")] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be 1.0.0 as well.
src/ResourceManager/Maps/Maps.sln
Outdated
@@ -56,6 +56,10 @@ Global | |||
{E1F5201D-6067-430E-B303-4E367652991B}.Debug|Any CPU.Build.0 = Debug|Any CPU | |||
{E1F5201D-6067-430E-B303-4E367652991B}.Release|Any CPU.ActiveCfg = Release|Any CPU | |||
{E1F5201D-6067-430E-B303-4E367652991B}.Release|Any CPU.Build.0 = Release|Any CPU | |||
{2493A8F7-1949-4F29-8D53-9D459046C3B8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove these four lines as well - this is from the tags.common project.
@jp94 Looks like the build is failing because your "Remove" cmdlet does not implement passthru. To add this, simply add a switchparameter "PassThru", and when the parameter is specified, print a boolean indicating the success or failure of the removal. Let me know if you have any questions about this. |
@maddieclayton [...]
+ [Cmdlet(VerbsCommon.Remove, MapsAccountNounStr, DefaultParameterSetName = NameParameterSet, SupportsShouldProcess = true), OutputType(typeof(bool))]
public class RemoveAzureMapsAccount : MapsAccountBaseCmdlet
{
[...]
+ [Parameter(Mandatory = false)]
+ public SwitchParameter PassThru { get; set; }
public override void ExecuteCmdlet()
{
base.ExecuteCmdlet();
RunCmdLet(() =>
{
[...]
if (!string.IsNullOrEmpty(rgName)
&& !string.IsNullOrEmpty(name)
&& ShouldProcess(name, string.Format(CultureInfo.CurrentCulture, Resources.RemoveAccount_ProcessMessage, name)))
{
this.MapsClient.Accounts.Delete(rgName, name);
+ if (PassThru.IsPresent)
+ {
+ WriteObject(true);
+ }
}
});
}
}
} I was able to complete the build without errors, and you can see the changes noted by |
@jp94 That looks great! My only comment would be to add a "HelpMessage" to the PassThru parameter. |
@jp94 You will also need to regenerate the help file, so the new parameter gets picked up. Thanks! |
@@ -106,6 +106,19 @@ Accept pipeline input: True (ByPropertyName) | |||
Accept wildcard characters: False | |||
``` | |||
|
|||
### -PassThru | |||
Return whether the specified account was successfully deleted or not.```yaml |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please move this yaml tag down to the next line (this is a known issue in platyps)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep.. I fixed the issue, and am running the whole msbuild build.proj
again right now.
Description
Introduce Azure maps cmdlets.
Most are renaming LocationBasedServices cmdlets to Maps.
However, I had to attach a Microsoft.Azure.Management.ResourceManager.ResourceManagementClient to pass test cases.
Cmdlet review:
https://github.com/Azure/azure-powershell-cmdlet-review-pr/issues/21
Checklist
CONTRIBUTING.md
platyPS
module