Skip to content
This repository has been archived by the owner on Dec 12, 2020. It is now read-only.

Commit

Permalink
Merge pull request #99 from Azure/December-Integration
Browse files Browse the repository at this point in the history
December integration
  • Loading branch information
jamesweb-ms committed Jan 21, 2016
2 parents 3afa3e1 + 0cae820 commit 861dd4d
Show file tree
Hide file tree
Showing 70 changed files with 2,796 additions and 196 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ bld/
[Bb]in/
[Oo]bj/
Build_Output/
.vs/

# Roslyn cache directories
*.ide/
Expand Down
3 changes: 3 additions & 0 deletions .nuget/NuGet.Config
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,7 @@
<config>
<add key="repositorypath" value="..\packages" />
</config>
<packageSources>
<add key="nuget.org" value="https://www.nuget.org/api/v2/" />
</packageSources>
</configuration>
3 changes: 3 additions & 0 deletions Common/Common.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@
<Compile Include="Helpers\AzureRetryHelper.cs" />
<Compile Include="Helpers\AzureTableStorageHelper.cs" />
<Compile Include="Helpers\BlobStorageHelper.cs" />
<Compile Include="Schema\SchemaHelper.cs" />
<Compile Include="Utility\DocDbQueryResult.cs" />
<Compile Include="Helpers\DynamicValuesHelper.cs" />
<Compile Include="Helpers\FunctionalHelper.cs" />
Expand All @@ -122,6 +123,8 @@
<Compile Include="Utility\IDocDbRestUtility.cs" />
<Compile Include="Helpers\ParsingHelper.cs" />
<Compile Include="Helpers\ReflectionHelper.cs" />
<Compile Include="Models\ApiRegistrationModel.cs" />
<Compile Include="Models\ApiRegistrationTableEntity.cs" />
<Compile Include="Models\Commands\Command.cs" />
<Compile Include="Models\Commands\DeviceCommandConstants.cs" />
<Compile Include="Models\DeviceListEntity.cs" />
Expand Down
31 changes: 25 additions & 6 deletions Common/Deployment/DeploymentLib.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,16 @@ function LoadLibrary()
if($packageDirectories.Length -eq 0)
{
Write-Host ("{0} Library Nuget doesn't exist. Downloading now ..." -f $library) -ForegroundColor Yellow
$nugetDownloadExpression = "& '$nugetPath\nuget.exe' install $library -OutputDirectory '$nugetPath' | out-null"
$nugetDownloadExpression = "& '$nugetPath\nuget.exe' install $library -OutputDirectory '$nugetPath' -Source https://www.nuget.org/api/v2 | out-null"
Invoke-Expression $nugetDownloadExpression
$packageDirectories = (Get-ChildItem -Path $nugetPath -Filter ("{0}*" -f $library) -Directory)
if ($packageDirectories.Length -eq 0)
{
Write-Error ("Unable to find package {0} on Nuget.org" -f $library)
return $false
}
}
$assemblies = (Get-ChildItem ("{0}.dll" -f $dllName) -Path $packageDirectories[$packageDirectories.length-1].FullName -Recurse)
$assemblies = (Get-ChildItem ("{0}.dll" -f $dllName) -Path ($packageDirectories |sort Name -desc)[0].FullName -Recurse)
if ($assemblies -eq $null)
{
Write-Error ("Unable to find {0}.dll assembly for {0} library, is the dll a different name?" -f $library)
Expand Down Expand Up @@ -185,8 +190,12 @@ function UpdateResourceGroupState()
{
$tag.Value = $state
$updated = $true
break
}
if ($tag.Name -eq "IoTSuiteVersion" -and $tag.Value -ne $global:version)
{
$tag.Value = $global:version
$updated = $true
}
}
if (!$updated)
{
Expand Down Expand Up @@ -322,11 +331,18 @@ function StopExistingStreamAnalyticsJobs()
return $false
}
Write-Host "Stopping existing Stream Analytics jobs..."
$returnValue = $true
foreach ($sasJob in $sasJobs)
{
$null = Stop-AzureStreamAnalyticsJob -Name $sasJob.ResourceName -ResourceGroupName $resourceGroupName
$job = Get-AzureStreamAnalyticsJob -Name $sasJob.ResourceName -ResourceGroupName $resourceGroupName
if ($job.Properties.LastOutputEventTime -eq $null)
{
# If the job never has seen data, use JobStartTime
$returnValue = $false
}
}
return $true
return $returnValue
}

