Skip to content

Conversation

@nanowireUK
Copy link

@nanowireUK nanowireUK commented Mar 11, 2021

New feature: generate a SAS token based on only device connection string.

This extends the az iot cli to provide the functionality we already have in VS Code and as basic scripts in samples. We can directly generate a SAS token based only on the supplied device connection string without a requirement for any IoT Hub authentication. This is particularly useful for customers wanting to connect devices directly over MQTT to IoT Central since in this case you are not able to get an IoT Hub connection string.


This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact [email protected] with any additional questions or comments.

Thank you for contributing to the IoT extension!

This checklist is used to make sure that common guidelines for a pull request are followed.

General Guidelines

  • If introducing new functionality or modified behavior, are they backed by unit and integration tests?
  • In the same context as above are command names and their parameter definitions accurate? Do help docs have sufficient content?
  • Have all unit and integration tests passed locally? i.e. pytest <project root> -vv
  • Have static checks passed using the .pylintrc and .flake8 rules? Look at the CI scripts for example usage.
  • Have you made an entry in HISTORY.rst which concisely explains your feature or change?

New feature: generate a SAS token based on only connection string
@nanowireUK nanowireUK requested a review from digimaun as a code owner March 11, 2021 15:04
@digimaun
Copy link
Member

Thank you for this contribution and bringing up the gap in functionality as we aim for the IoT CLI to be a comprehensive tool.

Will get back to you on this PR...we may want to pivot in a different implementation (that covers the same functionality).

cmd,
hub_name=None,
device_id=None,
device_connection_string=None,
Copy link
Member

Choose a reason for hiding this comment

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

Instead of supporting an offline mode just for device connection strings, I'm thinking it would be valuable to support either hub, device or module offline SAS token generation via generic connection_string corresponding to a new --connection-string argument on this command.

Copy link
Author

Choose a reason for hiding this comment

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

@digimaun absolutely agree. This just happened to cover my use case for IoT Central but agree that there's no reason to restrict to only device connection strings

elif 'dps_name' in args:
iot_cmd_type = 'DPS'
entity_value = args['dps_name']
entity_value = args['dps_name']
Copy link
Member

Choose a reason for hiding this comment

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

Let's remove the extra spaces.

policy = None
key = None

if device_connection_string:
Copy link
Member

Choose a reason for hiding this comment

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

Lets add tests to exercise the scenario

Copy link
Author

Choose a reason for hiding this comment

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

I've noticed it creates a bunch of regression issues in my az iot cli which I need to look at before I go further with it

@digimaun
Copy link
Member

@nanowireUK let us know if you want to continue working on the PR, or we can cover this functionality in a different PR.

Right now my mental model for the feature is we should cover more than device connection strings.

@nanowireUK
Copy link
Author

@digimaun happy to keep working on the PR and absolutely support the idea of making the implementation more generic. I'll have a go at that and update the PR.

@digimaun
Copy link
Member

Superseded by #375

@digimaun digimaun closed this Jun 29, 2021
c-ryan-k pushed a commit to c-ryan-k/azure-iot-cli-extension that referenced this pull request Apr 10, 2025
…lated mgmt commands (Azure#319)

* Minimizes extraneous changes.
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.

2 participants