Skip to content

Commit

Permalink
v0.5.2 additions (#41)
Browse files Browse the repository at this point in the history
* Reformatted readme
* Using uamqp 1.0.1 which significantly reduces chance of deadlock on interrupt
* Catch empty sys.excepthook errors occasionally raised by underlying cancelled futures
  • Loading branch information
digimaun authored Aug 31, 2018
1 parent b76c64e commit 6aeefba
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 31 deletions.
59 changes: 31 additions & 28 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,42 +12,47 @@ The extension augments the vanilla Azure CLI IoT by adding to or modifying the e
- IoT Edge
- IoT Device Provisioning Service (DPS)

## Quick Start
## Installation

Validate that your Azure CLI version is [compatible](#compatibility).
The extension is designed to be plug-and-play with Azure CLI. **Even** if you have Azure CLI installed make sure it is up to date.

**Add the extension**: `az extension add --name azure-cli-iot-ext`
:exclamation: For **installation troubleshooting** please go to the [respective docs section](docs/install-help.md) for help.

**List installed extensions**: `az extension list`
### Compatibility
Before installation ensure that your Azure CLI version meets the following criteria. The criteria differs based on OS and method of installation. Use `az --version` to determine the CLI version.

**Update the extension**: `az extension update --name azure-cli-iot-ext`
In all cases your CLI needs to be at least `v2.0.24`.

**Remove the extension**: `az extension remove --name azure-cli-iot-ext`
| CLI Install Method | NOT compatible with |
| ------------- | ------------- |
| Windows via MSI | v2.0.34 to v2.0.38 |
| Windows via PIP, Linux or macOS | v2.0.34 to v2.0.36 |

## Installation

The extension is designed to be plug-and-play with Azure CLI. **Even** if you have Azure CLI installed make sure it is up to date.
### Quick Guide

:exclamation: For **installation troubleshooting** please go to the [respective docs section](docs/install-help.md) for help.
Validate that your Azure CLI version is [compatible](#compatibility).

### Compatibility
Before installation validate that your Azure CLI version is within the following criteria. The criteria differs based on OS and method of installation. Use `az --version` to validate.
**Common Az CLI extension operations**

Add: `az extension add --name azure-cli-iot-ext`

List: `az extension list`

```python
# Windows MSI
>= '2.0.24' and NOT between '2.0.34' - '2.0.38' inclusive
Update: `az extension update --name azure-cli-iot-ext`

# Windows PIP, Linux and macOS
>= '2.0.24' and NOT between '2.0.34' - '2.0.36' inclusive
```
Remove: `az extension remove --name azure-cli-iot-ext`

### Step 0: Install/Update Azure CLI

At a minimum your CLI core version must be within the compatibility criteria defined above.
### Full Guide

#### Step 0: Install/Update Azure CLI

At a minimum your CLI core version must be within the [compatibility](#compatibility) criteria defined above.

Follow the installation instructions on [GitHub](https://github.com/Azure/azure-cli) or [Microsoft Docs](https://docs.microsoft.com/en-us/cli/azure/install-azure-cli?view=azure-cli-latest) to setup Azure CLI in your environment.

### Step 1: Install the extension
#### Step 1: Install the extension

Now that you have a compatible Azure CLI installed you can add the IoT extension.
When you install an extension, any additional Python dependencies required are automatically downloaded and installed.
Expand Down Expand Up @@ -89,15 +94,15 @@ To build the wheel locally, ensure you have the Python `wheel` package installed

Now follow the local package installation method.

### Step 2: Log In (if you haven't already)
#### Step 2: Log In (if you haven't already)

Your subscription details are used to interact with target resources.

You can login interactively, pass in account credentials, or use a service principal with password/certificate options.

[More details](https://docs.microsoft.com/en-us/cli/azure/authenticate-azure-cli?view=azure-cli-latest) about Azure CLI authentication.

### Step 3: Have Fun
#### Step 3: Have Fun

If you have any suggestions or find bugs, please let us know.

Expand All @@ -107,16 +112,17 @@ To remove the extension at any time, you can use `az extension remove --name azu

## Command Guide

[Command Wiki](https://github.com/Azure/azure-iot-cli-extension/wiki/Commands)
The [Microsoft Docs](https://docs.microsoft.com/en-us/cli/azure/ext/azure-cli-iot-ext/iot?view=azure-cli-latest) extensions reference are updated per release.

#### Tips for success

**Tip#1** Many commands require the default policy to exist on the target resource which is being manipulated. For example IoT Hub based commands commonly look for the **iothubowner** policy. _This behavior will change in a future update_.
* Many commands require the default policy to exist on the target resource which is being manipulated. For example IoT Hub based commands commonly look for the **iothubowner** policy. _This behavior will change in a future update_.

**Tip#2** For command parameters that take JSON, for example the `az iot hub device-twin update` command's `--set` parameter, JSON input is different between CMD/PowerShell and Bash-like shells.
* For command parameters that take JSON, for example the `az iot hub device-twin update` command's `--set` parameter, the JSON input format is different between CMD/PowerShell and Bash-like shells.

Please read the [Tips Wiki page](https://github.com/Azure/azure-iot-cli-extension/wiki/Tips) for more detail and to maximize the functionality and enjoyment out of the IoT extension.


## Developer setup

Extension development depends on a local Azure CLI dev environment. First, follow these [instructions](https://github.com/Azure/azure-cli/blob/master/doc/configuring_your_machine.md) to prepare your machine.
Expand Down Expand Up @@ -185,9 +191,6 @@ At this point if your environment has been setup to execute all tests, you can l

`pytest -v <extension root> --cov=azext_iot --cov-config <extension root>/.coveragerc`

## Known Issues

- Device Export does not currently support IoT Edge device capability

## Contributing

Expand Down
2 changes: 1 addition & 1 deletion azext_iot/_constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
MIN_SIM_MSG_INTERVAL = 1
MIN_SIM_MSG_COUNT = 1
SIM_RECEIVE_SLEEP_SEC = 3
EVENT_LIB = ('uamqp', '0.2.1')
EVENT_LIB = ('uamqp', '1.0.1')

# Config Key's
CONFIG_KEY_UAMQP_EXT_VERSION = 'uamqp_ext_version'
5 changes: 3 additions & 2 deletions azext_iot/operations/events3/_events.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ def _get_conn_props():
properties=properties,
device_id=device_id,
timeout=timeout))
await asyncio.gather(*coroutines)
await asyncio.gather(*coroutines, return_exceptions=True)


async def monitor_events(endpoint, connection, path, auth, partition, consumer_group, enqueuedtimeutc,
Expand Down Expand Up @@ -154,7 +154,7 @@ def _output_msg_kpi(msg):
async for msg in receive_client.receive_messages_iter_async():
_output_msg_kpi(msg)

except asyncio.CancelledError:
except (asyncio.CancelledError, KeyboardInterrupt):
exp_cancelled = True
await receive_client.close_async()
except uamqp.errors.LinkDetach as ld:
Expand All @@ -164,6 +164,7 @@ def _output_msg_kpi(msg):
finally:
if not exp_cancelled:
await receive_client.close_async()
logger.info("Closed monitor on partition %s", partition)


def _build_auth_container(target):
Expand Down
4 changes: 4 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@
# 'jmespath==0.9.3',
# 'pyyaml==3.13'

# There is also a dependency for uamqp for amqp based commands
# though that is installed out of band (managed by the extension)
# for compatibility reasons.

DEPENDENCIES = [
'paho-mqtt==1.3.1'
]
Expand Down

0 comments on commit 6aeefba

Please sign in to comment.