function UploadFile()
Expand Down Expand Up @@ -701,7 +717,10 @@ function InitializeEnvironment()
throw "Suite name '$environmentName' must be between 3-62 characters"
}

$null = ImportLibraries
if(!(ImportLibraries))
{
throw "Failed to load dependent libraries"
}
$global:environmentName = $environmentName
$null = Get-AzureResourceGroup -ErrorAction SilentlyContinue -ErrorVariable credError
if ($credError -ne $null)
Expand Down Expand Up @@ -810,7 +829,7 @@ $global:timeStampFormat = "o"
$global:resourceNotFound = "ResourceNotFound"
$global:serviceNameToken = "ServiceName"
$global:azurePath = Split-Path $MyInvocation.MyCommand.Path
$global:version = "v1.0.0"
$global:version = "v1.1.0"

# Load System.Web
Add-Type -AssemblyName System.Web
Expand Down
27 changes: 22 additions & 5 deletions Common/Deployment/LocalMonitoring.json
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,8 @@
"type": "string",
"metadata": {
"description": "The start time for Stream Analytics jobs"
}
},
"defaultValue": "notused"
}
},
"variables": {
Expand All @@ -105,14 +106,18 @@
"iotHubKeyResource": "[resourceId('Microsoft.Devices/Iothubs/Iothubkeys', parameters('iotHubName'), variables('iotHubKeyName'))]",
"rulesCGName": "rulescg",
"deviceInfoCGName": "deviceinfocg",
"telemetryCGName": "telemetrycg"
"telemetryCGName": "telemetrycg",
"suiteType": "LocalMonitoring"
},
"resources": [
{
"apiVersion": "[variables('docDBVersion')]",
"type": "Microsoft.DocumentDb/databaseAccounts",
"name": "[parameters('docDBName')]",
"location": "[variables('location')]",
"tags": {
"IotSuiteType": "[variables('suiteType')]"
},
"properties": {
"name": "[parameters('docDBName')]",
"databaseAccountOfferType": "[parameters('docDBSku')]"
Expand All @@ -137,6 +142,9 @@
"tier": "[parameters('iotHubTier')]",
"capacity": 1
},
"tags": {
"IotSuiteType": "[variables('suiteType')]"
},
"properties": {
"location": "[variables('location')]"
}
Expand Down Expand Up @@ -170,6 +178,9 @@
"name": "[parameters('sbName')]",
"type": "Microsoft.Eventhub/namespaces",
"location": "[variables('location')]",
"tags": {
"IotSuiteType": "[variables('suiteType')]"
},
"properties": {
"messagingSku": "[parameters('sbSku')]",
"region": "[variables('location')]"
Expand Down Expand Up @@ -212,12 +223,14 @@
"[concat('Microsoft.Storage/storageAccounts/', parameters('storageName'))]",
"[concat('Microsoft.Devices/Iothubs/', parameters('iotHubName'))]"
],
"tags": {
"IotSuiteType": "[variables('suiteType')]"
},
"properties": {
"sku": {
"name": "standard"
},
"OutputStartMode": "[parameters('asaStartBehavior')]",
"OutputStartTime": "[parameters('asaStartTime')]",
"EventsOutOfOrderMaxDelayInSeconds": 10,
"EventsOutOfOrderPolicy": "adjust",
"Inputs": [
Expand Down Expand Up @@ -317,12 +330,14 @@
"[concat('Microsoft.Eventhub/namespaces/', parameters('sbName'))]",
"[concat('Microsoft.Devices/Iothubs/', parameters('iotHubName'))]"
],
"tags": {
"IotSuiteType": "[variables('suiteType')]"
},
"properties": {
"sku": {
"name": "standard"
},
"OutputStartMode": "[parameters('asaStartBehavior')]",
"OutputStartTime": "[parameters('asaStartTime')]",
"EventsOutOfOrderMaxDelayInSeconds": 10,
"EventsOutOfOrderPolicy": "adjust",
"Inputs": [
Expand Down Expand Up @@ -391,12 +406,14 @@
"[concat('Microsoft.Eventhub/namespaces/', parameters('sbName'))]",
"[concat('Microsoft.Devices/Iothubs/', parameters('iotHubName'))]"
],
"tags": {
"IotSuiteType": "[variables('suiteType')]"
},
"properties": {
"sku": {
"name": "standard"
},
"OutputStartMode": "[parameters('asaStartBehavior')]",
"OutputStartTime": "[parameters('asaStartTime')]",
"EventsOutOfOrderMaxDelayInSeconds": 10,
"EventsOutOfOrderPolicy": "adjust",
"Inputs": [
Expand Down
21 changes: 15 additions & 6 deletions Common/Deployment/PrepareIoTSample.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ ClearDNSCache
InitializeEnvironment $environmentName

# Set environment specific variables
$suitename = "IotSuiteLocal"
$suitename = "LocalRM"
$suiteType = "LocalMonitoring"
$deploymentTemplatePath = "$(Split-Path $MyInvocation.MyCommand.Path)\LocalMonitoring.json"
$global:site = "https://localhost:44305/"
Expand All @@ -31,6 +31,15 @@ if ($environmentName -ne "local")
#[string]$branch = "$(git symbolic-ref --short -q HEAD)"
$cloudDeploy = $true
}
else
{
$legacyNameExists = (Get-AzureResourceGroup -Tag @{Name="IotSuiteType";Value=$suiteType} | ?{$_.ResourceGroupName -eq "IotSuiteLocal"}) -ne $null
if ($legacyNameExists)
{
$suiteName = "IotSuiteLocal"
}
}

$suiteExists = (Get-AzureResourceGroup -Tag @{Name="IotSuiteType";Value=$suiteType} | ?{$_.ResourceGroupName -eq $suiteName}) -ne $null
$resourceGroupName = (GetResourceGroup -Name $suiteName -Type $suiteType).ResourceGroupName
$storageAccount = GetAzureStorageAccount $suiteName $resourceGroupName
Expand Down Expand Up @@ -108,11 +117,11 @@ if ($cloudDeploy)
}
}

# Stream analytics does not auto stop, and requires a start time for both create and update as well as stop if already exists
[string]$startTime = (get-date).ToUniversalTime().ToString("yyyy-MM-ddTHH:mm:ssZ")
$null = StopExistingStreamAnalyticsJobs $resourceGroupName
$params += @{asaStartBehavior='CustomTime'}
$params += @{asaStartTime=$startTime}
# Stream analytics does not auto stop, and if already exists should be set to LastOutputEventTime to not lose data
if (StopExistingStreamAnalyticsJobs $resourceGroupName)
{
$params += @{asaStartBehavior='LastOutputEventTime'}
}

Write-Host "Provisioning resources, if this is the first time, this operation can take up 10 minutes..."
$result = New-AzureResourceGroupDeployment -ResourceGroupName $resourceGroupName -TemplateFile $deploymentTemplatePath -TemplateParameterObject $params -Verbose
Expand Down
42 changes: 37 additions & 5 deletions Common/Deployment/RemoteMonitoring.json
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,8 @@
"type": "string",
"metadata": {
"description": "The start time for Stream Analytics jobs"
}
},
"defaultValue": "notused"
}
},
"variables": {
Expand Down Expand Up @@ -164,14 +165,18 @@
"iotHubKeyResource": "[resourceId('Microsoft.Devices/Iothubs/Iothubkeys', parameters('iotHubName'), variables('iotHubKeyName'))]",
"rulesCGName": "rulescg",
"deviceInfoCGName": "deviceinfocg",
"telemetryCGName": "telemetrycg"
"telemetryCGName": "telemetrycg",
"suiteType": "RemoteMonitoring"
},
"resources": [
{
"apiVersion": "[variables('docDBVersion')]",
"type": "Microsoft.DocumentDb/databaseAccounts",
"name": "[parameters('docDBName')]",
"location": "[variables('location')]",
"tags": {
"IotSuiteType": "[variables('suiteType')]"
},
"properties": {
"name": "[parameters('docDBName')]",
"databaseAccountOfferType": "[parameters('docDBSku')]"
Expand All @@ -188,6 +193,9 @@
"name": "internal1",
"promotionCode": null
},
"tags": {
"IotSuiteType": "[variables('suiteType')]"
},
"properties": { }
},
{
Expand All @@ -209,6 +217,9 @@
"tier": "[parameters('iotHubTier')]",
"capacity": 1
},
"tags": {
"IotSuiteType": "[variables('suiteType')]"
},
"properties": {
"location": "[variables('location')]"
}
Expand Down Expand Up @@ -242,6 +253,9 @@
"name": "[parameters('sbName')]",
"type": "Microsoft.Eventhub/namespaces",
"location": "[variables('location')]",
"tags": {
"IotSuiteType": "[variables('suiteType')]"
},
"properties": {
"messagingSku": "[parameters('sbSku')]",
"region": "[variables('location')]"
Expand Down Expand Up @@ -284,12 +298,14 @@
"[concat('Microsoft.Storage/storageAccounts/', parameters('storageName'))]",
"[concat('Microsoft.Devices/Iothubs/', parameters('iotHubName'))]"
],
"tags": {
"IotSuiteType": "[variables('suiteType')]"
},
"properties": {
"sku": {
"name": "standard"
},
"OutputStartMode": "[parameters('asaStartBehavior')]",
"OutputStartTime": "[parameters('asaStartTime')]",
"EventsOutOfOrderMaxDelayInSeconds": 10,
"EventsOutOfOrderPolicy": "adjust",
"Inputs": [
Expand Down Expand Up @@ -389,12 +405,14 @@
"[concat('Microsoft.Eventhub/namespaces/', parameters('sbName'))]",
"[concat('Microsoft.Devices/Iothubs/', parameters('iotHubName'))]"
],
"tags": {
"IotSuiteType": "[variables('suiteType')]"
},
"properties": {
"sku": {
"name": "standard"
},
"OutputStartMode": "[parameters('asaStartBehavior')]",
"OutputStartTime": "[parameters('asaStartTime')]",
"EventsOutOfOrderMaxDelayInSeconds": 10,
"EventsOutOfOrderPolicy": "adjust",
"Inputs": [
Expand Down Expand Up @@ -463,12 +481,14 @@
"[concat('Microsoft.Eventhub/namespaces/', parameters('sbName'))]",
"[concat('Microsoft.Devices/Iothubs/', parameters('iotHubName'))]"
],
"tags": {
"IotSuiteType": "[variables('suiteType')]"
},
"properties": {
"sku": {
"name": "standard"
},
"OutputStartMode": "[parameters('asaStartBehavior')]",
"OutputStartTime": "[parameters('asaStartTime')]",
"EventsOutOfOrderMaxDelayInSeconds": 10,
"EventsOutOfOrderPolicy": "adjust",
"Inputs": [
Expand Down Expand Up @@ -587,6 +607,9 @@
"name": "[variables('webPlanName')]",
"type": "Microsoft.Web/serverfarms",
"location": "[variables('location')]",
"tags": {
"IotSuiteType": "[variables('suiteType')]"
},
"properties": {
"name": "[variables('webPlanName')]",
"sku": "[parameters('webSku')]",
Expand All @@ -599,6 +622,9 @@
"name": "[variables('webJobPlanName')]",
"type": "Microsoft.Web/serverfarms",
"location": "[variables('location')]",
"tags": {
"IotSuiteType": "[variables('suiteType')]"
},
"properties": {
"name": "[variables('webJobPlanName')]",
"sku": "[parameters('webJobSku')]",
Expand All @@ -621,6 +647,9 @@
"[resourceId('Microsoft.Devices/Iothubs', parameters('iotHubName'))]",
"[resourceId('Microsoft.BingMaps/mapApis', variables('bingMapsName'))]"
],
"tags": {
"IotSuiteType": "[variables('suiteType')]"
},
"properties": {
"serverFarmId": "[variables('webPlanName')]",
"siteConfig": {
Expand Down Expand Up @@ -732,6 +761,9 @@
"[resourceId('Microsoft.StreamAnalytics/streamingjobs', concat(parameters('suiteName'), '-DeviceInfo'))]",
"[resourceId('Microsoft.StreamAnalytics/streamingjobs', concat(parameters('suiteName'), '-Rules'))]"
],
"tags": {
"IotSuiteType": "[variables('suiteType')]"
},
"properties": {
"serverFarmId": "[variables('webJobPlanName')]",
"siteConfig": {
Expand Down
Loading

0 comments on commit 861dd4d

Please sign in to comment.