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.
This should be Get-Location 'Microsoft.Maps' 'accounts' 'West US';
Apply everywhere.
There was a problem hiding this comment.
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.
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.
Should have the download link: https://docs.microsoft.com/en-us/powershell/module/azurerm.locationbasedservices
There was a problem hiding this comment.
Is it okay to reference the old locationbasedservices link over maps?
There was a problem hiding this comment.
Oops no, please use https://docs.microsoft.com/en-us/powershell/module/azurerm.maps
|
|
||
| # Version number of this module. | ||
| ModuleVersion = '1.0.1' | ||
| ModuleVersion = '2.0.0' |
There was a problem hiding this comment.
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.
Was this just missing before?
There was a problem hiding this comment.
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.
Please comment this out (add a # to the beginning).
| <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.
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.
Please add a check here to ensure the account was deleted (make sure get returns nothing)
There was a problem hiding this comment.
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.
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.
What changed to mean that you need this? Did you change the tests?
There was a problem hiding this comment.
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.
Interesting. This is fine then.
| <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" /> |
src/ResourceManager/Maps/Maps.sln
Outdated
| 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}" |
|
@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. |
|
|
||
| [assembly: AssemblyVersion("1.0.0")] | ||
| [assembly: AssemblyFileVersion("1.0.0")] | ||
| [assembly: AssemblyVersion("2.0.0")] |
There was a problem hiding this comment.
This should be 1.0.0 as well.
src/ResourceManager/Maps/Maps.sln
Outdated
| {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.
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! |
| ``` | ||
|
|
||
| ### -PassThru | ||
| Return whether the specified account was successfully deleted or not.```yaml |
There was a problem hiding this comment.
Please move this yaml tag down to the next line (this is a known issue in platyps)
There was a problem hiding this comment.
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.mdplatyPSmodule