Streaming to Azure IoT
# Streaming to Azure IoT ### Creating a Cloud Connector from ThingSpace directly to an Existing Azure IoT Central Application #### Prerequisites: - A Verizon BillingAccount with CAS devices previously on boarded into it - Ability to create the access (user token) and the session (VZ M2M token) to execute the ThingSpace API - [API reference documentation](/docs/specialized-apis/streaming-cloud-connector/api-reference) - Perform the Query Subscription and Query Target API calls to make sure that there are no existing subscriptions and/or targets associated with the Verizon `BillingAccountId` - Delete any previously created subscription on the Verizon `BillingAccount` - Delete any previously created targets on the Verizon `BillingAccount` NOTE: The documentation available at the link above does not contain the API calls required to create a ‘Target’ to stream to IoT Central. Creating a ‘Target’ to stream to IoT Central is covered below. - Azure IoT Central Application to which the ThingSpace Cloud Connector will stream including the following from that IoT Central Application: - HTTPS URL of the IoT Central Application streaming endpoint (retrieve this MS Azure URL) - Shared Access Signature of the IoT Central Application (retrieve this MS Azure SharedAccessSignature) Note: Every Azure IOT central APP has a Shared Access Signature. Navigate to Administration -> API tokens -> Generate token -> select admin role -> Generate. Copy the token and save it. ### Create a target to define the Endpoint and a Subscription [Create a target resource](/docs/specialized-apis/streaming-cloud-connector/api-endpoints/targets/createtarget) to define where to send device data. A REST Azure IoT target requires these values: - addressscheme must be “streamazureiot”. - address is your Azure IoT Central application ready to receive streamed device data. - authorization is the Shared Secret API token from your Azure IoT central application. \ Create a subscription using the `targetid` from the “Create a Target” response: - billingaccountid is your ThingSpace billing account - streamkind must be `ts.event` to receive all device data - targetid must be the UUID for the target, which was in the response when the target was created. - name: to be used to query for resources later. The cloud connector from the ThingSpace (Verizon `BillingAccountId`) to the IoT Central Application has now been configured The cloud connector populates the device templates that were specified by the target creation request in the IoT Central Application. Subsequently, data from CAS devices that are in the Verizon `BillingAccount` will start streaming telemetry data into the IoT Central application. Note: it may take some time for the cloud connector to get fully setup and start streaming data into the IoT Central Application. Also the sleep mode of the CAS device will determine how often the device wakes up and sends data into the IoT Central app ### Deploying a new Azure IoT Central Application from the ThingSpace Cloud Connector Azure Resource Manager template An alternative approach to using the Cloud Connector with Azure is to use Verizon’s default Azure Application Resource Management (ARM) template to create a new Azure application; rather than adding Cloud Connector devices to an existing Azure IoT Central application. [The attached guide](https://thingspace.verizon.com/content/dam/thingspace-portal/resources/documentation/pdf/Azure-IOT-Central-ARM-template.pdf) walks through the Azure-side prerequisites to use this approach. The instructions may vary as Microsoft Azure may change the flow as the platform evolves. At a high level, the Azure prerequisites (outlined in this guide) include: - Having an active Azure subscription - Azure portal (or Azure API) and credentials - Registering Azure Active Directory Applications - Creating secrets - Creating subscription resources - Creating IAM roles Once those Azure prerequisites are achieved, the following ThingSpace API’s can be executed: - Create a new Azure IoT Central application using the ThingSpace API. - Create a target to define the Endpoint and a Subscription Create a subscription using the `targetid` from the “[Create a Target](/docs/specialized-apis/streaming-cloud-connector/api-endpoints/targets/createtarget)” response