Skip to content

Iot Hub Commandlets #3250

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 24 commits into from
Dec 12, 2016
Merged

Iot Hub Commandlets #3250

merged 24 commits into from
Dec 12, 2016

Conversation

rkmanda
Copy link
Member

@rkmanda rkmanda commented Dec 5, 2016

Description


This checklist is used to make sure that common guidelines for a pull request are followed. You can find a more complete discussion of PowerShell cmdlet best practices here.

General Guidelines

  • Title of the pull request is clear and informative.
  • There are a small number of commits, each of which have an informative message. This means that previously merged commits do not appear in the history of the PR. For more information on cleaning up the commits in your PR, see this page.
  • The pull request does not introduce breaking changes (unless a major version change occurs in the assembly and module).

Testing Guidelines

  • Pull request includes test coverage for the included changes.
  • PowerShell scripts used in tests should do any necessary setup as part of the test or suite setup, and should not use hard-coded values for locations or existing resources.

Cmdlet Signature Guidelines

  • New cmdlets that make changes or have side effects should implement ShouldProcess and have SupportShouldProcess=true specified in the cmdlet attribute. You can find more information on ShouldProcess here.
  • Cmdlet specifies OutputType attribute if any output is produced - if the cmdlet produces no output, it should implement a PassThrough parameter.

Cmdlet Parameter Guidelines

  • Parameter types should not expose types from the management library - complex parameter types should be defined in the module.
  • Complex parameter types are discouraged - a parameter type should be simple types as often as possible. If complex types are used, they should be shallow and easily creatable from a constructor or another cmdlet.
  • Cmdlet parameter sets should be mutually exclusive - each parameter set must have at least one mandatory parameter not in other parameter sets.

@azurecla
Copy link

azurecla commented Dec 5, 2016

Hi @rkmanda, I'm your friendly neighborhood Azure Pull Request Bot (You can call me AZPRBOT). Thanks for your contribution!


It looks like you're working at Microsoft (rmanda). If you're full-time, we DON'T require a contribution license agreement.



If you are a vendor, DO please sign the electronic contribution license agreement. It will take 2 minutes and there's no faxing! https://cla.azure.com.

TTYL, AZPRBOT;

@rkmanda
Copy link
Member Author

rkmanda commented Dec 5, 2016

This is the next iteration after the older PR for the same was closed. Link to PR #3156

@markcowl
Copy link
Member

markcowl commented Dec 6, 2016

@rkmanda Please clean up the commits in this PR as described here:https://github.com/Azure/azure-powershell/blob/dev/documentation/cleaning-up-commits.md

Please fill out the checklist as required as well

Copy link
Member

@cormacpayne cormacpayne left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rkmanda I left a few comments that need to be addressed

Also, you will need to add a ChangeLog.md file to your folder (view here for an example), as well as a documentation folder containing breaking change documents (view here for an example)

// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("0.0.1")]
[assembly: AssemblyFileVersion("1.0.0.0")]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rkmanda this should also be 0.0.1

$op= $iotHubUpdated.Properties.OperationsMonitoringProperties
$op.OperationMonitoringEvents["Connections"] = "Information"
$iotHubUpdated = Set-AzureRmIotHub -ResourceGroupName $ResourceGroupName -Name $IotHubName -OperationsMonitoringProperties $op
Assert-True { $iothubUpdated.Properties.OperationsMonitoringProperties.OperationMonitoringEvents["Connections"] -eq "Information" }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rkmanda do you plan on adding a test using the parameter set UpdateFileUploadProperties for Set-AzureRmIotHub?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not as a part of the current PR. The test for this is a little involved as it requires a SAS token to be fetched on the fly. Will add the test later.


[Cmdlet(VerbsCommon.Get, "AzureRmIotHubJob")]
[OutputType(typeof(PSIotHubJobResponse), typeof(List<PSIotHubJobResponse>))]
public class GetAzureRmIotHubJob : IotHubBaseCmdlet
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rkmanda I don't see any tests for this cmdlet

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The prereq for testing this is to have a test for NewAzureRmIotHubExportDevices which also relies on a valid SAS token to be generated on the fly. Will target this later.


