Skip to content

Commit

Permalink
Merge pull request #101 from ks6088ts-labs/feature/issue-100_add-mqtt…
Browse files Browse the repository at this point in the history
…-broker

add mqtt broker and architecture diagram
  • Loading branch information
ks6088ts authored Jun 12, 2024
2 parents fadb785 + 2ce1b38 commit 215fcdc
Show file tree
Hide file tree
Showing 4 changed files with 166 additions and 0 deletions.
13 changes: 13 additions & 0 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,3 +97,16 @@
- [Create a database in Azure Cosmos DB for NoSQL using Python](https://learn.microsoft.com/en-us/azure/cosmos-db/nosql/how-to-python-create-database)
- [Create a container in Azure Cosmos DB for NoSQL using Python](https://learn.microsoft.com/en-us/azure/cosmos-db/nosql/how-to-python-create-container)
- [Sample - demonstrates the basic CRUD operations on a Item resource for Azure Cosmos](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/cosmos/azure-cosmos/samples/document_management.py)

### Azure IoT Hub

- [Create and monitor a device](https://learn.microsoft.com/en-us/azure/iot-hub/quickstart-send-telemetry-cli#create-and-monitor-a-device)
- [Connect Raspberry Pi to Azure IoT Hub](https://learn.microsoft.com/en-us/azure/iot-hub/raspberry-pi-get-started)

```shell
IOT_HUB_NAME=""
DEVICE_NAME="simDevice"
az iot hub device-identity create \
--device-id $DEVICE_NAME \
--hub-name $IOT_HUB_NAME
```
108 changes: 108 additions & 0 deletions docs/architecture.drawio
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
<mxfile host="65bd71144e">
<diagram id="EQstYv7ABCkQYGfebw5h" name="Page-1">
<mxGraphModel dx="2288" dy="725" grid="1" gridSize="10" guides="1" tooltips="1" connect="1" arrows="1" fold="1" page="1" pageScale="1" pageWidth="850" pageHeight="1100" math="0" shadow="0">
<root>
<mxCell id="0"/>
<mxCell id="1" parent="0"/>
<mxCell id="8" style="edgeStyle=none;html=1;" edge="1" parent="1" source="2" target="7">
<mxGeometry relative="1" as="geometry"/>
</mxCell>
<mxCell id="34" style="edgeStyle=none;html=1;" edge="1" parent="1" target="3">
<mxGeometry relative="1" as="geometry">
<mxPoint x="240" y="380" as="sourcePoint"/>
</mxGeometry>
</mxCell>
<mxCell id="35" style="edgeStyle=none;html=1;" edge="1" parent="1" source="2" target="4">
<mxGeometry relative="1" as="geometry"/>
</mxCell>
<mxCell id="36" style="edgeStyle=none;html=1;" edge="1" parent="1" source="2">
<mxGeometry relative="1" as="geometry">
<mxPoint x="90" y="470.6666666666667" as="targetPoint"/>
</mxGeometry>
</mxCell>
<mxCell id="2" value="" style="aspect=fixed;html=1;points=[];align=center;image;fontSize=12;image=img/lib/azure2/iot/IoT_Hub.svg;" vertex="1" parent="1">
<mxGeometry x="240" y="368.25" width="64" height="64" as="geometry"/>
</mxCell>
<mxCell id="33" style="edgeStyle=none;html=1;" edge="1" parent="1" source="3">
<mxGeometry relative="1" as="geometry">
<mxPoint x="240" y="380" as="targetPoint"/>
</mxGeometry>
</mxCell>
<mxCell id="3" value="" style="outlineConnect=0;dashed=0;verticalLabelPosition=bottom;verticalAlign=top;align=center;html=1;shape=mxgraph.aws3.hardware_board;fillColor=#5294CF;gradientColor=none;" vertex="1" parent="1">
<mxGeometry x="40" y="290" width="50.57" height="60.5" as="geometry"/>
</mxCell>
<mxCell id="14" style="edgeStyle=none;html=1;" edge="1" parent="1" source="4">
<mxGeometry relative="1" as="geometry">
<mxPoint x="250" y="400" as="targetPoint"/>
</mxGeometry>
</mxCell>
<mxCell id="4" value="" style="outlineConnect=0;dashed=0;verticalLabelPosition=bottom;verticalAlign=top;align=center;html=1;shape=mxgraph.aws3.hardware_board;fillColor=#5294CF;gradientColor=none;" vertex="1" parent="1">
<mxGeometry x="40" y="370" width="50.57" height="60.5" as="geometry"/>
</mxCell>
<mxCell id="15" style="edgeStyle=none;html=1;" edge="1" parent="1" source="5" target="2">
<mxGeometry relative="1" as="geometry"/>
</mxCell>
<mxCell id="5" value="" style="outlineConnect=0;dashed=0;verticalLabelPosition=bottom;verticalAlign=top;align=center;html=1;shape=mxgraph.aws3.hardware_board;fillColor=#5294CF;gradientColor=none;" vertex="1" parent="1">
<mxGeometry x="40" y="450" width="50.57" height="60.5" as="geometry"/>
</mxCell>
<mxCell id="6" value="" style="aspect=fixed;html=1;points=[];align=center;image;fontSize=12;image=img/lib/azure2/databases/Azure_Cosmos_DB.svg;" vertex="1" parent="1">
<mxGeometry x="520" y="368" width="64" height="64" as="geometry"/>
</mxCell>
<mxCell id="9" style="edgeStyle=none;html=1;entryX=0;entryY=0.516;entryDx=0;entryDy=0;entryPerimeter=0;" edge="1" parent="1" source="7" target="6">
<mxGeometry relative="1" as="geometry"/>
</mxCell>
<mxCell id="7" value="" style="aspect=fixed;html=1;points=[];align=center;image;fontSize=12;image=img/lib/azure2/analytics/Stream_Analytics_Jobs.svg;" vertex="1" parent="1">
<mxGeometry x="380" y="371" width="68" height="57.99999999999999" as="geometry"/>
</mxCell>
<mxCell id="11" value="" style="aspect=fixed;html=1;points=[];align=center;image;fontSize=12;image=img/lib/azure2/ai_machine_learning/Cognitive_Services.svg;" vertex="1" parent="1">
<mxGeometry x="507" y="38" width="68" height="48" as="geometry"/>
</mxCell>
<mxCell id="12" value="" style="editableCssRules=.*;shape=image;verticalLabelPosition=bottom;labelBackgroundColor=#ffffff;verticalAlign=top;aspect=fixed;imageAspect=0;image=data:image/svg+xml,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHhtbG5zOnY9Imh0dHBzOi8vdmVjdGEuaW8vbmFubyIgd2lkdGg9IjE4IiBoZWlnaHQ9IjIwIiB2aWV3Qm94PSIwIDAgMTggMjAiPiYjeGE7CTxzdHlsZSB0eXBlPSJ0ZXh0L2NzcyI+JiN4YTsJLnN0MHtmaWxsOiM0Mjg1ZjQ7fSYjeGE7CS5zdDF7ZmlsbDojNjY5ZGY2O30mI3hhOwk8L3N0eWxlPiYjeGE7CTxwYXRoIGNsYXNzPSJzdDAiIGQ9Ik04IDBoMnYyMEg4ek00IDZoMnY4SDR6bTggMGgydjhoLTJ6TTAgM2gydjE0SDB6bTE2IDBoMnYxNGgtMnoiLz4mI3hhOwk8cGF0aCBjbGFzcz0ic3QxIiBkPSJNOCAwaDJ2MTBIOHpNNCA2aDJ2NEg0em04IDBoMnY0aC0yek0wIDNoMnY3SDB6bTE2IDBoMnY3aC0yeiIvPiYjeGE7PC9zdmc+;" vertex="1" parent="1">
<mxGeometry x="514" y="148" width="54" height="60" as="geometry"/>
</mxCell>
<mxCell id="18" style="edgeStyle=none;html=1;entryX=1.016;entryY=0.516;entryDx=0;entryDy=0;entryPerimeter=0;" edge="1" parent="1" source="17" target="6">
<mxGeometry relative="1" as="geometry"/>
</mxCell>
<mxCell id="19" style="edgeStyle=none;html=1;entryX=1;entryY=0.5;entryDx=0;entryDy=0;" edge="1" parent="1" source="17" target="12">
<mxGeometry relative="1" as="geometry">
<mxPoint x="580" y="130" as="targetPoint"/>
</mxGeometry>
</mxCell>
<mxCell id="20" style="edgeStyle=none;html=1;entryX=0.956;entryY=0.771;entryDx=0;entryDy=0;entryPerimeter=0;" edge="1" parent="1" source="17" target="11">
<mxGeometry relative="1" as="geometry"/>
</mxCell>
<mxCell id="29" style="edgeStyle=none;html=1;entryX=0.94;entryY=0.437;entryDx=0;entryDy=0;entryPerimeter=0;" edge="1" parent="1" source="17" target="27">
<mxGeometry relative="1" as="geometry">
<mxPoint x="580" y="490" as="targetPoint"/>
</mxGeometry>
</mxCell>
<mxCell id="30" style="edgeStyle=none;html=1;entryX=0.969;entryY=0.385;entryDx=0;entryDy=0;entryPerimeter=0;" edge="1" parent="1" source="17" target="28">
<mxGeometry relative="1" as="geometry">
<mxPoint x="590" y="610" as="targetPoint"/>
</mxGeometry>
</mxCell>
<mxCell id="42" style="edgeStyle=none;html=1;entryX=1.021;entryY=0.053;entryDx=0;entryDy=0;entryPerimeter=0;" edge="1" parent="1" source="17" target="2">
<mxGeometry relative="1" as="geometry"/>
</mxCell>
<mxCell id="17" value="" style="aspect=fixed;html=1;points=[];align=center;image;fontSize=12;image=img/lib/azure2/compute/Function_Apps.svg;" vertex="1" parent="1">
<mxGeometry x="800" y="212.25" width="68" height="60" as="geometry"/>
</mxCell>
<mxCell id="25" style="edgeStyle=none;html=1;entryX=0.985;entryY=0.463;entryDx=0;entryDy=0;entryPerimeter=0;" edge="1" parent="1" source="21" target="17">
<mxGeometry relative="1" as="geometry"/>
</mxCell>
<mxCell id="21" value="" style="sketch=0;aspect=fixed;pointerEvents=1;shadow=0;dashed=0;html=1;strokeColor=none;labelPosition=center;verticalLabelPosition=bottom;verticalAlign=top;align=center;fillColor=#00188D;shape=mxgraph.mscae.enterprise.tool;" vertex="1" parent="1">
<mxGeometry x="1030" y="217.5" width="50" height="45" as="geometry"/>
</mxCell>
<mxCell id="23" value="" style="html=1;verticalLabelPosition=bottom;align=center;labelBackgroundColor=#ffffff;verticalAlign=top;strokeWidth=2;strokeColor=#0080F0;shadow=0;dashed=0;shape=mxgraph.ios7.icons.user;" vertex="1" parent="1">
<mxGeometry x="1010" y="178" width="30" height="30" as="geometry"/>
</mxCell>
<mxCell id="27" value="" style="sketch=0;aspect=fixed;html=1;points=[];align=center;image;fontSize=12;image=img/lib/mscae/BlobBlock.svg;" vertex="1" parent="1">
<mxGeometry x="525" y="490" width="50" height="42" as="geometry"/>
</mxCell>
<mxCell id="28" value="" style="aspect=fixed;html=1;points=[];align=center;image;fontSize=12;image=img/lib/azure2/general/Storage_Queue.svg;" vertex="1" parent="1">
<mxGeometry x="520" y="610" width="64" height="52" as="geometry"/>
</mxCell>
</root>
</mxGraphModel>
</diagram>
</mxfile>
13 changes: 13 additions & 0 deletions infra/main.bicep
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ param eventGridName string = '${prefix}eg'
@description('Specifies the name of the Azure Cosmos DB resource.')
param cosmosDbName string = '${prefix}cosmosdb'

@description('Specifies the name of the Azure IoT Hub resource.')
param iotHubName string = '${prefix}iothub'

module openAi './modules/openAi.bicep' = {
name: 'openAi'
params: {
Expand Down Expand Up @@ -92,6 +95,15 @@ module cosmosDb './modules/cosmosDb.bicep' = {
}
}

module iotHub './modules/iotHub.bicep' = {
name: 'iotHub'
params: {
name: iotHubName
location: location
tags: tags
}
}

// Output
output cognitiveServicesName string = cognitiveServices.outputs.name
output cognitiveServicesEndpoint string = cognitiveServices.outputs.endpoint
Expand All @@ -100,3 +112,4 @@ output eventGridTopicEndpoint string = eventGrid.outputs.eventGridTopicEndpoint
output openAiName string = openAi.outputs.name
output openAiEndpoint string = openAi.outputs.endpoint
output storageAccountName string = storageAccount.outputs.name
output iotHubName string = iotHub.outputs.iotHubName
32 changes: 32 additions & 0 deletions infra/modules/iotHub.bicep
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
// Parameters
@description('Specifies the name prefix.')
param prefix string = uniqueString(resourceGroup().id)

@description('Specifies the primary location of Azure resources.')
param location string = resourceGroup().location

@description('Specifies the resource tags.')
param tags object = {}

@description('Specifies the name of the Azure resource.')
param name string = '${prefix}-iothub'

@description('The SKU to use for the IoT Hub.')
param skuName string = 'B1'

@description('The number of IoT Hub units.')
param skuUnits int = 1

resource iotHub 'Microsoft.Devices/IotHubs@2023-06-30' = {
name: name
location: location
tags: tags
sku: {
name: skuName
capacity: skuUnits
}
}

// Outputs
output iotHubId string = iotHub.id
output iotHubName string = iotHub.name

0 comments on commit 215fcdc

Please sign in to comment.