Azure / azure-iot-cli-extension

Azure IoT extension for Azure CLI
Other
82 stars 65 forks source link

Hub State Import, Export, Migrate Refactor #582

Closed vilit1 closed 1 year ago

vilit1 commented 1 year ago

This will introduce the az iot hub state command group:

File structure is as follows:

{
  "arm": full_arm_template,
  "configurations": {
       "admConfigurations": {
           "config_id": { config_properties }
       },
       "edgeDeployments": {
           "config_id": { config_properties }
       }
   }
  "devices": {
      "device_id": {
         "identity": { identity_properties (and properties shared with twin) },
         "twin" : { twin_properties },
         "modules" : {
            "module_id" : {
                "identity": { identity_properties },
                "twin": { twin_properties }
            }
         }
      }
   }
}

Improvements:

  1. you can choose which aspects (currently limited to arm (control plane), devices, configurations)
    • aspects will only be deleted if specified with the replace flag - for example, devices will only be deleted if replace and devices are specified
    • aspects will be uploaded if it is specified and in the file - if an aspect is specified but not in the file, it will not be changed (beyond the replace flag) and the user will be warned at the end.
    • no aspects = all aspects
    • certificates are the only things deleted from arm with the replace flag since they need an etag during arm upload if they exist. (and the arm template doesn't take in an etag)
  2. the control plane will be exported as an ARM template - which will reduce time needed to set up the control plane aspect of the hub
    • for import and migrate - if the hub does not exist, the hub will be created
    • the arm template will be modified to have the correct name (and location, rg, sku if the hub exists)
    • during export, the connection strings (for endpoints and file upload) will be populated if needed
  3. Tests depend on fixtures now and are more stable (as in dataplane as more retries when checking)
    • two hubs are created for migrate tests, one for import and export
  4. Better error handling
    • if the arm deployment fails, the command stops
    • if a device or config fails, it will be noted but the command will continue

Limitations:


History:

IoT Hub updates


This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact opencode@microsoft.com 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

Intent for Production

Basic expectations

Azure IoT CLI maintainers reserve the right to enforce any of the outlined expectations.

A PR is considered ready for review when all basic expectations have been met (or do not apply).

vilit1 commented 1 year ago

Test run: https://dev.azure.com/azureiotdevxp/aziotcli/_build/results?buildId=6717&view=results

vilit1 commented 1 year ago

tests passing again

vilit1 commented 1 year ago

https://dev.azure.com/azureiotdevxp/aziotcli/_build/results?buildId=7301&view=results - tests passing