[Cmdlet(VerbsCommon.New, "AzureRmIotHubExportDevices", SupportsShouldProcess = true)]
[OutputType(typeof(JobResponse))]
public class NewAzureRmIotHubExportDevices : IotHubBaseCmdlet
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rkmanda I don't see any tests for this cmdlet

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Relies on a valid SAS token to be generated on the fly. Will target this later.


[Cmdlet(VerbsCommon.New, "AzureRmIotHubImportDevices", SupportsShouldProcess = true)]
[OutputType(typeof(JobResponse))]
public class NewAzureRmIotHubImportDevices : IotHubBaseCmdlet
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rkmanda I don't see any tests for this cmdlet

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Relies on a valid SAS token to be generated on the fly. Will target this later.



# Assemblies that must be loaded prior to importing this module
RequiredAssemblies = @()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need to have The correct version of AzureRM.Profile as a dependency, see: https://github.com/Azure/azure-powershell/blob/dev/src/ResourceManager/Cdn/AzureRM.Cdn.psd1#L54

PSData = @{

# Tags applied to this module. These help with module discovery in online galleries.
# Tags = @()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please uncomment tags property and put in appropriate tags

<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>..\..\..\Package\Release\ResourceManager\AzureResourceManager\AzureRM.IotHub</OutputPath>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You don't want this path for tests

public void TestAzureIotHubLifeCycle()
{
IotHubController.NewInstance.RunPsTestWorkflow(
() => { return new[] { string.Format("{0} {1} {2} {3} {4}", "Test-AzureRmIotHubLifecycle", "northeurope", "powershelliothub", "powershellrg", "S1") }; },
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do not hard code regions. Instead, your test should detect an appropriate available region as part of test setup. Hard coded regions are a maintenance headache, because the test cannot be re-recorded against the test cluster in the future.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Found other resources hardcoding location directly in the script. What I have done is to ensure that the script itself does not have the hardcoding so it can be run in any location. Let me know if this works for the current PR. I will raise an issue to fix this in a subsequent PR.

<OutputPath>..\..\..\Package\Release\ResourceManager\AzureResourceManager\AzureRM.IotHub</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You need the properties that support delay siging in this target. See: https://github.com/Azure/azure-powershell/blob/dev/src/ResourceManager/Cdn/Commands.Cdn/Commands.Cdn.csproj#L43 for an example. You will also need to include the delay sign key, as that assembly does

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why doi you have two property groups for the release configuration? Please clean up.

Position = 2,
Mandatory = true,
HelpMessage = "Name of the Key")]
[ValidateNotNullOrEmpty]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any chance this will come from the pipeline (A Get call, perhaps?)

using Microsoft.Azure.Management.IotHub;
using Microsoft.Azure.Management.IotHub.Models;

[Cmdlet(VerbsCommon.Set, "AzureRmIotHub", SupportsShouldProcess = true)]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need a default parameter set setting

@@ -0,0 +1,276 @@
# ----------------------------------------------------------------------------------
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is this file intended for? Remove

## PARAMETERS

### -EventHubConsumerGroupName
EventHubConsumerGroupName.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Informative description, please


### -CloudToDevice
CloudToDevice

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need an informative description for each parameter. This applies to all help files

@rkmanda
Copy link
Member Author

rkmanda commented Dec 8, 2016

@markcowl please review. Addressed most comments. Some tests are to be added and I will raise an issue for this. The region hardcoding will also be removed as a part of the test issue.

Copy link
Member

@markcowl markcowl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You need to file test issues for:

  • missing coverage
  • hard-coded locations
  • cleanup of duplicated scripts

Send us the link for these issues and we will be able to merge the PR once it passes test and signing builds

## Current Release

## Version 1.0.0
* Adds commandlets for the Azure IoT Hub
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please listy the capabilities of these cmdlets, and the resources they allow you to manage.

<OutputPath>..\..\..\Package\Release\ResourceManager\AzureResourceManager\AzureRM.IotHub</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why doi you have two property groups for the release configuration? Please clean up.

@markcowl
Copy link
Member

markcowl commented Dec 8, 2016

@cormacpayne
Copy link
Member

@cormacpayne cormacpayne changed the base branch from dev to release-3.3.0 December 10, 2016 00:05
@cormacpayne
Copy link
Member

@rkmanda
Copy link
Member Author

rkmanda commented Dec 11, 2016

Can this be merged now?

@cormacpayne cormacpayne merged commit 07db5f9 into Azure:release-3.3.0 Dec 12, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants