azd up --environment iot-stream-analytics
Run the following commands in your local environment.
# Set parameters
IOTHUB_NAME=$(terraform output -state=.azure/iot-stream-analytics/infra/terraform.tfstate -raw iothub_name)
STREAM_ANALYTICS_JOB_NAME=$(terraform output -state=.azure/iot-stream-analytics/infra/terraform.tfstate -raw stream_analytics_job_name)
DEVICE_NAME="myDevice"
# Create a device identity
az iot hub device-identity create \
--hub-name $IOTHUB_NAME \
--device-id $DEVICE_NAME
# Get the device connection string
CONNECTION_STRING=$(az iot hub device-identity connection-string show \
--hub-name $IOTHUB_NAME \
--device-id $DEVICE_NAME \
--query "connectionString" \
--output tsv)
# Start stream analytics job
az stream-analytics job start \
--job-name $STREAM_ANALYTICS_JOB_NAME \
--resource-group rg-iot-stream-analytics
To send mock data run the following procedures in your local environment.
- Open Raspberry Pi Azure IoT Online Simulator
- Override
connectionString
to$CONNECTION_STRING
of your device connection string - Click
Start
to send data - Go to storage container to see the data
azd down --force
SUBSCRIPTION_ID="$(az account list --query "[?isDefault].id" -o tsv)"
az ad sp create-for-rbac \
--name "iot-stream-analytics" \
--role contributor \
--scopes /subscriptions/f7b447fb-636e-49c2-ae1c-81120dc5e304/resourceGroups/rg-iot-stream-analytics \
--sdk-auth > .azure/credentials.json
gh secret set AZURE_CREDENTIALS < .azure/credentials.json