-
Notifications
You must be signed in to change notification settings - Fork 49
/
SimulatorCloudRunner.ps1
34 lines (30 loc) · 1.68 KB
/
SimulatorCloudRunner.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
param (
[string]$Location = "westeurope",
[string]$ResourceGroup = "iothubsimulator",
[int]$DeviceCount = 100,
[int]$ContainerCount = 1,
[int]$MessageCount = 100,
[int]$Interval = 1000,
[string]$FixPayload='',
[int]$FixPayloadSize=0,
[string]$Template = '{ \"deviceId\": \"$.DeviceId\", \"temp\": $.Temp, \"Ticks\": $.Ticks, \"Counter\": $.Counter, \"time\": \"$.Time\", \"engine\": \"$.Engine\", \"source\": \"$.MachineName\" }',
[string]$Header = '',
[string]$Variables = '[{name: \"Temp\", random: true, max: 25, min: 23}, {name:\"Counter\", min:100}, {name:\"Engine\", values: [\"on\", \"off\"]}]',
[Parameter(Mandatory=$true)][string]$IotHubConnectionString,
[string]$Image = "mcr.microsoft.com/oss/azure-samples/azureiot-telemetrysimulator:latest",
[double]$Cpu = 1.0,
[double]$Memory = 1.5
)
az group create --name $ResourceGroup --location $Location
$i = 0
$deviceIndex = 1
$devicesPerContainer = [int]($DeviceCount / $ContainerCount)
while($i -lt $ContainerCount)
{
$i++
$containerName = "iotsimulator-" + $i.ToString()
az container create -g $ResourceGroup --no-wait --location $Location --restart-policy Never --cpu $Cpu --memory $Memory --name $containerName --image $Image --environment-variables IotHubConnectionString=$IotHubConnectionString Template=$Template Variables=$Variables DeviceCount=$devicesPerContainer MessageCount=$MessageCount DeviceIndex=$deviceIndex Interval=$Interval Header=$Header FixPayloadSize=$FixPayloadSize FixPayload=$FixPayload
$deviceIndex = $deviceIndex + $devicesPerContainer
}
Write-Host "Creation of" $ContainerCount "container instances has started. Telemetry will start flowing soon"