Tutorial: Create a cloud deployment

This quickstart shows how to create your first cloud-based application deployment. Cloud-based deployment delivers an application through a deployment assigned to a device group within the target product.

In this tutorial, you will learn how to:

  • Create a product
  • Enable cloud-based deployment for your device
  • Create the deployment
  • Trigger deployment
  • Re-enable development and debugging

Prerequisites

Create a product

A product identifies a model of Azure Sphere device that performs a specific function and runs a particular application.

If you do not already have a product, create one using the az sphere product create command.

az sphere product create --resource-group MyResourceGroup --catalog MyCatalog --name MyProduct --description "My First Product"

Product names must be unique within your Azure Sphere catalog and are not case sensitive. If the name contains spaces, enclose it in double quotation marks in commands.

The az sphere product create command automatically creates five default device groups for the new product: Development, Field Test, Production, Field Test OS Evaluation, and Production OS Evaluation. Device groups provide a way for you to organize your devices according to how you're using them.

Enable cloud-based deployment for your device

Before you test the cloud-based deployment process, your Azure Sphere device must be ready to accept cloud-based application updates. Use the az sphere device enable-cloud-test command to prepare your device:

az sphere device enable-cloud-test --catalog MyCatalog --resource-group MyResourceGroup --product MyProduct

This command:

  • Identifies the device as the MyProduct model, which was created in the previous step.
  • By default, assigns the device to the Field Test device group, which enables cloud-based application updates.
  • Disables the ability for the SDK to load applications onto the device, so that only cloud-based applications can be loaded.

Create the deployment

A deployment is a set of images that can be deployed from the Azure Sphere cloud service to the devices within a particular device group.

To create a deployment:

  1. Upload the image package to your Azure Sphere catalog using az sphere image add.

  2. Create a new deployment for a device group for the uploaded images using az sphere deployment create.

  3. Upload the image package:

     az sphere image add --resource-group MyResourceGroup --catalog MyCatalog --image-path <path-to-image>
    

    The output should show something like the following:

Uploading image from file 'Blink.imagepackage':
 --> Image ID:       <image-ID>
 --> Component ID:   <component-ID>
 --> Component name: 'Blink'
Removing temporary state for uploaded image.
Successfully uploaded image with ID '<image-id>' and name 'Blink' to component with ID '<component-id>'.

You will use the Image ID in the next step.

  1. Create a new deployment for a device group:

    az sphere deployment create --resource-group MyResourceGroup --catalog MyCatalog --product MyProduct --device-group <device-group-ID> --images <image-ID>
    
  2. To provide multiple values for --images enter a list of values separated by spaces.

  3. Specify the Field Test device group and the name of the product that you created in Create a product.

  4. Replace <image-ID> with the image ID of the image package that you created in Tutorial: Build a high-level application.

  5. To verify that the deployment is set up, use the az sphere image list-targeted command.

Trigger the deployment

The previous steps set up all the required deployment elements. To trigger the download immediately, press the Reset button on the Azure Sphere device. The application should download and start within several minutes, and you should see the LED start to blink.

To verify that the application was installed on your device, use the az sphere device image list-installed command. You may not see the results of the deployment immediately. If the deployment is not listed when you run the command, try again in a few minutes. The LED will begin to blink on the Azure Sphere device as soon as the deployment completes.

Next steps

As you continue to develop and test applications, you will probably want to sideload them until you're ready to deploy them more broadly. To reverse the az sphere device enable-cloud-test command and enable the device for development and debugging, use az sphere device enable-development.

Advance to the next article to learn how to:

If you aren't ready to build real-time applications, you might also want to:

Troubleshoot

If you encounter problems with the operations above, refer to troubleshooting guidance.

If you encounter problems with the operations above, refer to troubleshooting guidance.