зеркало из https://github.com/Azure/vdc.git
resolving conflicts
This commit is contained in:
Коммит
8c77dc75fa
|
@ -1 +1,114 @@
|
|||
Install-Module Az, Az.ResourceGraph, Pester -Force
|
||||
<#
|
||||
.NOTES
|
||||
==============================================================================================
|
||||
Copyright(c) Microsoft Corporation. All rights reserved.
|
||||
|
||||
File: InstallDependencies.ps1
|
||||
|
||||
Purpose: PowerShell - Install Module Dependencies
|
||||
|
||||
Version: 2.0.0.0 - 1st September 2019 - Azure Virtual Datacenter Development Team
|
||||
==============================================================================================
|
||||
|
||||
.SYNOPSIS
|
||||
This script contains functionality used to install PowerShell Module Dependencies.
|
||||
|
||||
.DESCRIPTION
|
||||
This script contains functionality used to install PowerShell Module Dependencies.
|
||||
|
||||
Deployment steps of the script are outlined below.
|
||||
1) Install Az Module
|
||||
2) Install Az.ResourceGraph Module
|
||||
3) Install Pester Module
|
||||
|
||||
DISCLAIMER:
|
||||
==============================================================================================
|
||||
This script is not supported under any Microsoft standard support program or service.
|
||||
|
||||
This script is provided AS IS without warranty of any kind.
|
||||
Microsoft further disclaims all implied warranties including, without limitation, any
|
||||
implied warranties of merchantability or of fitness for a particular purpose.
|
||||
|
||||
The entire risk arising out of the use or performance of the script
|
||||
and documentation remains with you. In no event shall Microsoft, its authors,
|
||||
or anyone else involved in the creation, production, or delivery of the
|
||||
script be liable for any damages whatsoever (including, without limitation,
|
||||
damages for loss of business profits, business interruption, loss of business
|
||||
information, or other pecuniary loss) arising out of the use of or inability
|
||||
to use the sample scripts or documentation, even if Microsoft has been
|
||||
advised of the possibility of such damages.
|
||||
==============================================================================================
|
||||
#>
|
||||
|
||||
#Requires -Version 5
|
||||
|
||||
#region - Functions
|
||||
function Get-IsElevated
|
||||
{
|
||||
#region - Get-IsElevated()
|
||||
try
|
||||
{
|
||||
$WindowsId = [System.Security.Principal.WindowsIdentity]::GetCurrent()
|
||||
$WindowsPrincipal = New-Object System.Security.Principal.WindowsPrincipal($WindowsId)
|
||||
$adminRole = [System.Security.Principal.WindowsBuiltInRole]::Administrator
|
||||
|
||||
if ($WindowsPrincipal.IsInRole($adminRole))
|
||||
{
|
||||
return $true
|
||||
}
|
||||
else
|
||||
{
|
||||
return $false
|
||||
}
|
||||
}
|
||||
catch [system.exception]
|
||||
{
|
||||
Write-Output "Error in Get-IsElevated() $($psitem.Exception.Message) Line:$($psitem.InvocationInfo.ScriptLineNumber) Char:$($psitem.InvocationInfo.OffsetInLine)"
|
||||
exit
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region - Install Dependencies
|
||||
Clear-Host
|
||||
|
||||
Write-Output "Script Started"
|
||||
|
||||
if (Get-IsElevated)
|
||||
{
|
||||
try
|
||||
{
|
||||
$timeSync = Get-Date
|
||||
$timeSync = $timeSync.ToString()
|
||||
|
||||
Write-Output "Script is running in an elevated PowerShell host."
|
||||
Write-Output "Start time: $timeSync`n"
|
||||
|
||||
#region - Install PowerShell Modules
|
||||
$paramInstallModule = @{
|
||||
Name = 'Az', 'Az.ResourceGraph', 'Pester'
|
||||
Force = $true
|
||||
ErrorAction = 'Stop'
|
||||
}
|
||||
Install-Module @paramInstallModule
|
||||
#endregion
|
||||
|
||||
$timeSync = Get-Date
|
||||
$timeSync = $timeSync.ToString()
|
||||
Write-Output "`nEnded at: $timeSync"
|
||||
}
|
||||
catch [system.exception]
|
||||
{
|
||||
Write-Output "Error:$($psitem.Exception.Message) Line:$($psitem.InvocationInfo.ScriptLineNumber) Char:$($psitem.InvocationInfo.OffsetInLine)"
|
||||
exit
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Write-Output "Please start the script from an elevated PowerShell host."
|
||||
exit
|
||||
}
|
||||
|
||||
Write-Output "Script Completed."
|
||||
#endregion
|
|
@ -28,134 +28,144 @@
|
|||
|
||||
#region Parameters
|
||||
$here = Split-Path -Parent $MyInvocation.MyCommand.Path
|
||||
$here = Join-Path $here ".."
|
||||
$here = Join-Path -Path $here -ChildPath ".."
|
||||
$template = Split-Path -Leaf $here
|
||||
$TemplateFileTestCases = @()
|
||||
|
||||
ForEach ( $File in (Get-ChildItem (Join-Path "$here" "deploy.json") -Recurse | Select-Object -ExpandProperty Name) ) {
|
||||
$TemplateFileTestCases += @{ TemplateFile = $File }
|
||||
#region - Template File Test Cases
|
||||
$templateFileTestCases = @()
|
||||
ForEach ($file in (Get-ChildItem (Join-Path -Path "$here" -ChildPath "deploy.json") -Recurse | Select-Object -ExpandProperty Name)) {
|
||||
$templateFileTestCases += @{ TemplateFile = $file }
|
||||
}
|
||||
$ParameterFileTestCases = @()
|
||||
ForEach ( $File in (Get-ChildItem (Join-Path "$here" "Tests" -AdditionalChildPath @("*parameters.json")) -Recurse -ErrorAction SilentlyContinue | Select-Object -ExpandProperty Name) ) {
|
||||
$ParameterFileTestCases += @{ ParameterFile = Join-Path "Tests" $File }
|
||||
#endregion
|
||||
|
||||
#region - Parameter File Test Cases
|
||||
$parameterFileTestCases = @()
|
||||
ForEach ($file in (Get-ChildItem (Join-Path -Path "$here" -ChildPath "Tests" -AdditionalChildPath @("*parameters.json")) -Recurse -ErrorAction SilentlyContinue | Select-Object -ExpandProperty Name)) {
|
||||
$parameterFileTestCases += @{ ParameterFile = Join-Path -Path "Tests" $file }
|
||||
}
|
||||
$Modules = @();
|
||||
ForEach ( $File in (Get-ChildItem (Join-Path "$here" "deploy.json") ) ) {
|
||||
$Module = [PSCustomObject]@{
|
||||
#endregion
|
||||
|
||||
#region - Module Test Cases
|
||||
$modules = @()
|
||||
ForEach ($file in (Get-ChildItem (Join-Path -Path "$here" -ChildPath "deploy.json"))) {
|
||||
$module = [PSCustomObject]@{
|
||||
'Template' = $null
|
||||
'Parameters' = $null
|
||||
}
|
||||
$Module.Template = $File.FullName;
|
||||
$Parameters = @();
|
||||
ForEach ( $ParameterFile in (Get-ChildItem (Join-Path "$here" "Tests" -AdditionalChildPath @("*parameters.json")) -Recurse -ErrorAction SilentlyContinue | Select-Object -ExpandProperty Name) ) {
|
||||
$Parameters += (Join-Path "$here" "Tests" -AdditionalChildPath @("$ParameterFile") )
|
||||
$module.Template = $file.FullName
|
||||
|
||||
$parameters = @()
|
||||
ForEach ($parameterFile in (Get-ChildItem (Join-Path -Path "$here" -ChildPath "Tests" -AdditionalChildPath @("*parameters.json")) -Recurse -ErrorAction SilentlyContinue | Select-Object -ExpandProperty Name)) {
|
||||
$parameters += (Join-Path -Path "$here" -ChildPath "Tests" -AdditionalChildPath @("$ParameterFile"))
|
||||
}
|
||||
$Module.Parameters = $Parameters;
|
||||
$Modules += @{ Module = $Module };
|
||||
$Module.Parameters = $Parameters
|
||||
$Modules += @{Module = $Module}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
#region Run Pester Test Script
|
||||
Describe "Template: $template - Storage Accounts" -Tags Unit {
|
||||
#region - Run Pester Test Script
|
||||
Describe "Template: $template - API Management Service" -Tags -Unit {
|
||||
|
||||
#region - Template File Syntax
|
||||
Context "Template File Syntax" {
|
||||
|
||||
It "Has a JSON template file" {
|
||||
(Join-Path "$here" "deploy.json") | Should Exist
|
||||
(Join-Path -Path "$here" -ChildPath "deploy.json") | Should -Exist
|
||||
}
|
||||
|
||||
It "Converts from JSON and has the expected properties" -TestCases $TemplateFileTestCases {
|
||||
Param( $TemplateFile )
|
||||
It "Converts from JSON and has the expected properties" -TestCases $templateFileTestCases {
|
||||
param($templateFile)
|
||||
$expectedProperties = '$schema',
|
||||
'contentVersion',
|
||||
'parameters',
|
||||
'variables',
|
||||
'resources',
|
||||
'outputs' | Sort-Object
|
||||
$templateProperties = (Get-Content (Join-Path "$here" "$TemplateFile") `
|
||||
| ConvertFrom-Json -ErrorAction SilentlyContinue) `
|
||||
| Get-Member -MemberType NoteProperty `
|
||||
| Sort-Object -Property Name `
|
||||
| ForEach-Object Name
|
||||
$templateProperties | Should Be $expectedProperties
|
||||
}
|
||||
$templateProperties = (Get-Content (Join-Path -Path "$here" -ChildPath "$templateFile") `
|
||||
| ConvertFrom-Json -ErrorAction SilentlyContinue) `
|
||||
| Get-Member -MemberType NoteProperty `
|
||||
| Sort-Object -Property Name `
|
||||
| ForEach-Object Name
|
||||
$templateProperties | Should -Be $expectedProperties
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region - Parameter File Syntax
|
||||
Context "Parameter File Syntax" {
|
||||
|
||||
It "Parameter file does not contains the expected properties" -TestCases $ParameterFileTestCases {
|
||||
Param( $ParameterFile )
|
||||
|
||||
It "Parameter file does not contains the expected properties" -TestCases $parameterFileTestCases {
|
||||
param($parameterFile)
|
||||
$expectedProperties = '$schema',
|
||||
'contentVersion',
|
||||
'parameters' | Sort-Object
|
||||
Write-Host $ParameterFile
|
||||
Join-Path "$here" "$ParameterFile" | Write-Host
|
||||
$templateFileProperties = (Get-Content (Join-Path "$here" "$ParameterFile") `
|
||||
| ConvertFrom-Json -ErrorAction SilentlyContinue) `
|
||||
| Get-Member -MemberType NoteProperty `
|
||||
| Sort-Object -Property Name `
|
||||
| ForEach-Object Name
|
||||
$templateFileProperties | Should Be $expectedProperties
|
||||
Write-Output $parameterFile
|
||||
Join-Path -Path "$here" -ChildPath "$parameterFile" | Write-Output
|
||||
$templateFileProperties = (Get-Content (Join-Path -Path "$here" -ChildPath "$parameterFile") `
|
||||
| ConvertFrom-Json -ErrorAction SilentlyContinue) `
|
||||
| Get-Member -MemberType NoteProperty `
|
||||
| Sort-Object -Property Name `
|
||||
| ForEach-Object Name
|
||||
$templateFileProperties | Should -Be $expectedProperties
|
||||
}
|
||||
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region - Template and Parameter Compactibility
|
||||
Context "Template and Parameter Compactibility" {
|
||||
|
||||
It "Is count of required parameters in template file equal or lesser than count of all parameters in parameters file" -TestCases $Modules {
|
||||
Param( $Module )
|
||||
|
||||
$requiredParametersInTemplateFile = (Get-Content "$($Module.Template)" `
|
||||
| ConvertFrom-Json -ErrorAction SilentlyContinue).Parameters.PSObject.Properties `
|
||||
| Where-Object -FilterScript { -not ($_.Value.PSObject.Properties.Name -eq "defaultValue") } `
|
||||
| Sort-Object -Property Name `
|
||||
| ForEach-Object Name
|
||||
ForEach ( $Parameter in $Module.Parameters ) {
|
||||
$allParametersInParametersFile = (Get-Content $Parameter `
|
||||
| ConvertFrom-Json -ErrorAction SilentlyContinue).Parameters.PSObject.Properties `
|
||||
| Sort-Object -Property Name `
|
||||
| ForEach-Object Name
|
||||
$requiredParametersInTemplateFile.Count | Should Not BeGreaterThan $allParametersInParametersFile.Count;
|
||||
It "Is count of required parameters in template file equal or lesser than count of all parameters in parameters file" -TestCases $modules {
|
||||
param($module)
|
||||
$requiredParametersInTemplateFile = (Get-Content "$($module.Template)" `
|
||||
| ConvertFrom-Json -ErrorAction SilentlyContinue).Parameters.PSObject.Properties `
|
||||
| Where-Object -FilterScript { -not ($psitem.Value.PSObject.Properties.Name -eq "defaultValue")} `
|
||||
| Sort-Object -Property Name `
|
||||
| ForEach-Object Name
|
||||
ForEach ( $parameter in $module.Parameters ) {
|
||||
$allParametersInParametersFile = (Get-Content $parameter `
|
||||
| ConvertFrom-Json -ErrorAction SilentlyContinue).Parameters.PSObject.Properties `
|
||||
| Sort-Object -Property Name `
|
||||
| ForEach-Object Name
|
||||
$requiredParametersInTemplateFile.Count | Should -Not -BeGreaterThan $allParametersInParametersFile.Count
|
||||
}
|
||||
}
|
||||
|
||||
It "Has all parameters in parameters file existing in template file" -TestCases $Modules {
|
||||
Param( $Module )
|
||||
|
||||
$allParametersInTemplateFile = (Get-Content "$($Module.Template)" `
|
||||
| ConvertFrom-Json -ErrorAction SilentlyContinue).Parameters.PSObject.Properties `
|
||||
| Sort-Object -Property Name `
|
||||
| ForEach-Object Name
|
||||
ForEach ( $Parameter in $Module.Parameters ) {
|
||||
Write-Host "File analyzed: $Parameter";
|
||||
$allParametersInParametersFile = (Get-Content $Parameter `
|
||||
| ConvertFrom-Json -ErrorAction SilentlyContinue).Parameters.PSObject.Properties `
|
||||
| Sort-Object -Property Name `
|
||||
| ForEach-Object Name
|
||||
$result = @($allParametersInParametersFile| Where-Object {$allParametersInTemplateFile -notcontains $_});
|
||||
Write-Host "Invalid parameters: $(ConvertTo-Json $result)";
|
||||
@($allParametersInParametersFile| Where-Object {$allParametersInTemplateFile -notcontains $_}).Count | Should Be 0;
|
||||
It "Has all parameters in parameters file existing in template file" -TestCases $modules {
|
||||
param($module)
|
||||
$allParametersInTemplateFile = (Get-Content "$($module.Template)" `
|
||||
| ConvertFrom-Json -ErrorAction SilentlyContinue).Parameters.PSObject.Properties `
|
||||
| Sort-Object -Property Name `
|
||||
| ForEach-Object Name
|
||||
ForEach ($parameter in $module.Parameters) {
|
||||
Write-Output "File analyzed: $parameter"
|
||||
$allParametersInParametersFile = (Get-Content $parameter `
|
||||
| ConvertFrom-Json -ErrorAction SilentlyContinue).Parameters.PSObject.Properties `
|
||||
| Sort-Object -Property Name `
|
||||
| ForEach-Object Name
|
||||
$result = @($allParametersInParametersFile| Where-Object {$allParametersInTemplateFile -notcontains $psitem})
|
||||
Write-Output "Invalid parameters: $(ConvertTo-Json $result)"
|
||||
@($allParametersInParametersFile| Where-Object {$allParametersInTemplateFile -notcontains $psitem}).Count | Should -Be 0
|
||||
}
|
||||
}
|
||||
|
||||
It "Has required parameters in template file existing in parameters file" -TestCases $Modules {
|
||||
Param( $Module )
|
||||
|
||||
$requiredParametersInTemplateFile = (Get-Content "$($Module.Template)" `
|
||||
| ConvertFrom-Json -ErrorAction SilentlyContinue).Parameters.PSObject.Properties `
|
||||
| Where-Object -FilterScript { -not ($_.Value.PSObject.Properties.Name -eq "defaultValue") } `
|
||||
| Sort-Object -Property Name `
|
||||
| ForEach-Object Name
|
||||
ForEach ( $Parameter in $Module.Parameters ) {
|
||||
$allParametersInParametersFile = (Get-Content $Parameter `
|
||||
| ConvertFrom-Json -ErrorAction SilentlyContinue).Parameters.PSObject.Properties `
|
||||
| Sort-Object -Property Name `
|
||||
| ForEach-Object Name
|
||||
@($requiredParametersInTemplateFile| Where-Object {$allParametersInParametersFile -notcontains $_}).Count | Should Be 0;
|
||||
It "Has required parameters in template file existing in parameters file" -TestCases $modules {
|
||||
param($module)
|
||||
$requiredParametersInTemplateFile = (Get-Content "$($module.Template)" `
|
||||
| ConvertFrom-Json -ErrorAction SilentlyContinue).Parameters.PSObject.Properties `
|
||||
| Where-Object -FilterScript { -not ($psitem.Value.PSObject.Properties.Name -eq "defaultValue") } `
|
||||
| Sort-Object -Property Name `
|
||||
| ForEach-Object Name
|
||||
ForEach ($parameter in $module.Parameters ) {
|
||||
$allParametersInParametersFile = (Get-Content $parameter `
|
||||
| ConvertFrom-Json -ErrorAction SilentlyContinue).Parameters.PSObject.Properties `
|
||||
| Sort-Object -Property Name `
|
||||
| ForEach-Object Name
|
||||
@($requiredParametersInTemplateFile| Where-Object {$allParametersInParametersFile -notcontains $psitem}).Count | Should -Be 0
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
#endregion
|
|
@ -5,7 +5,7 @@
|
|||
|
||||
Microsoft Consulting Services - AzureCAT - VDC Toolkit (v2.0)
|
||||
|
||||
File: output.test.ps1
|
||||
File: output.tests.ps1
|
||||
|
||||
Purpose: Test - API Management Service ARM Template Output Variables
|
||||
|
||||
|
@ -32,7 +32,7 @@
|
|||
|
||||
.EXAMPLE
|
||||
Default:
|
||||
C:\PS>.\output.test.ps1
|
||||
C:\PS>.\output.tests.ps1
|
||||
-apimServiceName "$(apimServiceName)"
|
||||
-apimServiceResourceId "$(apimServiceResourceId)"
|
||||
-apimServiceResourceGroup "$(apimServiceResourceGroup)"
|
|
@ -5,7 +5,7 @@
|
|||
"apiManagementServiceName": {
|
||||
"type": "string",
|
||||
"metadata": {
|
||||
"description": "Required. The name of the of the API Management service"
|
||||
"description": "Required. The name of the of the Api Management service"
|
||||
}
|
||||
},
|
||||
"publisherEmail": {
|
||||
|
@ -24,12 +24,13 @@
|
|||
"type": "string",
|
||||
"allowedValues": [
|
||||
"Developer",
|
||||
"Basic",
|
||||
"Standard",
|
||||
"Premium"
|
||||
],
|
||||
"defaultValue": "Developer",
|
||||
"metadata": {
|
||||
"description": "Optional.The pricing tier of this API Management service"
|
||||
"description": "Optional.The pricing tier of this Api Management service"
|
||||
}
|
||||
},
|
||||
"skuCount": {
|
||||
|
@ -40,14 +41,14 @@
|
|||
],
|
||||
"defaultValue": "1",
|
||||
"metadata": {
|
||||
"description": "Optional.The instance size of this API Management service"
|
||||
"description": "Optional.The instance size of this Api Management service"
|
||||
}
|
||||
},
|
||||
"location": {
|
||||
"type": "string",
|
||||
"defaultValue": "[resourceGroup().location]",
|
||||
"metadata": {
|
||||
"description": "Optional. Location of the API Management service"
|
||||
"description": "Optional. Location for all Resources"
|
||||
}
|
||||
},
|
||||
"diagnosticStorageAccountId": {
|
||||
|
@ -78,45 +79,18 @@
|
|||
"description": "Optional. Customer Usage Attribution Id (GUID). This GUID must be previously registered"
|
||||
}
|
||||
},
|
||||
"tagEnvironment": {
|
||||
"type": "string",
|
||||
"tagValues": {
|
||||
"type": "object",
|
||||
"defaultValue": "",
|
||||
"metadata": {
|
||||
"description": "Optional. The name of the Environment"
|
||||
}
|
||||
},
|
||||
"tagProject": {
|
||||
"type": "string",
|
||||
"defaultValue": "",
|
||||
"metadata": {
|
||||
"description": "Optional. The name of the project"
|
||||
}
|
||||
},
|
||||
"tagApplication": {
|
||||
"type": "string",
|
||||
"defaultValue": "",
|
||||
"metadata": {
|
||||
"description": "Optional. The name of the application"
|
||||
}
|
||||
},
|
||||
"tagOwner": {
|
||||
"type": "string",
|
||||
"defaultValue": "",
|
||||
"metadata": {
|
||||
"description": "Optional. The business owner for the application"
|
||||
}
|
||||
},
|
||||
"tagOwnerEmail": {
|
||||
"type": "string",
|
||||
"defaultValue": "",
|
||||
"metadata": {
|
||||
"description": "Optional. The Email address of the business owner for the application"
|
||||
"description": "Optional. Azure Resource Tags object"
|
||||
}
|
||||
}
|
||||
},
|
||||
"variables": {
|
||||
"apimServiceName": "[parameters('apiManagementServiceName')]",
|
||||
"apimServiceResourceId": "[resourceId('Microsoft.ApiManagement/service',parameters('apiManagementServiceName'))]",
|
||||
"apimServiceApiVersion": "2019-01-01",
|
||||
"diagnosticStorageAccountId": "[parameters('diagnosticStorageAccountId')]",
|
||||
"diagnosticWorkspaceId": "[parameters('logAnalyticsWorkspaceId')]",
|
||||
"pidName": "[concat('pid-', parameters('cuaId'))]"
|
||||
|
@ -138,16 +112,10 @@
|
|||
},
|
||||
{
|
||||
"type": "Microsoft.ApiManagement/service",
|
||||
"apiVersion": "2019-01-01",
|
||||
"name": "[parameters('apiManagementServiceName')]",
|
||||
"apiVersion": "[variables('apimServiceApiVersion')]",
|
||||
"name": "[variables('apimServiceName')]",
|
||||
"location": "[parameters('location')]",
|
||||
"tags": {
|
||||
"Environment": "[parameters('tagEnvironment')]",
|
||||
"Application": "[parameters('tagApplication')]",
|
||||
"Project": "[parameters('tagProject')]",
|
||||
"Owner": "[parameters('tagOwner')]",
|
||||
"OwnerEmail": "[parameters('tagOwnerEmail')]"
|
||||
},
|
||||
"tags": "[if(empty(parameters('tagValues')), json('null'), parameters('tagValues'))]",
|
||||
"sku": {
|
||||
"name": "[parameters('sku')]",
|
||||
"capacity": "[parameters('skuCount')]"
|
||||
|
@ -155,7 +123,8 @@
|
|||
"properties": {
|
||||
"publisherEmail": "[parameters('publisherEmail')]",
|
||||
"publisherName": "[parameters('publisherName')]",
|
||||
"notificationSenderEmail": "apimgmt-noreply@mail.windowsazure.com"
|
||||
"notificationSenderEmail": "apimgmt-noreply@mail.windowsazure.com",
|
||||
"virtualNetworkType": "None"
|
||||
},
|
||||
"resources": [
|
||||
{
|
||||
|
@ -164,11 +133,12 @@
|
|||
"name": "[concat(variables('apimServiceName'), '/', 'Microsoft.Insights/service')]",
|
||||
"location": "[parameters('location')]",
|
||||
"dependsOn": [
|
||||
"[concat('Microsoft.ApiManagement/service/', variables('apimServiceName'))]"
|
||||
"[variables('apimServiceResourceId')]"
|
||||
],
|
||||
"properties": {
|
||||
"storageAccountId": "[variables('diagnosticStorageAccountId')]",
|
||||
"workspaceId": "[variables('diagnosticWorkspaceId')]",
|
||||
"logAnalyticsDestinationType": "Dedicated",
|
||||
"logs": [
|
||||
{
|
||||
"category": "GatewayLogs",
|
||||
|
@ -215,21 +185,21 @@
|
|||
"type": "string",
|
||||
"value": "[variables('apimServiceName')]",
|
||||
"metadata": {
|
||||
"description": "The API Management Service Name"
|
||||
"description": "The Api Management Service Name"
|
||||
}
|
||||
},
|
||||
"apimServiceResourceId": {
|
||||
"type": "string",
|
||||
"value": "[variables('apimServiceResourceId')]",
|
||||
"metadata": {
|
||||
"description": "The Resource Id of the API Management Service"
|
||||
"description": "The Resource Id of the Api Management Service"
|
||||
}
|
||||
},
|
||||
"apimServiceResourceGroup": {
|
||||
"type": "string",
|
||||
"value": "[resourceGroup().name]",
|
||||
"metadata": {
|
||||
"description": "The name of the Resource Group with the API Management Service"
|
||||
"description": "The name of the Resource Group with the Api Management Service"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
# API Management
|
||||
|
||||
This module deploys API Management.
|
||||
# Api Management
|
||||
|
||||
This module deploys Api Management.
|
||||
|
||||
## Resources
|
||||
|
||||
|
@ -10,47 +9,40 @@ The following Resources are deployed.
|
|||
+ **Microsoft.ApiManagement/service**
|
||||
+ **Microsoft.ApiManagement/service/providers/diagnosticsettings**
|
||||
|
||||
|
||||
## Parameters
|
||||
|
||||
| Parameter Name | Default Value | Description |
|
||||
| :- | :- | :- |
|
||||
| `apiManagementServiceName` || **Required** The name of the of the API Management Service
|
||||
| `publisherEmail` || **Required** The email address of the owner of the service
|
||||
| `publisherName` || **Required** The name of the owner of the service
|
||||
| `sku` | Developer | **Optional** The pricing tier of this API Management service
|
||||
| `skuCount` | 1 | **Optional** The instance size of this API Management service
|
||||
| `location` | resourceGroup().location | **Optional** Location for all resources
|
||||
| `diagnosticStorageAccountId` || **Required** Resource identifier of the Diagnostic Storage Account
|
||||
| `logAnalyticsWorkspaceId` || **Required** Resource identifier of Log Analytics Workspace
|
||||
| `logsRetentionInDays` | 30 | **Optional** Specifies the number of days that logs will be kept for, a value of 0 will retain data indefinitely
|
||||
| `cuaId` || **Optional** Customer Usage Attribution Id (GUID). This GUID must be previously registered
|
||||
| `tagEnvironment` || **Optional** The name of the Environment
|
||||
| `tagProject` || **Optional** The name of the project
|
||||
| `tagApplication` || **Optional** The name of the application
|
||||
| `tagOwner` || **Optional** The business owner for the application
|
||||
| `tagOwnerEmail` || **Optional** The Email address of the business owner for the application
|
||||
|
||||
| Parameter Name | Default Value | Required | Description |
|
||||
| :- | :- | :- |:- |
|
||||
| `apiManagementServiceName` || **Required** | The name of the of the Api Management Service
|
||||
| `publisherEmail` || **Required** | The email address of the owner of the service
|
||||
| `publisherName` || **Required** | The name of the owner of the service
|
||||
| `notificationSenderEmail` || **Optional** | The notification sender email address for the service
|
||||
| `sku` | Developer | **Optional** | The pricing tier of this Api Management service
|
||||
| `skuCount` | 1 | **Optional** | The instance size of this Api Management service
|
||||
| `location` | resourceGroup().location | **Optional** | Location for all Resources"
|
||||
| `diagnosticStorageAccountId` || **Required** | Resource identifier of the Diagnostic Storage Account
|
||||
| `logAnalyticsWorkspaceId` || **Required** | Resource identifier of Log Analytics Workspace
|
||||
| `logsRetentionInDays` | 30 | **Optional** | Specifies the number of days that logs will be kept for, a value of 0 will retain data indefinitely
|
||||
| `cuaId` || **Optional** | Customer Usage Attribution Id (GUID). This GUID must be previously registered
|
||||
| `tagValues` || **Optional** | Optional. Azure Resource Tags object
|
||||
|
||||
## Outputs
|
||||
|
||||
| Output Name | Description |
|
||||
| :- | :- |
|
||||
| `apimServiceName` | API Management Service Name output parameter
|
||||
| `apimServiceResourceId` | API Management Service ResourceId output parameter
|
||||
| `apimServiceResourceGroup` | API Management Service ResourceGroup output parameter
|
||||
|
||||
| `apimServiceName` | Api Management Service Name output parameter
|
||||
| `apimServiceResourceId` | Api Management Service ResourceId output parameter
|
||||
| `apimServiceResourceGroup` | Api Management Service ResourceGroup output parameter
|
||||
|
||||
## Scripts
|
||||
|
||||
+ There is no Scripts for this Module
|
||||
|
||||
+ There is no deployment considerations for this Module.
|
||||
|
||||
## Considerations
|
||||
|
||||
+ There is no deployment considerations for this Module.
|
||||
|
||||
|
||||
## Additional resources
|
||||
|
||||
[Microsoft API Management template reference](https://docs.microsoft.com/en-us/azure/templates/microsoft.apimanagement/allversions)
|
||||
+ [Microsoft Api Management template reference](https://docs.microsoft.com/en-us/azure/templates/microsoft.apimanagement/allversions)
|
||||
+ [Microsoft Api Management diagnostic settings reference](https://docs.microsoft.com/en-us/azure/api-management/api-management-howto-use-azure-monitor#diagnostic-logs)
|
||||
|
|
|
@ -27,135 +27,145 @@
|
|||
#Requires -Version 5
|
||||
|
||||
#region Parameters
|
||||
|
||||
$here = Split-Path -Parent $MyInvocation.MyCommand.Path
|
||||
$here = Join-Path $here ".."
|
||||
$here = Join-Path -Path $here -ChildPath ".."
|
||||
$template = Split-Path -Leaf $here
|
||||
$TemplateFileTestCases = @()
|
||||
ForEach ( $File in (Get-ChildItem (Join-Path "$here" "deploy.json") -Recurse | Select-Object -ExpandProperty Name) ) {
|
||||
$TemplateFileTestCases += @{ TemplateFile = $File }
|
||||
|
||||
#region - Template File Test Cases
|
||||
$templateFileTestCases = @()
|
||||
ForEach ($file in (Get-ChildItem (Join-Path -Path "$here" -ChildPath "deploy.json") -Recurse | Select-Object -ExpandProperty Name)) {
|
||||
$templateFileTestCases += @{ TemplateFile = $file }
|
||||
}
|
||||
$ParameterFileTestCases = @()
|
||||
ForEach ( $File in (Get-ChildItem (Join-Path "$here" "Tests" -AdditionalChildPath @("*parameters.json")) -Recurse -ErrorAction SilentlyContinue | Select-Object -ExpandProperty Name) ) {
|
||||
$ParameterFileTestCases += @{ ParameterFile = Join-Path "Tests" $File }
|
||||
#endregion
|
||||
|
||||
#region - Parameter File Test Cases
|
||||
$parameterFileTestCases = @()
|
||||
ForEach ($file in (Get-ChildItem (Join-Path -Path "$here" -ChildPath "Tests" -AdditionalChildPath @("*parameters.json")) -Recurse -ErrorAction SilentlyContinue | Select-Object -ExpandProperty Name)) {
|
||||
$parameterFileTestCases += @{ ParameterFile = Join-Path -Path "Tests" $file }
|
||||
}
|
||||
$Modules = @();
|
||||
ForEach ( $File in (Get-ChildItem (Join-Path "$here" "deploy.json") ) ) {
|
||||
$Module = [PSCustomObject]@{
|
||||
#endregion
|
||||
|
||||
#region - Module Test Cases
|
||||
$modules = @()
|
||||
ForEach ($file in (Get-ChildItem (Join-Path -Path "$here" -ChildPath "deploy.json"))) {
|
||||
$module = [PSCustomObject]@{
|
||||
'Template' = $null
|
||||
'Parameters' = $null
|
||||
}
|
||||
$Module.Template = $File.FullName;
|
||||
$Parameters = @();
|
||||
ForEach ( $ParameterFile in (Get-ChildItem (Join-Path "$here" "Tests" -AdditionalChildPath @("*parameters.json")) -Recurse -ErrorAction SilentlyContinue | Select-Object -ExpandProperty Name) ) {
|
||||
$Parameters += (Join-Path "$here" "Tests" -AdditionalChildPath @("$ParameterFile") )
|
||||
$module.Template = $file.FullName
|
||||
|
||||
$parameters = @()
|
||||
ForEach ($parameterFile in (Get-ChildItem (Join-Path -Path "$here" -ChildPath "Tests" -AdditionalChildPath @("*parameters.json")) -Recurse -ErrorAction SilentlyContinue | Select-Object -ExpandProperty Name)) {
|
||||
$parameters += (Join-Path -Path "$here" -ChildPath "Tests" -AdditionalChildPath @("$ParameterFile"))
|
||||
}
|
||||
$Module.Parameters = $Parameters;
|
||||
$Modules += @{ Module = $Module };
|
||||
$Module.Parameters = $Parameters
|
||||
$Modules += @{Module = $Module}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
#region Run Pester Test Script
|
||||
Describe "Template: $template - Storage Accounts" -Tags Unit {
|
||||
#region - Run Pester Test Script
|
||||
Describe "Template: $template - Analysis Services" -Tags -Unit {
|
||||
|
||||
#region - Template File Syntax
|
||||
Context "Template File Syntax" {
|
||||
|
||||
It "Has a JSON template file" {
|
||||
(Join-Path "$here" "deploy.json") | Should Exist
|
||||
(Join-Path -Path "$here" -ChildPath "deploy.json") | Should -Exist
|
||||
}
|
||||
|
||||
It "Converts from JSON and has the expected properties" -TestCases $TemplateFileTestCases {
|
||||
Param( $TemplateFile )
|
||||
It "Converts from JSON and has the expected properties" -TestCases $templateFileTestCases {
|
||||
param($templateFile)
|
||||
$expectedProperties = '$schema',
|
||||
'contentVersion',
|
||||
'parameters',
|
||||
'variables',
|
||||
'resources',
|
||||
'outputs' | Sort-Object
|
||||
$templateProperties = (Get-Content (Join-Path "$here" "$TemplateFile") `
|
||||
| ConvertFrom-Json -ErrorAction SilentlyContinue) `
|
||||
| Get-Member -MemberType NoteProperty `
|
||||
| Sort-Object -Property Name `
|
||||
| ForEach-Object Name
|
||||
$templateProperties | Should Be $expectedProperties
|
||||
}
|
||||
$templateProperties = (Get-Content (Join-Path -Path "$here" -ChildPath "$templateFile") `
|
||||
| ConvertFrom-Json -ErrorAction SilentlyContinue) `
|
||||
| Get-Member -MemberType NoteProperty `
|
||||
| Sort-Object -Property Name `
|
||||
| ForEach-Object Name
|
||||
$templateProperties | Should -Be $expectedProperties
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region - Parameter File Syntax
|
||||
Context "Parameter File Syntax" {
|
||||
|
||||
It "Parameter file does not contains the expected properties" -TestCases $ParameterFileTestCases {
|
||||
Param( $ParameterFile )
|
||||
|
||||
It "Parameter file does not contains the expected properties" -TestCases $parameterFileTestCases {
|
||||
param($parameterFile)
|
||||
$expectedProperties = '$schema',
|
||||
'contentVersion',
|
||||
'parameters' | Sort-Object
|
||||
Write-Host $ParameterFile
|
||||
Join-Path "$here" "$ParameterFile" | Write-Host
|
||||
$templateFileProperties = (Get-Content (Join-Path "$here" "$ParameterFile") `
|
||||
| ConvertFrom-Json -ErrorAction SilentlyContinue) `
|
||||
| Get-Member -MemberType NoteProperty `
|
||||
| Sort-Object -Property Name `
|
||||
| ForEach-Object Name
|
||||
$templateFileProperties | Should Be $expectedProperties
|
||||
Write-Output $parameterFile
|
||||
Join-Path -Path "$here" -ChildPath "$parameterFile" | Write-Output
|
||||
$templateFileProperties = (Get-Content (Join-Path -Path "$here" -ChildPath "$parameterFile") `
|
||||
| ConvertFrom-Json -ErrorAction SilentlyContinue) `
|
||||
| Get-Member -MemberType NoteProperty `
|
||||
| Sort-Object -Property Name `
|
||||
| ForEach-Object Name
|
||||
$templateFileProperties | Should -Be $expectedProperties
|
||||
}
|
||||
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region - Template and Parameter Compactibility
|
||||
Context "Template and Parameter Compactibility" {
|
||||
|
||||
It "Is count of required parameters in template file equal or lesser than count of all parameters in parameters file" -TestCases $Modules {
|
||||
Param( $Module )
|
||||
|
||||
$requiredParametersInTemplateFile = (Get-Content "$($Module.Template)" `
|
||||
| ConvertFrom-Json -ErrorAction SilentlyContinue).Parameters.PSObject.Properties `
|
||||
| Where-Object -FilterScript { -not ($_.Value.PSObject.Properties.Name -eq "defaultValue") } `
|
||||
| Sort-Object -Property Name `
|
||||
| ForEach-Object Name
|
||||
ForEach ( $Parameter in $Module.Parameters ) {
|
||||
$allParametersInParametersFile = (Get-Content $Parameter `
|
||||
| ConvertFrom-Json -ErrorAction SilentlyContinue).Parameters.PSObject.Properties `
|
||||
| Sort-Object -Property Name `
|
||||
| ForEach-Object Name
|
||||
$requiredParametersInTemplateFile.Count | Should Not BeGreaterThan $allParametersInParametersFile.Count;
|
||||
It "Is count of required parameters in template file equal or lesser than count of all parameters in parameters file" -TestCases $modules {
|
||||
param($module)
|
||||
$requiredParametersInTemplateFile = (Get-Content "$($module.Template)" `
|
||||
| ConvertFrom-Json -ErrorAction SilentlyContinue).Parameters.PSObject.Properties `
|
||||
| Where-Object -FilterScript { -not ($psitem.Value.PSObject.Properties.Name -eq "defaultValue")} `
|
||||
| Sort-Object -Property Name `
|
||||
| ForEach-Object Name
|
||||
ForEach ( $parameter in $module.Parameters ) {
|
||||
$allParametersInParametersFile = (Get-Content $parameter `
|
||||
| ConvertFrom-Json -ErrorAction SilentlyContinue).Parameters.PSObject.Properties `
|
||||
| Sort-Object -Property Name `
|
||||
| ForEach-Object Name
|
||||
$requiredParametersInTemplateFile.Count | Should -Not -BeGreaterThan $allParametersInParametersFile.Count
|
||||
}
|
||||
}
|
||||
|
||||
It "Has all parameters in parameters file existing in template file" -TestCases $Modules {
|
||||
Param( $Module )
|
||||
|
||||
$allParametersInTemplateFile = (Get-Content "$($Module.Template)" `
|
||||
| ConvertFrom-Json -ErrorAction SilentlyContinue).Parameters.PSObject.Properties `
|
||||
| Sort-Object -Property Name `
|
||||
| ForEach-Object Name
|
||||
ForEach ( $Parameter in $Module.Parameters ) {
|
||||
Write-Host "File analyzed: $Parameter";
|
||||
$allParametersInParametersFile = (Get-Content $Parameter `
|
||||
| ConvertFrom-Json -ErrorAction SilentlyContinue).Parameters.PSObject.Properties `
|
||||
| Sort-Object -Property Name `
|
||||
| ForEach-Object Name
|
||||
$result = @($allParametersInParametersFile| Where-Object {$allParametersInTemplateFile -notcontains $_});
|
||||
Write-Host "Invalid parameters: $(ConvertTo-Json $result)";
|
||||
@($allParametersInParametersFile| Where-Object {$allParametersInTemplateFile -notcontains $_}).Count | Should Be 0;
|
||||
It "Has all parameters in parameters file existing in template file" -TestCases $modules {
|
||||
param($module)
|
||||
$allParametersInTemplateFile = (Get-Content "$($module.Template)" `
|
||||
| ConvertFrom-Json -ErrorAction SilentlyContinue).Parameters.PSObject.Properties `
|
||||
| Sort-Object -Property Name `
|
||||
| ForEach-Object Name
|
||||
ForEach ($parameter in $module.Parameters) {
|
||||
Write-Output "File analyzed: $parameter"
|
||||
$allParametersInParametersFile = (Get-Content $parameter `
|
||||
| ConvertFrom-Json -ErrorAction SilentlyContinue).Parameters.PSObject.Properties `
|
||||
| Sort-Object -Property Name `
|
||||
| ForEach-Object Name
|
||||
$result = @($allParametersInParametersFile| Where-Object {$allParametersInTemplateFile -notcontains $psitem})
|
||||
Write-Output "Invalid parameters: $(ConvertTo-Json $result)"
|
||||
@($allParametersInParametersFile| Where-Object {$allParametersInTemplateFile -notcontains $psitem}).Count | Should -Be 0
|
||||
}
|
||||
}
|
||||
|
||||
It "Has required parameters in template file existing in parameters file" -TestCases $Modules {
|
||||
Param( $Module )
|
||||
|
||||
$requiredParametersInTemplateFile = (Get-Content "$($Module.Template)" `
|
||||
| ConvertFrom-Json -ErrorAction SilentlyContinue).Parameters.PSObject.Properties `
|
||||
| Where-Object -FilterScript { -not ($_.Value.PSObject.Properties.Name -eq "defaultValue") } `
|
||||
| Sort-Object -Property Name `
|
||||
| ForEach-Object Name
|
||||
ForEach ( $Parameter in $Module.Parameters ) {
|
||||
$allParametersInParametersFile = (Get-Content $Parameter `
|
||||
| ConvertFrom-Json -ErrorAction SilentlyContinue).Parameters.PSObject.Properties `
|
||||
| Sort-Object -Property Name `
|
||||
| ForEach-Object Name
|
||||
@($requiredParametersInTemplateFile| Where-Object {$allParametersInParametersFile -notcontains $_}).Count | Should Be 0;
|
||||
It "Has required parameters in template file existing in parameters file" -TestCases $modules {
|
||||
param($module)
|
||||
$requiredParametersInTemplateFile = (Get-Content "$($module.Template)" `
|
||||
| ConvertFrom-Json -ErrorAction SilentlyContinue).Parameters.PSObject.Properties `
|
||||
| Where-Object -FilterScript { -not ($psitem.Value.PSObject.Properties.Name -eq "defaultValue") } `
|
||||
| Sort-Object -Property Name `
|
||||
| ForEach-Object Name
|
||||
ForEach ($parameter in $module.Parameters ) {
|
||||
$allParametersInParametersFile = (Get-Content $parameter `
|
||||
| ConvertFrom-Json -ErrorAction SilentlyContinue).Parameters.PSObject.Properties `
|
||||
| Sort-Object -Property Name `
|
||||
| ForEach-Object Name
|
||||
@($requiredParametersInTemplateFile| Where-Object {$allParametersInParametersFile -notcontains $psitem}).Count | Should -Be 0
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
#endregion
|
|
@ -5,7 +5,7 @@
|
|||
|
||||
Microsoft Consulting Services - AzureCAT - VDC Toolkit (v2.0)
|
||||
|
||||
File: output.test.ps1
|
||||
File: output.tests.ps1
|
||||
|
||||
Purpose: Test - Analysis Services ARM Template Output Variables
|
||||
|
||||
|
@ -32,7 +32,7 @@
|
|||
|
||||
.EXAMPLE
|
||||
Default:
|
||||
C:\PS>.\output.test.ps1
|
||||
C:\PS>.\output.tests.ps1
|
||||
-analysisServicesName "$(analysisServicesName)"
|
||||
-analysisServicesResourceId "$(analysisServicesResourceId)"
|
||||
-analysisServicesResourceGroup "$(analysisServicesResourceGroup)"
|
|
@ -12,7 +12,7 @@
|
|||
"type": "string",
|
||||
"defaultValue": "[resourceGroup().location]",
|
||||
"metadata": {
|
||||
"description": "Optional. Location of the Azure Analysis Services server"
|
||||
"description": "Optional. Location for all Resources"
|
||||
}
|
||||
},
|
||||
"skuName": {
|
||||
|
@ -44,7 +44,7 @@
|
|||
"metadata": {
|
||||
"description": "Optional. The inbound firewall rules to define on the server. If not specified, firewall is disabled"
|
||||
}
|
||||
},
|
||||
},
|
||||
"diagnosticStorageAccountId": {
|
||||
"type": "string",
|
||||
"metadata": {
|
||||
|
@ -73,45 +73,18 @@
|
|||
"description": "Optional. Customer Usage Attribution id (GUID). This GUID must be previously registered"
|
||||
}
|
||||
},
|
||||
"tagEnvironment": {
|
||||
"type": "string",
|
||||
"tagValues": {
|
||||
"type": "object",
|
||||
"defaultValue": "",
|
||||
"metadata": {
|
||||
"description": "Optional. The name of the Environment"
|
||||
}
|
||||
},
|
||||
"tagProject": {
|
||||
"type": "string",
|
||||
"defaultValue": "",
|
||||
"metadata": {
|
||||
"description": "Optional. The name of the project"
|
||||
}
|
||||
},
|
||||
"tagApplication": {
|
||||
"type": "string",
|
||||
"defaultValue": "",
|
||||
"metadata": {
|
||||
"description": "Optional. The name of the application"
|
||||
}
|
||||
},
|
||||
"tagOwner": {
|
||||
"type": "string",
|
||||
"defaultValue": "",
|
||||
"metadata": {
|
||||
"description": "Optional. The business owner for the application"
|
||||
}
|
||||
},
|
||||
"tagOwnerEmail": {
|
||||
"type": "string",
|
||||
"defaultValue": "",
|
||||
"metadata": {
|
||||
"description": "Optional. The Email address of the business owner for the application"
|
||||
"description": "Optional. Azure Resource Tags object"
|
||||
}
|
||||
}
|
||||
},
|
||||
"variables": {
|
||||
"analysisServicesName": "[parameters('serverName')]",
|
||||
"analysisServicesResourceId": "[resourceId('Microsoft.AnalysisServices/servers',parameters('serverName'))]",
|
||||
"analysisServicesApiVersion": "2017-08-01",
|
||||
"diagnosticStorageAccountId": "[parameters('diagnosticStorageAccountId')]",
|
||||
"diagnosticWorkspaceId": "[parameters('logAnalyticsWorkspaceId')]",
|
||||
"pidName": "[concat('pid-', parameters('cuaId'))]"
|
||||
|
@ -133,16 +106,10 @@
|
|||
},
|
||||
{
|
||||
"type": "Microsoft.AnalysisServices/servers",
|
||||
"apiVersion": "[providers('Microsoft.AnalysisServices','servers').apiVersions[0]]",
|
||||
"name": "[parameters('serverName')]",
|
||||
"apiVersion": "[variables('analysisServicesApiVersion')]",
|
||||
"name": "[variables('analysisServicesName')]",
|
||||
"location": "[parameters('location')]",
|
||||
"tags": {
|
||||
"Environment": "[parameters('tagEnvironment')]",
|
||||
"Application": "[parameters('tagApplication')]",
|
||||
"Project": "[parameters('tagProject')]",
|
||||
"Owner": "[parameters('tagOwner')]",
|
||||
"OwnerEmail": "[parameters('tagOwnerEmail')]"
|
||||
},
|
||||
"tags": "[if(empty(parameters('tagValues')), json('null'), parameters('tagValues'))]",
|
||||
"sku": {
|
||||
"name": "[parameters('skuName')]",
|
||||
"capacity": "[parameters('skuCapacity')]"
|
||||
|
@ -153,11 +120,11 @@
|
|||
"resources": [
|
||||
{
|
||||
"type": "Microsoft.AnalysisServices/servers/providers/diagnosticsettings",
|
||||
"name": "[concat(parameters('serverName'), '/Microsoft.Insights/service')]",
|
||||
"apiVersion": "2017-05-01-preview",
|
||||
"name": "[concat(variables('analysisServicesName'), '/', 'Microsoft.Insights/service')]",
|
||||
"location": "[parameters('location')]",
|
||||
"dependsOn": [
|
||||
"[concat('Microsoft.AnalysisServices/servers/', parameters('serverName'))]"
|
||||
"[variables('analysisServicesResourceId')]"
|
||||
],
|
||||
"properties": {
|
||||
"storageAccountId": "[variables('diagnosticStorageAccountId')]",
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
# Analysis Services
|
||||
|
||||
This module deploys Analysis Services.
|
||||
# Analysis Services
|
||||
|
||||
This module deploys Analysis Services.
|
||||
|
||||
## Resources
|
||||
|
||||
|
@ -10,26 +9,20 @@ The following Resources are deployed.
|
|||
+ **Microsoft.AnalysisServices/servers**
|
||||
+ **Microsoft.AnalysisServices/servers/providers/diagnosticsettings**
|
||||
|
||||
|
||||
## Parameters
|
||||
|
||||
| Parameter Name | Default Value | Description |
|
||||
| :- | :- | :- |
|
||||
| `serverName` || **Required** The name of the Azure Analysis Services server to create
|
||||
| `Location` || **Optional** Location of the Azure Analysis Services server.
|
||||
| `skuName` | S0 | **Optional** The sku name of the Azure Analysis Services server to create.
|
||||
| `skuCapacity` | 1 | **Optional** The total number of query replica scale-out instances
|
||||
| `firewallSettings` | AllowFromAll | **Optional** The inbound firewall rules to define on the server. If not specified, firewall is disabled
|
||||
| `diagnosticStorageAccountId` || **Required** Resource identifier of the Diagnostic Storage Account
|
||||
| `logAnalyticsWorkspaceId` || **Required** Resource identifier of Log Analytics Workspace
|
||||
| `logsRetentionInDays` | 30 |**Optional** Specifies the number of days that logs will be kept for, a value of 0 will retain data indefinitely
|
||||
| `cuaId` || **Optional** Customer Usage Attribution Id (GUID). This GUID must be previously registered
|
||||
| `tagEnvironment` || **Optional** The name of the Environment
|
||||
| `tagProject` || **Optional** The name of the project
|
||||
| `tagApplication` || **Optional** The name of the application
|
||||
| `tagOwner` || **Optional** The business owner for the application
|
||||
| `tagOwnerEmail` || **Optional** The Email address of the business owner for the application
|
||||
|
||||
| Parameter Name | Default Value | Required | Description |
|
||||
| :- | :- | :- |:- |
|
||||
| `serverName` || **Required** | The name of the Azure Analysis Services server to create
|
||||
| `location` || **Optional** | Location for all Resources
|
||||
| `skuName` | S0 | **Optional** | The sku name of the Azure Analysis Services server to create
|
||||
| `skuCapacity` | 1 | **Optional** | The total number of query replica scale-out instances
|
||||
| `firewallSettings` | AllowFromAll | **Optional** | The inbound firewall rules to define on the server. If not specified, firewall is disabled
|
||||
| `diagnosticStorageAccountId` || **Required** | Resource identifier of the Diagnostic Storage Account
|
||||
| `logAnalyticsWorkspaceId` || **Required** | Resource identifier of Log Analytics Workspace
|
||||
| `logsRetentionInDays` | 30 |**Optional** | Specifies the number of days that logs will be kept for, a value of 0 will retain data indefinitely
|
||||
| `cuaId` || **Optional** | Customer Usage Attribution Id (GUID). This GUID must be previously registered
|
||||
| `tagValues` || **Optional** | Optional. Azure Resource Tags object
|
||||
|
||||
## Outputs
|
||||
|
||||
|
@ -39,17 +32,16 @@ The following Resources are deployed.
|
|||
| `analysisServicesResourceId` | Analysis Services ResourceId output parameter
|
||||
| `analysisServicesResourceGroup` | Analysis Services ResourceGroup output parameter
|
||||
|
||||
|
||||
## Scripts
|
||||
|
||||
+ There is no Scripts for this Module
|
||||
|
||||
+ There is no deployment considerations for this Module.
|
||||
|
||||
## Considerations
|
||||
|
||||
+ There is no deployment considerations for this Module
|
||||
|
||||
|
||||
## Additional resources
|
||||
|
||||
[Microsoft Analysis Services template reference](https://docs.microsoft.com/en-us/azure/templates/microsoft.analysisservices/allversions)
|
||||
+ [Microsoft Analysis Services template reference](https://docs.microsoft.com/en-us/azure/templates/microsoft.analysisservices/allversions)
|
||||
+ [Microsoft Analysis Services diagnostic settings reference](https://azure.microsoft.com/en-us/blog/azure-analysis-services-integration-with-azure-diagnostic-logs/)
|
||||
|
||||
|
|
|
@ -0,0 +1,35 @@
|
|||
name: $(Build.DefinitionName)-$(SourceBranchName)-$(Date:yyyyMMdd).$(Rev:rr)
|
||||
|
||||
variables:
|
||||
ModuleName: ApplicationInsights
|
||||
ModuleVersion: 2.0
|
||||
RepoName: azure-devops
|
||||
ModulePath: modules/$(ModuleName)/$(ModuleVersion)
|
||||
ArtifactName: contents
|
||||
|
||||
resources:
|
||||
repositories:
|
||||
- repository: main
|
||||
type: git
|
||||
name: '$(RepoName)'
|
||||
|
||||
trigger:
|
||||
branches:
|
||||
include:
|
||||
- master
|
||||
- '*'
|
||||
paths:
|
||||
include:
|
||||
- modules/ApplicationInsights/2.0
|
||||
|
||||
jobs:
|
||||
- job: BuildModule
|
||||
displayName: Build Module
|
||||
workspace:
|
||||
clean: all
|
||||
|
||||
steps:
|
||||
- template: /azure-devops/ci/buildmodule.yaml
|
||||
parameters:
|
||||
ModulePath: $(ModulePath)
|
||||
ArtifactName: $(ArtifactName)
|
|
@ -0,0 +1,128 @@
|
|||
<#
|
||||
.NOTES
|
||||
==============================================================================================
|
||||
Copyright(c) Microsoft Corporation. All rights reserved.
|
||||
|
||||
Microsoft Consulting Services - AzureCAT - VDC Toolkit (v2.0)
|
||||
|
||||
File: application.insights.continuous.export.ps1
|
||||
|
||||
Purpose: Deploys Application Insights Continuous Export Configuration
|
||||
|
||||
Version: 2.0.0.0 - 1st September 2019 - Azure Virtual Datacenter Development Team
|
||||
==============================================================================================
|
||||
|
||||
.SYNOPSIS
|
||||
This script Deploys Application Insights Continuous Export Configuration
|
||||
|
||||
.DESCRIPTION
|
||||
This script Deploys Application Insights Continuous Export Configuration
|
||||
|
||||
Deployment steps of the script are outlined below.
|
||||
1) Azure Parameter Configuration
|
||||
2) Configure Application Insights Continuous Export
|
||||
|
||||
.PARAMETER appInsightsName
|
||||
Specify the Azure Application Insights Name parameter.
|
||||
|
||||
.PARAMETER storageAccountName
|
||||
Specify the Storage Account Name parameter.
|
||||
|
||||
.EXAMPLE
|
||||
Default:
|
||||
C:\PS>.\application.insights.continuous.export.ps1
|
||||
-appInsightsName "$(appInsightsName)"
|
||||
-storageAccountName "$(storageAccountName)"
|
||||
#>
|
||||
|
||||
|
||||
#Requires -Version 5
|
||||
#Requires -Module Az.ApplicationInsights
|
||||
#Requires -Module Az.Storage
|
||||
#Requires -Module Az.Resources
|
||||
|
||||
[CmdletBinding()]
|
||||
param
|
||||
(
|
||||
[Parameter(Mandatory = $true)]
|
||||
[string]$appInsightsName,
|
||||
|
||||
[Parameter(Mandatory = $true)]
|
||||
[string]$storageAccountName
|
||||
)
|
||||
|
||||
#region - Application Insights Continuous Export Configuration
|
||||
Write-Output "Application Insights Name: $appInsightsName"
|
||||
Write-Output "Storage Account Name: $storageAccountName"
|
||||
|
||||
$paramGetAzResource = @{
|
||||
ResourceType = "Microsoft.Insights/components"
|
||||
ResourceName = $appInsightsName
|
||||
}
|
||||
$resource = Get-AzResource @paramGetAzResource
|
||||
$resourceGroup = $resource.ResourceGroupName
|
||||
|
||||
$paramGetAzApplicationInsightsContinuousExport = @{
|
||||
ResourceGroupName = $resourceGroup
|
||||
Name = $appInsightsName
|
||||
}
|
||||
$continuousExport = Get-AzApplicationInsightsContinuousExport @paramGetAzApplicationInsightsContinuousExport
|
||||
|
||||
if (-not ($continuousExport))
|
||||
{
|
||||
$paramGetAzResource = @{
|
||||
ResourceType = "Microsoft.Storage/storageAccounts"
|
||||
ResourceName = $storageAccountName
|
||||
}
|
||||
$resource = Get-AzResource @paramGetAzResource
|
||||
|
||||
$paramGetAzResource = @{
|
||||
ResourceId = $resource.Id
|
||||
}
|
||||
$resource = Get-AzResource @paramGetAzResource
|
||||
|
||||
$paramInvokeAzResourceAction = @{
|
||||
Action = 'listkeys'
|
||||
ResourceId = $resource.ResourceId
|
||||
Force = $true
|
||||
}
|
||||
$storagekey = (Invoke-AzResourceAction @paramInvokeAzResourceAction).keys[0].value
|
||||
|
||||
$paramNewAzStorageContext = @{
|
||||
StorageAccountName = $storageAccountName
|
||||
StorageAccountKey = $storagekey
|
||||
}
|
||||
$context = New-AzStorageContext @paramNewAzStorageContext
|
||||
|
||||
$paramNewAzStorageContainer = @{
|
||||
Name = "appinsights"
|
||||
Context = $context
|
||||
Permission = 'Off'
|
||||
}
|
||||
New-AzStorageContainer @paramNewAzStorageContainer
|
||||
|
||||
$paramNewAzStorageContainerSASToken = @{
|
||||
Name = "appinsights"
|
||||
Context = $context
|
||||
ExpiryTime = (Get-Date).AddYears(50)
|
||||
Permission = 'w'
|
||||
}
|
||||
$sasToken = New-AzStorageContainerSASToken @paramNewAzStorageContainerSASToken
|
||||
$sasURI = $resource.Properties.primaryEndpoints.blob + "appinsights" + $sasToken
|
||||
|
||||
$paramNewAzApplicationInsightsContinuousExport = @{
|
||||
ResourceGroupName = $ResourceGroup
|
||||
Name = $appInsightsName
|
||||
DocumentType = "Request", "Exception", "Custom Event", "Metric", "Page Load", "Page View", "Dependency", "Availability", "Performance Counter"
|
||||
StorageAccountId = $resource.ResourceId
|
||||
StorageLocation = $resource.Properties.primaryLocation
|
||||
StorageSASUri = $sasURI
|
||||
ErrorAction = 'Stop'
|
||||
}
|
||||
New-AzApplicationInsightsContinuousExport @paramNewAzApplicationInsightsContinuousExport
|
||||
}
|
||||
else
|
||||
{
|
||||
Write-Output "Skipping - Existing Application Insights Continuous Export Configuration Found"
|
||||
}
|
||||
#endregion
|
|
@ -1,123 +0,0 @@
|
|||
<#
|
||||
.NOTES
|
||||
==============================================================================================
|
||||
Copyright(c) Microsoft Corporation. All rights reserved.
|
||||
|
||||
File: application.insights.continuousexport.ps1
|
||||
|
||||
Purpose: Deploys Application Insights Continuous Export Configuration
|
||||
|
||||
Version: 1.0.0.0 - 1st April 2019 - Azure Virtual Datacenter Development Team
|
||||
==============================================================================================
|
||||
|
||||
.SYNOPSIS
|
||||
This script Deploys Application Insights Continuous Export Configuration
|
||||
|
||||
.DESCRIPTION
|
||||
This script Deploys Application Insights Continuous Export Configuration
|
||||
|
||||
Deployment steps of the script are outlined below.
|
||||
1) Azure Parameter Configuration
|
||||
2) Configure Application Insights Continuous Export
|
||||
|
||||
.PARAMETER AppInsightName
|
||||
Specify the Azure Application Insights Name parameter.
|
||||
|
||||
.PARAMETER StorageAccountName
|
||||
Specify the Storage Account Name parameter.
|
||||
|
||||
.EXAMPLE
|
||||
Default:
|
||||
C:\PS>.\application.insights.continuousexport.ps1 `
|
||||
-AppInsightName <"AppInsightName"> `
|
||||
-StorageAccountName <"StorageAccountName"> `
|
||||
#>
|
||||
|
||||
#Requires -Version 5
|
||||
#Requires -Module AzureRM.ApplicationInsights
|
||||
|
||||
[CmdletBinding()]
|
||||
param
|
||||
(
|
||||
[Parameter(Mandatory = $false)]
|
||||
[string]$AppInsightName,
|
||||
|
||||
[Parameter(Mandatory = $false)]
|
||||
[string]$StorageAccountName
|
||||
)
|
||||
|
||||
#region - Application Insights Continuous Export Configuration
|
||||
Write-Output "Application Insights Name: $AppInsightName"
|
||||
Write-Output "Storage Account Name: $StorageAccountName"
|
||||
|
||||
$Parameters = @{
|
||||
ResourceType = "Microsoft.Insights/components"
|
||||
ResourceName = $AppInsightName
|
||||
}
|
||||
$resource = Get-AzureRmResource @Parameters
|
||||
|
||||
$ResourceGroup = $resource.ResourceGroupName
|
||||
|
||||
$paramGetAzureRmApplicationInsightsContinuousExport = @{
|
||||
ResourceGroupName = $ResourceGroup
|
||||
Name = $AppInsightName
|
||||
}
|
||||
$ContinuousExport = Get-AzureRmApplicationInsightsContinuousExport @paramGetAzureRmApplicationInsightsContinuousExport
|
||||
|
||||
if ($ContinuousExport -ne $null)
|
||||
{
|
||||
Write-Output "Existing Application Insights Continuous Export Configuration - Skipping"
|
||||
}
|
||||
else
|
||||
{
|
||||
$Parameters = @{
|
||||
ResourceType = "Microsoft.Storage/storageAccounts"
|
||||
ResourceName = $StorageAccountName
|
||||
}
|
||||
$resource = Get-AzureRmResource @Parameters
|
||||
|
||||
$Parameters = @{
|
||||
ResourceId = $resource.Id
|
||||
}
|
||||
$resource = Get-AzureRmResource @Parameters
|
||||
|
||||
$Parameters = @{
|
||||
Action = 'listkeys'
|
||||
ResourceId = $resource.ResourceId
|
||||
}
|
||||
$Storagekey = (Invoke-AzureRmResourceAction @Parameters -Force).keys[0].value
|
||||
|
||||
$paramNewAzureStorageContext =@{
|
||||
StorageAccountName = $StorageAccountName
|
||||
StorageAccountKey = $Storagekey
|
||||
}
|
||||
$context = New-AzureStorageContext @paramNewAzureStorageContext
|
||||
|
||||
$paramNewAzureStorageContainer = @{
|
||||
Name = "appinsights"
|
||||
Context = $context
|
||||
Permission = 'Off'
|
||||
}
|
||||
New-AzureStorageContainer @paramNewAzureStorageContainer
|
||||
|
||||
$paramNewAzureStorageContainerSASToken = @{
|
||||
Name = "appinsights"
|
||||
Context = $context
|
||||
ExpiryTime = (Get-Date).AddYears(50)
|
||||
Permission = 'w'
|
||||
}
|
||||
$sastoken = New-AzureStorageContainerSASToken @paramNewAzureStorageContainerSASToken
|
||||
$sasuri = $resource.Properties.primaryEndpoints.blob + "appinsights" + $sastoken
|
||||
|
||||
$paramNewAzureRmApplicationInsightsContinuousExport = @{
|
||||
ResourceGroupName = $ResourceGroup
|
||||
Name = $AppInsightName
|
||||
DocumentType = "Request","Exception","Custom Event","Metric","Page Load","Page View","Dependency","Availability","Performance Counter"
|
||||
StorageAccountId = $resource.ResourceId
|
||||
StorageLocation = $resource.Properties.primaryLocation
|
||||
StorageSASUri = $sasuri
|
||||
ErrorAction = 'Stop'
|
||||
}
|
||||
New-AzureRmApplicationInsightsContinuousExport @paramNewAzureRmApplicationInsightsContinuousExport
|
||||
}
|
||||
#endregion
|
|
@ -0,0 +1,171 @@
|
|||
<#
|
||||
.NOTES
|
||||
==============================================================================================
|
||||
Copyright(c) Microsoft Corporation. All rights reserved.
|
||||
|
||||
Microsoft Consulting Services - AzureCAT - VDC Toolkit (v2.0)
|
||||
|
||||
File: module.tests.ps1
|
||||
|
||||
Purpose: Pester - Test Application Insights ARM Templates
|
||||
|
||||
Version: 2.0.0.0 - 1st August 2019 - Azure Virtual Datacenter Development Team
|
||||
==============================================================================================
|
||||
|
||||
.SYNOPSIS
|
||||
This script contains functionality used to test Application Insights ARM template synatax.
|
||||
|
||||
.DESCRIPTION
|
||||
This script contains functionality used to test Application Insights ARM template synatax.
|
||||
|
||||
Deployment steps of the script are outlined below.
|
||||
1) Test Template File Syntax
|
||||
2) Test Parameter File Syntax
|
||||
3) Test Template and Parameter File Compactibility
|
||||
#>
|
||||
|
||||
#Requires -Version 5
|
||||
|
||||
#region Parameters
|
||||
$here = Split-Path -Parent $MyInvocation.MyCommand.Path
|
||||
$here = Join-Path -Path $here -ChildPath ".."
|
||||
$template = Split-Path -Leaf $here
|
||||
|
||||
#region - Template File Test Cases
|
||||
$templateFileTestCases = @()
|
||||
ForEach ($file in (Get-ChildItem (Join-Path -Path "$here" -ChildPath "deploy.json") -Recurse | Select-Object -ExpandProperty Name)) {
|
||||
$templateFileTestCases += @{ TemplateFile = $file }
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region - Parameter File Test Cases
|
||||
$parameterFileTestCases = @()
|
||||
ForEach ($file in (Get-ChildItem (Join-Path -Path "$here" -ChildPath "Tests" -AdditionalChildPath @("*parameters.json")) -Recurse -ErrorAction SilentlyContinue | Select-Object -ExpandProperty Name)) {
|
||||
$parameterFileTestCases += @{ ParameterFile = Join-Path -Path "Tests" $file }
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region - Module Test Cases
|
||||
$modules = @()
|
||||
ForEach ($file in (Get-ChildItem (Join-Path -Path "$here" -ChildPath "deploy.json"))) {
|
||||
$module = [PSCustomObject]@{
|
||||
'Template' = $null
|
||||
'Parameters' = $null
|
||||
}
|
||||
$module.Template = $file.FullName
|
||||
|
||||
$parameters = @()
|
||||
ForEach ($parameterFile in (Get-ChildItem (Join-Path -Path "$here" -ChildPath "Tests" -AdditionalChildPath @("*parameters.json")) -Recurse -ErrorAction SilentlyContinue | Select-Object -ExpandProperty Name)) {
|
||||
$parameters += (Join-Path -Path "$here" -ChildPath "Tests" -AdditionalChildPath @("$ParameterFile"))
|
||||
}
|
||||
$Module.Parameters = $Parameters
|
||||
$Modules += @{Module = $Module}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
#region - Run Pester Test Script
|
||||
Describe "Template: $template - API Management Service" -Tags -Unit {
|
||||
|
||||
#region - Template File Syntax
|
||||
Context "Template File Syntax" {
|
||||
|
||||
It "Has a JSON template file" {
|
||||
(Join-Path -Path "$here" -ChildPath "deploy.json") | Should -Exist
|
||||
}
|
||||
|
||||
It "Converts from JSON and has the expected properties" -TestCases $templateFileTestCases {
|
||||
param($templateFile)
|
||||
$expectedProperties = '$schema',
|
||||
'contentVersion',
|
||||
'parameters',
|
||||
'variables',
|
||||
'resources',
|
||||
'outputs' | Sort-Object
|
||||
$templateProperties = (Get-Content (Join-Path -Path "$here" -ChildPath "$templateFile") `
|
||||
| ConvertFrom-Json -ErrorAction SilentlyContinue) `
|
||||
| Get-Member -MemberType NoteProperty `
|
||||
| Sort-Object -Property Name `
|
||||
| ForEach-Object Name
|
||||
$templateProperties | Should -Be $expectedProperties
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region - Parameter File Syntax
|
||||
Context "Parameter File Syntax" {
|
||||
|
||||
It "Parameter file does not contains the expected properties" -TestCases $parameterFileTestCases {
|
||||
param($parameterFile)
|
||||
$expectedProperties = '$schema',
|
||||
'contentVersion',
|
||||
'parameters' | Sort-Object
|
||||
Write-Output $parameterFile
|
||||
Join-Path -Path "$here" -ChildPath "$parameterFile" | Write-Output
|
||||
$templateFileProperties = (Get-Content (Join-Path -Path "$here" -ChildPath "$parameterFile") `
|
||||
| ConvertFrom-Json -ErrorAction SilentlyContinue) `
|
||||
| Get-Member -MemberType NoteProperty `
|
||||
| Sort-Object -Property Name `
|
||||
| ForEach-Object Name
|
||||
$templateFileProperties | Should -Be $expectedProperties
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region - Template and Parameter Compactibility
|
||||
Context "Template and Parameter Compactibility" {
|
||||
|
||||
It "Is count of required parameters in template file equal or lesser than count of all parameters in parameters file" -TestCases $modules {
|
||||
param($module)
|
||||
$requiredParametersInTemplateFile = (Get-Content "$($module.Template)" `
|
||||
| ConvertFrom-Json -ErrorAction SilentlyContinue).Parameters.PSObject.Properties `
|
||||
| Where-Object -FilterScript { -not ($psitem.Value.PSObject.Properties.Name -eq "defaultValue")} `
|
||||
| Sort-Object -Property Name `
|
||||
| ForEach-Object Name
|
||||
ForEach ( $parameter in $module.Parameters ) {
|
||||
$allParametersInParametersFile = (Get-Content $parameter `
|
||||
| ConvertFrom-Json -ErrorAction SilentlyContinue).Parameters.PSObject.Properties `
|
||||
| Sort-Object -Property Name `
|
||||
| ForEach-Object Name
|
||||
$requiredParametersInTemplateFile.Count | Should -Not -BeGreaterThan $allParametersInParametersFile.Count
|
||||
}
|
||||
}
|
||||
|
||||
It "Has all parameters in parameters file existing in template file" -TestCases $modules {
|
||||
param($module)
|
||||
$allParametersInTemplateFile = (Get-Content "$($module.Template)" `
|
||||
| ConvertFrom-Json -ErrorAction SilentlyContinue).Parameters.PSObject.Properties `
|
||||
| Sort-Object -Property Name `
|
||||
| ForEach-Object Name
|
||||
ForEach ($parameter in $module.Parameters) {
|
||||
Write-Output "File analyzed: $parameter"
|
||||
$allParametersInParametersFile = (Get-Content $parameter `
|
||||
| ConvertFrom-Json -ErrorAction SilentlyContinue).Parameters.PSObject.Properties `
|
||||
| Sort-Object -Property Name `
|
||||
| ForEach-Object Name
|
||||
$result = @($allParametersInParametersFile| Where-Object {$allParametersInTemplateFile -notcontains $psitem})
|
||||
Write-Output "Invalid parameters: $(ConvertTo-Json $result)"
|
||||
@($allParametersInParametersFile| Where-Object {$allParametersInTemplateFile -notcontains $psitem}).Count | Should -Be 0
|
||||
}
|
||||
}
|
||||
|
||||
It "Has required parameters in template file existing in parameters file" -TestCases $modules {
|
||||
param($module)
|
||||
$requiredParametersInTemplateFile = (Get-Content "$($module.Template)" `
|
||||
| ConvertFrom-Json -ErrorAction SilentlyContinue).Parameters.PSObject.Properties `
|
||||
| Where-Object -FilterScript { -not ($psitem.Value.PSObject.Properties.Name -eq "defaultValue") } `
|
||||
| Sort-Object -Property Name `
|
||||
| ForEach-Object Name
|
||||
ForEach ($parameter in $module.Parameters ) {
|
||||
$allParametersInParametersFile = (Get-Content $parameter `
|
||||
| ConvertFrom-Json -ErrorAction SilentlyContinue).Parameters.PSObject.Properties `
|
||||
| Sort-Object -Property Name `
|
||||
| ForEach-Object Name
|
||||
@($requiredParametersInTemplateFile| Where-Object {$allParametersInParametersFile -notcontains $psitem}).Count | Should -Be 0
|
||||
}
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
#endregion
|
|
@ -0,0 +1,116 @@
|
|||
<#
|
||||
.NOTES
|
||||
==============================================================================================
|
||||
Copyright(c) Microsoft Corporation. All rights reserved.
|
||||
|
||||
Microsoft Consulting Services - AzureCAT - VDC Toolkit (v2.0)
|
||||
|
||||
File: output.tests.ps1
|
||||
|
||||
Purpose: Test - Application Insights ARM Template Output Variables
|
||||
|
||||
Version: 2.0.0.0 - 1st September 2019 - Azure Virtual Datacenter Development Team
|
||||
==============================================================================================
|
||||
|
||||
.SYNOPSIS
|
||||
This script contains functionality used to test Application Insights ARM Template Output Variables.
|
||||
|
||||
.DESCRIPTION
|
||||
This script contains functionality used to test Application Insights ARM Template Output Variables.
|
||||
|
||||
Deployment steps of the script are outlined below.
|
||||
1) Outputs Variable Logic from pipeline
|
||||
|
||||
.PARAMETER appInsightsName
|
||||
Specify the Application Insights Name output parameter.
|
||||
|
||||
.PARAMETER appInsightsResourceId
|
||||
Specify the Application Insights Resource Id output parameter.
|
||||
|
||||
.PARAMETER appInsightsResourceGroup
|
||||
Specify the Application Insights ResourceGroup output parameter.
|
||||
|
||||
.PARAMETER appInsightsKey
|
||||
Specify the Application Insights Instrumentation Key output parameter.
|
||||
|
||||
.PARAMETER appInsightsAppId
|
||||
Specify the Application Insights AppId output parameter.
|
||||
|
||||
.EXAMPLE
|
||||
Default:
|
||||
C:\PS>.\output.tests.ps1
|
||||
-appInsightsName "$(appInsightsName)"
|
||||
-appInsightsResourceId "$(appInsightsResourceId)"
|
||||
-appInsightsResourceGroup "$(appInsightsResourceGroup)"
|
||||
-appInsightsKey "$(appInsightsKey)"
|
||||
-appInsightsAppId "$(appInsightsAppId)"
|
||||
#>
|
||||
|
||||
#Requires -Version 5
|
||||
|
||||
[CmdletBinding()]
|
||||
param
|
||||
(
|
||||
[Parameter(Mandatory = $false)]
|
||||
[string]$appInsightsName,
|
||||
|
||||
[Parameter(Mandatory = $false)]
|
||||
[string]$appInsightsResourceId,
|
||||
|
||||
[Parameter(Mandatory = $false)]
|
||||
[string]$appInsightsResourceGroup,
|
||||
|
||||
[Parameter(Mandatory = $false)]
|
||||
[string]$appInsightsKey,
|
||||
|
||||
[Parameter(Mandatory = $false)]
|
||||
[string]$appInsightsAppId
|
||||
)
|
||||
|
||||
#region - Application Insights Output Tests
|
||||
|
||||
if (-not [string]::IsNullOrWhiteSpace($PSBoundParameters['appInsightsName']))
|
||||
{
|
||||
Write-Output "Application Insights Name: $($appInsightsName)"
|
||||
}
|
||||
else
|
||||
{
|
||||
Write-Output "Application Insights Name: []"
|
||||
}
|
||||
|
||||
if (-not [string]::IsNullOrWhiteSpace($PSBoundParameters['appInsightsResourceId']))
|
||||
{
|
||||
Write-Output "Application Insights ResourceId: $($appInsightsResourceId)"
|
||||
}
|
||||
else
|
||||
{
|
||||
Write-Output "Application Insights Resource Id: []"
|
||||
}
|
||||
|
||||
if (-not [string]::IsNullOrWhiteSpace($PSBoundParameters['appInsightsResourceGroup']))
|
||||
{
|
||||
Write-Output "Application Insights ResourceGroup: $($appInsightsResourceGroup)"
|
||||
}
|
||||
else
|
||||
{
|
||||
Write-Output "Application Insights ResourceGroup: []"
|
||||
}
|
||||
|
||||
if (-not [string]::IsNullOrWhiteSpace($PSBoundParameters['appInsightsKey']))
|
||||
{
|
||||
Write-Output "Application Insights Instrumentation Key: $($appInsightsKey)"
|
||||
}
|
||||
else
|
||||
{
|
||||
Write-Output "Application Insights Instrumentation Key: []"
|
||||
}
|
||||
|
||||
if (-not [string]::IsNullOrWhiteSpace($PSBoundParameters['appInsightsAppId']))
|
||||
{
|
||||
Write-Output "Application Insights AppId: $($appInsightsAppId)"
|
||||
}
|
||||
else
|
||||
{
|
||||
Write-Output "Application Insights AppId: []"
|
||||
}
|
||||
#endregion
|
|
@ -2,5 +2,11 @@
|
|||
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentParameters.json#",
|
||||
"contentVersion": "1.0.0.0",
|
||||
"parameters": {
|
||||
"appInsightsName": {
|
||||
"value": "testappInsightsName"
|
||||
},
|
||||
"cuaId": {
|
||||
"value": "00000000-0000-0000-0000-000000000000"
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,9 +0,0 @@
|
|||
# Application Insights
|
||||
|
||||
This module deploys Application Insights.
|
||||
|
||||
## Deployed Resources
|
||||
|
||||
The following resources are deployed as part of this code block.
|
||||
|
||||
+ **Application Insights** : Diagnostic Settings
|
|
@ -1,103 +0,0 @@
|
|||
{
|
||||
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
|
||||
"contentVersion": "1.0.0.0",
|
||||
"parameters": {
|
||||
"appInsName": {
|
||||
"type": "string",
|
||||
"metadata": {
|
||||
"description": "Name of the Application Insights"
|
||||
}
|
||||
},
|
||||
"appType": {
|
||||
"type": "string",
|
||||
"allowedValues": [
|
||||
"web",
|
||||
"java",
|
||||
"other"
|
||||
],
|
||||
"defaultValue": "web",
|
||||
"metadata": {
|
||||
"description": "Enter the application type."
|
||||
}
|
||||
},
|
||||
"location": {
|
||||
"type": "string",
|
||||
"defaultValue": "[resourceGroup().location]",
|
||||
"metadata": {
|
||||
"description": "Location for resource"
|
||||
}
|
||||
},
|
||||
"storageAccountName": {
|
||||
"type": "string",
|
||||
"metadata": {
|
||||
"description": "SpecifyStorage Account Name"
|
||||
}
|
||||
},
|
||||
"storageAccountType": {
|
||||
"type": "string",
|
||||
"allowedValues": [
|
||||
"Standard_LRS",
|
||||
"Standard_GRS",
|
||||
"Standard_ZRS",
|
||||
"Premium_LRS"
|
||||
],
|
||||
"defaultValue": "Standard_GRS",
|
||||
"metadata": {
|
||||
"description": "Storage Account type"
|
||||
}
|
||||
}
|
||||
},
|
||||
"variables": {
|
||||
"appInsightsName": "[parameters('appInsName')]",
|
||||
"resourceId": "[resourceId('Microsoft.Insights/components', parameters('appInsName'))]",
|
||||
"apiVersion": "[providers('Microsoft.Insights', 'components').apiVersions[0]]",
|
||||
"StorageAccountName": "[parameters('storageAccountName')]"
|
||||
},
|
||||
"resources": [
|
||||
{
|
||||
"type": "Microsoft.Insights/components",
|
||||
"apiVersion": "2015-05-01",
|
||||
"name": "[parameters('appInsName')]",
|
||||
"location": "[parameters('location')]",
|
||||
"tags": {},
|
||||
"properties": {
|
||||
"ApplicationId": "[parameters('appInsName')]",
|
||||
"Application_Type": "[parameters('appType')]"
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "Microsoft.Storage/storageAccounts",
|
||||
"apiVersion": "2018-02-01",
|
||||
"name": "[parameters('storageAccountName')]",
|
||||
"location": "[resourceGroup().location]",
|
||||
"sku": {
|
||||
"name": "[parameters('storageAccountType')]"
|
||||
},
|
||||
"kind": "Storage",
|
||||
"properties": {
|
||||
"supportsHttpsTrafficOnly": true
|
||||
},
|
||||
"tags": {
|
||||
"displayName": "Storage Account"
|
||||
}
|
||||
}
|
||||
],
|
||||
"outputs": {
|
||||
"AppInsightName": {
|
||||
"type": "string",
|
||||
"value": "[variables('appInsightsName')]"
|
||||
},
|
||||
"AppInsightKey": {
|
||||
"type": "string",
|
||||
"value": "[reference(variables('resourceId'), variables('apiVersion')).instrumentationKey]"
|
||||
},
|
||||
"AppInsightAppId": {
|
||||
"type": "string",
|
||||
"value": "[reference(variables('resourceId'), variables('apiVersion')).AppId]"
|
||||
},
|
||||
"StorageAccountName": {
|
||||
"type": "string",
|
||||
"value": "[variables('StorageAccountName')]"
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,15 +0,0 @@
|
|||
{
|
||||
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentParameters.json#",
|
||||
"contentVersion": "1.0.0.0",
|
||||
"parameters": {
|
||||
"appInsName": {
|
||||
"value": null
|
||||
},
|
||||
"storageAccountName": {
|
||||
"value": null
|
||||
},
|
||||
"storageAccountType": {
|
||||
"value": "Standard_GRS"
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,115 @@
|
|||
{
|
||||
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
|
||||
"contentVersion": "1.0.0.0",
|
||||
"parameters": {
|
||||
"appInsightsName": {
|
||||
"type": "string",
|
||||
"metadata": {
|
||||
"description": "Required. Name of the Application Insights"
|
||||
}
|
||||
},
|
||||
"appInsightsType": {
|
||||
"type": "string",
|
||||
"allowedValues": [
|
||||
"web",
|
||||
"java",
|
||||
"other"
|
||||
],
|
||||
"defaultValue": "web",
|
||||
"metadata": {
|
||||
"description": "Optional. Application type"
|
||||
}
|
||||
},
|
||||
"location": {
|
||||
"type": "string",
|
||||
"defaultValue": "[resourceGroup().location]",
|
||||
"metadata": {
|
||||
"description": "Optional. Location for all Resources"
|
||||
}
|
||||
},
|
||||
"cuaId": {
|
||||
"type": "string",
|
||||
"defaultValue": "",
|
||||
"metadata": {
|
||||
"description": "Optional. Customer Usage Attribution id (GUID). This GUID must be previously registered"
|
||||
}
|
||||
},
|
||||
"tagValues": {
|
||||
"type": "object",
|
||||
"defaultValue": "",
|
||||
"metadata": {
|
||||
"description": "Optional. Azure Resource Tags object"
|
||||
}
|
||||
}
|
||||
},
|
||||
"variables": {
|
||||
"appInsightsName": "[parameters('appInsightsName')]",
|
||||
"appInsightsresourceId": "[resourceId('Microsoft.Insights/components',parameters('appInsightsName'))]",
|
||||
"appInsightsApiVersion": "2015-05-01",
|
||||
"pidName": "[concat('pid-',parameters('cuaId'))]"
|
||||
},
|
||||
"resources": [
|
||||
{
|
||||
"condition": "[not(empty(parameters('cuaId')))]",
|
||||
"type": "Microsoft.Resources/deployments",
|
||||
"apiVersion": "2018-02-01",
|
||||
"name": "[variables('pidName')]",
|
||||
"properties": {
|
||||
"mode": "Incremental",
|
||||
"template": {
|
||||
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
|
||||
"contentVersion": "1.0.0.0",
|
||||
"resources": []
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "Microsoft.Insights/components",
|
||||
"apiVersion": "[variables('appInsightsApiVersion')]",
|
||||
"name": "[variables('appInsightsName')]",
|
||||
"location": "[parameters('location')]",
|
||||
"tags": "[if(empty(parameters('tagValues')), json('null'), parameters('tagValues'))]",
|
||||
"properties": {
|
||||
"ApplicationId": "[parameters('appInsightsName')]",
|
||||
"Application_Type": "[parameters('appInsightsType')]"
|
||||
}
|
||||
}
|
||||
],
|
||||
"outputs": {
|
||||
"appInsightsName": {
|
||||
"type": "string",
|
||||
"value": "[variables('appInsightsName')]",
|
||||
"metadata": {
|
||||
"description": "Application Insights Resource Name"
|
||||
}
|
||||
},
|
||||
"appInsightsResourceId": {
|
||||
"type": "string",
|
||||
"value": "[variables('appInsightsresourceId')]",
|
||||
"metadata": {
|
||||
"description": "Application Insights Resource Id"
|
||||
}
|
||||
},
|
||||
"appInsightsResourceGroup": {
|
||||
"type": "string",
|
||||
"value": "[resourceGroup().name]",
|
||||
"metadata": {
|
||||
"description": "Application Insights ResourceGroup"
|
||||
}
|
||||
},
|
||||
"appInsightsKey": {
|
||||
"type": "string",
|
||||
"value": "[reference(variables('appInsightsresourceId'),variables('appInsightsApiVersion')).instrumentationKey]",
|
||||
"metadata": {
|
||||
"description": "Application Insights Resource Instrumentation Key"
|
||||
}
|
||||
},
|
||||
"appInsightsAppId": {
|
||||
"type": "string",
|
||||
"value": "[reference(variables('appInsightsresourceId'),variables('appInsightsApiVersion')).AppId]",
|
||||
"metadata": {
|
||||
"description": "Application Insights Application Id"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,43 @@
|
|||
# Application Insights
|
||||
|
||||
This module deploys Application Insights.
|
||||
|
||||
## Resources
|
||||
|
||||
The following Resources are deployed.
|
||||
|
||||
+ **Microsoft.Insights/components**
|
||||
|
||||
## Parameters
|
||||
|
||||
| Parameter Name | Default Value | Required | Description |
|
||||
| :- | :- | :- |:- |
|
||||
| `appInsightsName` || **Required** | Name of the Application Insights
|
||||
| `appInsightsType` | web | **Optional** | Application type
|
||||
| `location` | resourceGroup().location | **Optional** | Location for all Resources
|
||||
| `cuaId` || **Optional** | Customer Usage Attribution Id (GUID). This GUID must be previously registered
|
||||
| `tagValues` || **Optional** | Optional. Azure Resource Tags object
|
||||
|
||||
## Outputs
|
||||
|
||||
| Output Name | Description |
|
||||
| :- | :- |
|
||||
| `appInsightsName` | Application Insights Resource Name
|
||||
| `appInsightsResourceId` | Application Insights Resource Id
|
||||
| `appInsightsResourceGroup` | Application Insights ResourceGroup
|
||||
| `appInsightsKey` | Application Insights Resource Instrumentation Key
|
||||
| `appInsightsAppId` | Application Insights Application Id
|
||||
|
||||
## Scripts
|
||||
|
||||
| Output Name | Description |
|
||||
| :- | :- |
|
||||
| `application.insights.continuous.export.ps1` | Configures Application Insights Continuous Export Configuration
|
||||
|
||||
## Considerations
|
||||
|
||||
+ There is no deployment considerations for this Module
|
||||
|
||||
## Additional resources
|
||||
|
||||
+ [Microsoft Insights template reference](https://docs.microsoft.com/en-us/azure/templates/microsoft.insights/allversions)
|
|
@ -0,0 +1,35 @@
|
|||
name: $(Build.DefinitionName)-$(SourceBranchName)-$(Date:yyyyMMdd).$(Rev:rr)
|
||||
|
||||
variables:
|
||||
ModuleName: CognitiveServices
|
||||
ModuleVersion: 2.0
|
||||
RepoName: azure-devops
|
||||
ModulePath: modules/$(ModuleName)/$(ModuleVersion)
|
||||
ArtifactName: contents
|
||||
|
||||
resources:
|
||||
repositories:
|
||||
- repository: main
|
||||
type: git
|
||||
name: '$(RepoName)'
|
||||
|
||||
trigger:
|
||||
branches:
|
||||
include:
|
||||
- master
|
||||
- '*'
|
||||
paths:
|
||||
include:
|
||||
- modules/CognitiveServices/2.0
|
||||
|
||||
jobs:
|
||||
- job: BuildModule
|
||||
displayName: Build Module
|
||||
workspace:
|
||||
clean: all
|
||||
|
||||
steps:
|
||||
- template: /azure-devops/ci/buildmodule.yaml
|
||||
parameters:
|
||||
ModulePath: $(ModulePath)
|
||||
ArtifactName: $(ArtifactName)
|
|
@ -0,0 +1,171 @@
|
|||
<#
|
||||
.NOTES
|
||||
==============================================================================================
|
||||
Copyright(c) Microsoft Corporation. All rights reserved.
|
||||
|
||||
Microsoft Consulting Services - AzureCAT - VDC Toolkit (v2.0)
|
||||
|
||||
File: module.tests.ps1
|
||||
|
||||
Purpose: Pester - Test Cognitive Services ARM Templates
|
||||
|
||||
Version: 2.0.0.0 - 1st September 2019 - Azure Virtual Datacenter Development Team
|
||||
==============================================================================================
|
||||
|
||||
.SYNOPSIS
|
||||
This script contains functionality used to test Cognitive Services ARM template synatax.
|
||||
|
||||
.DESCRIPTION
|
||||
This script contains functionality used to test Cognitive Services ARM template synatax.
|
||||
|
||||
Deployment steps of the script are outlined below.
|
||||
1) Test Template File Syntax
|
||||
2) Test Parameter File Syntax
|
||||
3) Test Template and Parameter File Compactibility
|
||||
#>
|
||||
|
||||
#Requires -Version 5
|
||||
|
||||
#region Parameters
|
||||
$here = Split-Path -Parent $MyInvocation.MyCommand.Path
|
||||
$here = Join-Path -Path $here -ChildPath ".."
|
||||
$template = Split-Path -Leaf $here
|
||||
|
||||
#region - Template File Test Cases
|
||||
$templateFileTestCases = @()
|
||||
ForEach ($file in (Get-ChildItem (Join-Path -Path "$here" -ChildPath "deploy.json") -Recurse | Select-Object -ExpandProperty Name)) {
|
||||
$templateFileTestCases += @{ TemplateFile = $file }
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region - Parameter File Test Cases
|
||||
$parameterFileTestCases = @()
|
||||
ForEach ($file in (Get-ChildItem (Join-Path -Path "$here" -ChildPath "Tests" -AdditionalChildPath @("*parameters.json")) -Recurse -ErrorAction SilentlyContinue | Select-Object -ExpandProperty Name)) {
|
||||
$parameterFileTestCases += @{ ParameterFile = Join-Path -Path "Tests" $file }
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region - Module Test Cases
|
||||
$modules = @()
|
||||
ForEach ($file in (Get-ChildItem (Join-Path -Path "$here" -ChildPath "deploy.json"))) {
|
||||
$module = [PSCustomObject]@{
|
||||
'Template' = $null
|
||||
'Parameters' = $null
|
||||
}
|
||||
$module.Template = $file.FullName
|
||||
|
||||
$parameters = @()
|
||||
ForEach ($parameterFile in (Get-ChildItem (Join-Path -Path "$here" -ChildPath "Tests" -AdditionalChildPath @("*parameters.json")) -Recurse -ErrorAction SilentlyContinue | Select-Object -ExpandProperty Name)) {
|
||||
$parameters += (Join-Path -Path "$here" -ChildPath "Tests" -AdditionalChildPath @("$ParameterFile"))
|
||||
}
|
||||
$Module.Parameters = $Parameters
|
||||
$Modules += @{Module = $Module}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
#region - Run Pester Test Script
|
||||
Describe "Template: $template - Cognitive Services" -Tags -Unit {
|
||||
|
||||
#region - Template File Syntax
|
||||
Context "Template File Syntax" {
|
||||
|
||||
It "Has a JSON template file" {
|
||||
(Join-Path -Path "$here" -ChildPath "deploy.json") | Should -Exist
|
||||
}
|
||||
|
||||
It "Converts from JSON and has the expected properties" -TestCases $templateFileTestCases {
|
||||
param($templateFile)
|
||||
$expectedProperties = '$schema',
|
||||
'contentVersion',
|
||||
'parameters',
|
||||
'variables',
|
||||
'resources',
|
||||
'outputs' | Sort-Object
|
||||
$templateProperties = (Get-Content (Join-Path -Path "$here" -ChildPath "$templateFile") `
|
||||
| ConvertFrom-Json -ErrorAction SilentlyContinue) `
|
||||
| Get-Member -MemberType NoteProperty `
|
||||
| Sort-Object -Property Name `
|
||||
| ForEach-Object Name
|
||||
$templateProperties | Should -Be $expectedProperties
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region - Parameter File Syntax
|
||||
Context "Parameter File Syntax" {
|
||||
|
||||
It "Parameter file does not contains the expected properties" -TestCases $parameterFileTestCases {
|
||||
param($parameterFile)
|
||||
$expectedProperties = '$schema',
|
||||
'contentVersion',
|
||||
'parameters' | Sort-Object
|
||||
Write-Output $parameterFile
|
||||
Join-Path -Path "$here" -ChildPath "$parameterFile" | Write-Output
|
||||
$templateFileProperties = (Get-Content (Join-Path -Path "$here" -ChildPath "$parameterFile") `
|
||||
| ConvertFrom-Json -ErrorAction SilentlyContinue) `
|
||||
| Get-Member -MemberType NoteProperty `
|
||||
| Sort-Object -Property Name `
|
||||
| ForEach-Object Name
|
||||
$templateFileProperties | Should -Be $expectedProperties
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region - Template and Parameter Compactibility
|
||||
Context "Template and Parameter Compactibility" {
|
||||
|
||||
It "Is count of required parameters in template file equal or lesser than count of all parameters in parameters file" -TestCases $modules {
|
||||
param($module)
|
||||
$requiredParametersInTemplateFile = (Get-Content "$($module.Template)" `
|
||||
| ConvertFrom-Json -ErrorAction SilentlyContinue).Parameters.PSObject.Properties `
|
||||
| Where-Object -FilterScript { -not ($psitem.Value.PSObject.Properties.Name -eq "defaultValue")} `
|
||||
| Sort-Object -Property Name `
|
||||
| ForEach-Object Name
|
||||
ForEach ( $parameter in $module.Parameters ) {
|
||||
$allParametersInParametersFile = (Get-Content $parameter `
|
||||
| ConvertFrom-Json -ErrorAction SilentlyContinue).Parameters.PSObject.Properties `
|
||||
| Sort-Object -Property Name `
|
||||
| ForEach-Object Name
|
||||
$requiredParametersInTemplateFile.Count | Should -Not -BeGreaterThan $allParametersInParametersFile.Count
|
||||
}
|
||||
}
|
||||
|
||||
It "Has all parameters in parameters file existing in template file" -TestCases $modules {
|
||||
param($module)
|
||||
$allParametersInTemplateFile = (Get-Content "$($module.Template)" `
|
||||
| ConvertFrom-Json -ErrorAction SilentlyContinue).Parameters.PSObject.Properties `
|
||||
| Sort-Object -Property Name `
|
||||
| ForEach-Object Name
|
||||
ForEach ($parameter in $module.Parameters) {
|
||||
Write-Output "File analyzed: $parameter"
|
||||
$allParametersInParametersFile = (Get-Content $parameter `
|
||||
| ConvertFrom-Json -ErrorAction SilentlyContinue).Parameters.PSObject.Properties `
|
||||
| Sort-Object -Property Name `
|
||||
| ForEach-Object Name
|
||||
$result = @($allParametersInParametersFile| Where-Object {$allParametersInTemplateFile -notcontains $psitem})
|
||||
Write-Output "Invalid parameters: $(ConvertTo-Json $result)"
|
||||
@($allParametersInParametersFile| Where-Object {$allParametersInTemplateFile -notcontains $psitem}).Count | Should -Be 0
|
||||
}
|
||||
}
|
||||
|
||||
It "Has required parameters in template file existing in parameters file" -TestCases $modules {
|
||||
param($module)
|
||||
$requiredParametersInTemplateFile = (Get-Content "$($module.Template)" `
|
||||
| ConvertFrom-Json -ErrorAction SilentlyContinue).Parameters.PSObject.Properties `
|
||||
| Where-Object -FilterScript { -not ($psitem.Value.PSObject.Properties.Name -eq "defaultValue") } `
|
||||
| Sort-Object -Property Name `
|
||||
| ForEach-Object Name
|
||||
ForEach ($parameter in $module.Parameters ) {
|
||||
$allParametersInParametersFile = (Get-Content $parameter `
|
||||
| ConvertFrom-Json -ErrorAction SilentlyContinue).Parameters.PSObject.Properties `
|
||||
| Sort-Object -Property Name `
|
||||
| ForEach-Object Name
|
||||
@($requiredParametersInTemplateFile| Where-Object {$allParametersInParametersFile -notcontains $psitem}).Count | Should -Be 0
|
||||
}
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
#endregion
|
|
@ -0,0 +1,81 @@
|
|||
<#
|
||||
.NOTES
|
||||
==============================================================================================
|
||||
Copyright(c) Microsoft Corporation. All rights reserved.
|
||||
|
||||
Microsoft Consulting Services - AzureCAT - VDC Toolkit (v2.0)
|
||||
|
||||
File: output.tests.ps1
|
||||
|
||||
Purpose: Test - Cognitive Services ARM Template Output Variables
|
||||
|
||||
Version: 2.0.0.0 - 1st September 2019 - Azure Virtual Datacenter Development Team
|
||||
==============================================================================================
|
||||
|
||||
.SYNOPSIS
|
||||
This script contains functionality used to test Cognitive Services ARM Templates output variables.
|
||||
|
||||
.DESCRIPTION
|
||||
This script contains functionality used to test Cognitive Services ARM Templates output variables.
|
||||
|
||||
Deployment steps of the script are outlined below.
|
||||
1) Outputs Variable Logic from pipeline
|
||||
|
||||
.PARAMETER cognitiveServicesName
|
||||
Specify the Cognitive Services Name output parameter.
|
||||
|
||||
.PARAMETER cognitiveServicesResourceId
|
||||
Specify the Cognitive Services ResourceId output parameter.
|
||||
|
||||
.PARAMETER cognitiveServicesResourceGroup
|
||||
Specify the Cognitive Services ResourceGroup output parameter.
|
||||
|
||||
.EXAMPLE
|
||||
Default:
|
||||
C:\PS>.\output.tests.ps1
|
||||
-cognitiveServicesName "$(cognitiveServicesName)"
|
||||
-cognitiveServicesResourceId "$(cognitiveServicesResourceId)"
|
||||
-cognitiveServicesResourceGroup "$(cognitiveServicesResourceGroup)"
|
||||
#>
|
||||
|
||||
#Requires -Version 5
|
||||
|
||||
[CmdletBinding()]
|
||||
param
|
||||
(
|
||||
[Parameter(Mandatory = $false)]
|
||||
[string]$cognitiveServicesName,
|
||||
|
||||
[Parameter(Mandatory = $false)]
|
||||
[string]$cognitiveServicesResourceId,
|
||||
|
||||
[Parameter(Mandatory = $false)]
|
||||
[string]$cognitiveServicesResourceGroup
|
||||
)
|
||||
|
||||
if (-not [string]::IsNullOrWhiteSpace($PSBoundParameters['cognitiveServicesName']))
|
||||
{
|
||||
Write-Output "Cognitive Services Name: $($cognitiveServicesName)"
|
||||
}
|
||||
else
|
||||
{
|
||||
Write-Output "Cognitive Services Name: []"
|
||||
}
|
||||
|
||||
if (-not [string]::IsNullOrWhiteSpace($PSBoundParameters['cognitiveServicesResourceId']))
|
||||
{
|
||||
Write-Output "Cognitive Services ResourceId: $($cognitiveServicesResourceId)"
|
||||
}
|
||||
else
|
||||
{
|
||||
Write-Output "Cognitive Services ResourceId: []"
|
||||
}
|
||||
|
||||
if (-not [string]::IsNullOrWhiteSpace($PSBoundParameters['cognitiveServicesResourceGroup']))
|
||||
{
|
||||
Write-Output "Cognitive Services Resource Group: $($cognitiveServicesResourceGroup)"
|
||||
}
|
||||
else
|
||||
{
|
||||
Write-Output "Cognitive Services Resource Group: []"
|
||||
}
|
|
@ -2,8 +2,8 @@
|
|||
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentParameters.json#",
|
||||
"contentVersion": "1.0.0.0",
|
||||
"parameters": {
|
||||
"workspaceName": {
|
||||
"value": null
|
||||
"accountName": {
|
||||
"value": "testaccountName"
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,29 +0,0 @@
|
|||
# Cognitve Services
|
||||
|
||||
This template deploys an Cognitve Services Translation API.
|
||||
|
||||
https://docs.microsoft.com/en-us/azure/templates/microsoft.cognitiveservices/allversions
|
||||
|
||||
|
||||
## Resources
|
||||
|
||||
The following Resources are deployed.
|
||||
|
||||
+ **Cognitive Services** : Accounts
|
||||
|
||||
|
||||
## Parameters
|
||||
|
||||
+ **accountName** - Display name of Text Translation API account
|
||||
+ **sku** - SKU for TextTranslation API
|
||||
+ **location** - Location for all resources
|
||||
|
||||
|
||||
## Outputs
|
||||
|
||||
There is no Outputs in this module
|
||||
|
||||
|
||||
## Scripts
|
||||
|
||||
There is no Scripts in this module
|
|
@ -1,49 +0,0 @@
|
|||
{
|
||||
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
|
||||
"contentVersion": "1.0.0.0",
|
||||
"parameters": {
|
||||
"accountName": {
|
||||
"type": "string",
|
||||
"defaultValue": "translate",
|
||||
"metadata": {
|
||||
"description": "Display name of Text Translation API account"
|
||||
}
|
||||
},
|
||||
"sku": {
|
||||
"type": "string",
|
||||
"allowedValues": [
|
||||
"F0",
|
||||
"S1",
|
||||
"S2",
|
||||
"S3",
|
||||
"S4"
|
||||
],
|
||||
"defaultValue": "F0",
|
||||
"metadata": {
|
||||
"description": "SKU for TextTranslation API"
|
||||
}
|
||||
},
|
||||
"location": {
|
||||
"type": "string",
|
||||
"defaultValue": "[resourceGroup().location]",
|
||||
"metadata": {
|
||||
"description": "Location for all resources"
|
||||
}
|
||||
}
|
||||
},
|
||||
"variables": {},
|
||||
"resources": [
|
||||
{
|
||||
"type": "Microsoft.CognitiveServices/accounts",
|
||||
"apiVersion": "2017-04-18",
|
||||
"name": "[parameters('accountName')]",
|
||||
"location": "[parameters('location')]",
|
||||
"kind": "TextTranslation",
|
||||
"properties": {},
|
||||
"sku": {
|
||||
"name": "[parameters('sku')]"
|
||||
}
|
||||
}
|
||||
],
|
||||
"outputs": {}
|
||||
}
|
|
@ -0,0 +1,97 @@
|
|||
{
|
||||
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
|
||||
"contentVersion": "1.0.0.0",
|
||||
"parameters": {
|
||||
"accountName": {
|
||||
"type": "string",
|
||||
"metadata": {
|
||||
"description": "Required. The name of Text Translation API account"
|
||||
}
|
||||
},
|
||||
"sku": {
|
||||
"type": "string",
|
||||
"defaultValue": "S0",
|
||||
"metadata": {
|
||||
"description": "Optional. sku for Text Translation API"
|
||||
}
|
||||
},
|
||||
"location": {
|
||||
"type": "string",
|
||||
"defaultValue": "[resourceGroup().location]",
|
||||
"metadata": {
|
||||
"description": "Optional. Location for all Resources"
|
||||
}
|
||||
},
|
||||
"cuaId": {
|
||||
"type": "string",
|
||||
"defaultValue": "",
|
||||
"metadata": {
|
||||
"description": "Optional. Customer Usage Attribution id (GUID). This GUID must be previously registered"
|
||||
}
|
||||
},
|
||||
"tagValues": {
|
||||
"type": "object",
|
||||
"defaultValue": "",
|
||||
"metadata": {
|
||||
"description": "Optional. Azure Resource Tags object"
|
||||
}
|
||||
}
|
||||
},
|
||||
"variables": {
|
||||
"cognitiveServicesName": "[parameters('accountName')]",
|
||||
"cognitiveServicesResourceId": "[resourceId('Microsoft.CognitiveServices/accounts',parameters('accountName'))]",
|
||||
"cognitiveServicesApiVersion": "2017-04-18",
|
||||
"pidName": "[concat('pid-', parameters('cuaId'))]"
|
||||
},
|
||||
"resources": [
|
||||
{
|
||||
"condition": "[not(empty(parameters('cuaId')))]",
|
||||
"type": "Microsoft.Resources/deployments",
|
||||
"apiVersion": "2018-02-01",
|
||||
"name": "[variables('pidName')]",
|
||||
"properties": {
|
||||
"mode": "Incremental",
|
||||
"template": {
|
||||
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
|
||||
"contentVersion": "1.0.0.0",
|
||||
"resources": []
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "Microsoft.CognitiveServices/accounts",
|
||||
"apiVersion": "[variables('cognitiveServicesApiVersion')]",
|
||||
"name": "[variables('cognitiveServicesName')]",
|
||||
"location": "[parameters('location')]",
|
||||
"kind": "TextTranslation",
|
||||
"tags": "[if(empty(parameters('tagValues')), json('null'), parameters('tagValues'))]",
|
||||
"sku": {
|
||||
"name": "[parameters('sku')]"
|
||||
},
|
||||
"properties": {}
|
||||
}
|
||||
],
|
||||
"outputs": {
|
||||
"cognitiveServicesName": {
|
||||
"type": "string",
|
||||
"value": "[variables('cognitiveServicesName')]",
|
||||
"metadata": {
|
||||
"description": "The Name of the Cognitive Services"
|
||||
}
|
||||
},
|
||||
"cognitiveServicesResourceId": {
|
||||
"type": "string",
|
||||
"value": "[variables('cognitiveServicesResourceId')]",
|
||||
"metadata": {
|
||||
"description": "The Resource Id of the Cognitive Services"
|
||||
}
|
||||
},
|
||||
"cognitiveServicesResourceGroup": {
|
||||
"type": "string",
|
||||
"value": "[resourceGroup().name]",
|
||||
"metadata": {
|
||||
"description": "The name of the Resource Group with the Cognitive Services"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,39 @@
|
|||
# Cognitve Services
|
||||
|
||||
This module deploys Cognitve Services Translation API.
|
||||
|
||||
## Resources
|
||||
|
||||
The following Resources are deployed.
|
||||
|
||||
+ **Microsoft.CognitiveServices/accounts**
|
||||
|
||||
## Parameters
|
||||
|
||||
| Parameter Name | Default Value | Required | Description |
|
||||
| :- | :- | :- |:- |
|
||||
| `accountName` || **Required** |The name of Text Translation API account
|
||||
| `sku` | S0| **Optional** | sku for Text Translation API
|
||||
| `location` || **Optional** | Location for all Resources
|
||||
| `cuaId` || **Optional** | Customer Usage Attribution Id (GUID). This GUID must be previously registered
|
||||
| `tagValues` || **Optional** | Optional. Azure Resource Tags object
|
||||
|
||||
## Outputs
|
||||
|
||||
| Output Name | Description |
|
||||
| :- | :- |
|
||||
| `cognitiveServicesName` | Cognitive Services Name output parameter
|
||||
| `cognitiveServicesResourceId` | Cognitive Services ResourceId output parameter
|
||||
| `cognitiveServicesResourceGroup` | Cognitive Services ResourceGroup output parameter
|
||||
|
||||
## Scripts
|
||||
|
||||
+ There is no Scripts for this Module
|
||||
|
||||
## Considerations
|
||||
|
||||
+ There is no deployment considerations for this Module
|
||||
|
||||
## Additional resources
|
||||
|
||||
+ [Microsoft Cognitve Services template reference](https://docs.microsoft.com/en-us/azure/templates/microsoft.cognitiveservices/allversions)
|
|
@ -0,0 +1,35 @@
|
|||
name: $(Build.DefinitionName)-$(SourceBranchName)-$(Date:yyyyMMdd).$(Rev:rr)
|
||||
|
||||
variables:
|
||||
ModuleName: EventHub
|
||||
ModuleVersion: 2.0
|
||||
RepoName: azure-devops
|
||||
ModulePath: modules/$(ModuleName)/$(ModuleVersion)
|
||||
ArtifactName: contents
|
||||
|
||||
resources:
|
||||
repositories:
|
||||
- repository: main
|
||||
type: git
|
||||
name: '$(RepoName)'
|
||||
|
||||
trigger:
|
||||
branches:
|
||||
include:
|
||||
- master
|
||||
- '*'
|
||||
paths:
|
||||
include:
|
||||
- modules/EventHub/2.0
|
||||
|
||||
jobs:
|
||||
- job: BuildModule
|
||||
displayName: Build Module
|
||||
workspace:
|
||||
clean: all
|
||||
|
||||
steps:
|
||||
- template: /azure-devops/ci/buildmodule.yaml
|
||||
parameters:
|
||||
ModulePath: $(ModulePath)
|
||||
ArtifactName: $(ArtifactName)
|
|
@ -3,18 +3,20 @@
|
|||
==============================================================================================
|
||||
Copyright(c) Microsoft Corporation. All rights reserved.
|
||||
|
||||
Microsoft Consulting Services - AzureCAT - VDC Toolkit (v2.0)
|
||||
|
||||
File: module.tests.ps1
|
||||
|
||||
Purpose: Pester - Test ADDS ARM Templates
|
||||
Purpose: Pester - Test EventHub Namespace ARM Templates
|
||||
|
||||
Version: 1.0.0.0 - 1st August 2019 - Azure Virtual Datacenter Development Team
|
||||
Version: 2.0.0.0 - 1st September 2019 - Azure Virtual Datacenter Development Team
|
||||
==============================================================================================
|
||||
|
||||
.SYNOPSIS
|
||||
This script contains functionality used to test Azure Storage Account ARM template synatax.
|
||||
This script contains functionality used to test EventHub Namespace ARM template synatax.
|
||||
|
||||
.DESCRIPTION
|
||||
This script contains functionality used to test Azure Storage Account ARM template synatax.
|
||||
This script contains functionality used to test EventHub Namespace ARM template synatax.
|
||||
|
||||
Deployment steps of the script are outlined below.
|
||||
1) Test Template File Syntax
|
||||
|
@ -25,146 +27,145 @@
|
|||
#Requires -Version 5
|
||||
|
||||
#region Parameters
|
||||
|
||||
$here = Split-Path -Parent $MyInvocation.MyCommand.Path
|
||||
$here = Join-Path $here ".."
|
||||
$here = Join-Path -Path $here -ChildPath ".."
|
||||
$template = Split-Path -Leaf $here
|
||||
$TemplateFileTestCases = @()
|
||||
ForEach ( $File in (Get-ChildItem (Join-Path "$here" "deploy.json") -Recurse | Select-Object -ExpandProperty Name) ) {
|
||||
$TemplateFileTestCases += @{ TemplateFile = $File }
|
||||
|
||||
#region - Template File Test Cases
|
||||
$templateFileTestCases = @()
|
||||
ForEach ($file in (Get-ChildItem (Join-Path -Path "$here" -ChildPath "deploy.json") -Recurse | Select-Object -ExpandProperty Name)) {
|
||||
$templateFileTestCases += @{ TemplateFile = $file }
|
||||
}
|
||||
$ParameterFileTestCases = @()
|
||||
ForEach ( $File in (Get-ChildItem (Join-Path "$here" "Tests" -AdditionalChildPath @("*parameters.json")) -Recurse -ErrorAction SilentlyContinue | Select-Object -ExpandProperty Name) ) {
|
||||
$ParameterFileTestCases += @{ ParameterFile = Join-Path "Tests" $File }
|
||||
#endregion
|
||||
|
||||
#region - Parameter File Test Cases
|
||||
$parameterFileTestCases = @()
|
||||
ForEach ($file in (Get-ChildItem (Join-Path -Path "$here" -ChildPath "Tests" -AdditionalChildPath @("*parameters.json")) -Recurse -ErrorAction SilentlyContinue | Select-Object -ExpandProperty Name)) {
|
||||
$parameterFileTestCases += @{ ParameterFile = Join-Path -Path "Tests" $file }
|
||||
}
|
||||
$Modules = @();
|
||||
ForEach ( $File in (Get-ChildItem (Join-Path "$here" "deploy.json") ) ) {
|
||||
$Module = [PSCustomObject]@{
|
||||
#endregion
|
||||
|
||||
#region - Module Test Cases
|
||||
$modules = @()
|
||||
ForEach ($file in (Get-ChildItem (Join-Path -Path "$here" -ChildPath "deploy.json"))) {
|
||||
$module = [PSCustomObject]@{
|
||||
'Template' = $null
|
||||
'Parameters' = $null
|
||||
}
|
||||
$Module.Template = $File.FullName;
|
||||
$Parameters = @();
|
||||
ForEach ( $ParameterFile in (Get-ChildItem (Join-Path "$here" "Tests" -AdditionalChildPath @("*parameters.json")) -Recurse -ErrorAction SilentlyContinue| Select-Object -ExpandProperty Name) ) {
|
||||
$Parameters += (Join-Path "$here" "Tests" -AdditionalChildPath @("$ParameterFile") )
|
||||
$module.Template = $file.FullName
|
||||
|
||||
$parameters = @()
|
||||
ForEach ($parameterFile in (Get-ChildItem (Join-Path -Path "$here" -ChildPath "Tests" -AdditionalChildPath @("*parameters.json")) -Recurse -ErrorAction SilentlyContinue | Select-Object -ExpandProperty Name)) {
|
||||
$parameters += (Join-Path -Path "$here" -ChildPath "Tests" -AdditionalChildPath @("$ParameterFile"))
|
||||
}
|
||||
$Module.Parameters = $Parameters;
|
||||
$Modules += @{ Module = $Module };
|
||||
$Module.Parameters = $Parameters
|
||||
$Modules += @{Module = $Module}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
#region Run Pester Test Script
|
||||
Describe "Template: $template - Storage Accounts" -Tags Unit {
|
||||
#region - Run Pester Test Script
|
||||
Describe "Template: $template - EventHub Namespace" -Tags -Unit {
|
||||
|
||||
#region - Template File Syntax
|
||||
Context "Template File Syntax" {
|
||||
|
||||
It "Has a JSON template file" {
|
||||
(Join-Path "$here" "deploy.json") | Should Exist
|
||||
(Join-Path -Path "$here" -ChildPath "deploy.json") | Should -Exist
|
||||
}
|
||||
|
||||
It "Converts from JSON and has the expected properties" -TestCases $TemplateFileTestCases {
|
||||
Param( $TemplateFile )
|
||||
It "Converts from JSON and has the expected properties" -TestCases $templateFileTestCases {
|
||||
param($templateFile)
|
||||
$expectedProperties = '$schema',
|
||||
'contentVersion',
|
||||
'parameters',
|
||||
'variables',
|
||||
'resources',
|
||||
'outputs' | Sort-Object
|
||||
$templateProperties = (Get-Content (Join-Path "$here" "$TemplateFile") `
|
||||
| ConvertFrom-Json -ErrorAction SilentlyContinue) `
|
||||
| Get-Member -MemberType NoteProperty `
|
||||
| Sort-Object -Property Name `
|
||||
| ForEach-Object Name
|
||||
$templateProperties | Should Be $expectedProperties
|
||||
}
|
||||
$templateProperties = (Get-Content (Join-Path -Path "$here" -ChildPath "$templateFile") `
|
||||
| ConvertFrom-Json -ErrorAction SilentlyContinue) `
|
||||
| Get-Member -MemberType NoteProperty `
|
||||
| Sort-Object -Property Name `
|
||||
| ForEach-Object Name
|
||||
$templateProperties | Should -Be $expectedProperties
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region - Parameter File Syntax
|
||||
Context "Parameter File Syntax" {
|
||||
|
||||
It "Parameter file does not contains the expected properties" -TestCases $ParameterFileTestCases {
|
||||
Param( $ParameterFile )
|
||||
|
||||
It "Parameter file does not contains the expected properties" -TestCases $parameterFileTestCases {
|
||||
param($parameterFile)
|
||||
$expectedProperties = '$schema',
|
||||
'contentVersion',
|
||||
'parameters' | Sort-Object
|
||||
Write-Host $ParameterFile
|
||||
Join-Path "$here" "$ParameterFile" | Write-Host
|
||||
$templateFileProperties = (Get-Content (Join-Path "$here" "$ParameterFile") `
|
||||
| ConvertFrom-Json -ErrorAction SilentlyContinue) `
|
||||
| Get-Member -MemberType NoteProperty `
|
||||
| Sort-Object -Property Name `
|
||||
| ForEach-Object Name
|
||||
$templateFileProperties | Should Be $expectedProperties
|
||||
Write-Output $parameterFile
|
||||
Join-Path -Path "$here" -ChildPath "$parameterFile" | Write-Output
|
||||
$templateFileProperties = (Get-Content (Join-Path -Path "$here" -ChildPath "$parameterFile") `
|
||||
| ConvertFrom-Json -ErrorAction SilentlyContinue) `
|
||||
| Get-Member -MemberType NoteProperty `
|
||||
| Sort-Object -Property Name `
|
||||
| ForEach-Object Name
|
||||
$templateFileProperties | Should -Be $expectedProperties
|
||||
}
|
||||
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region - Template and Parameter Compactibility
|
||||
Context "Template and Parameter Compactibility" {
|
||||
|
||||
It "Is count of required parameters in template file equal or lesser than count of all parameters in parameters file" -TestCases $Modules {
|
||||
Param( $Module )
|
||||
|
||||
$requiredParametersInTemplateFile = (Get-Content "$($Module.Template)" `
|
||||
| ConvertFrom-Json -ErrorAction SilentlyContinue).Parameters.PSObject.Properties `
|
||||
| Where-Object -FilterScript { -not ($_.Value.PSObject.Properties.Name -eq "defaultValue") } `
|
||||
| Sort-Object -Property Name `
|
||||
| ForEach-Object Name
|
||||
ForEach ( $Parameter in $Module.Parameters ) {
|
||||
$allParametersInParametersFile = (Get-Content $Parameter `
|
||||
| ConvertFrom-Json -ErrorAction SilentlyContinue).Parameters.PSObject.Properties `
|
||||
| Sort-Object -Property Name `
|
||||
| ForEach-Object Name
|
||||
if ($requiredParametersInTemplateFile.Count -gt $allParametersInParametersFile.Count) {
|
||||
Write-Host "Mismatch found, parameters from parameter file are more than the expected in the template"
|
||||
Write-Host "Required parameters are: $(ConvertTo-Json $requiredParametersInTemplateFile)"
|
||||
Write-Host "Parameters from parameter file are: $(ConvertTo-Json $allParametersInParametersFile)"
|
||||
}
|
||||
$requiredParametersInTemplateFile.Count | Should Not BeGreaterThan $allParametersInParametersFile.Count;
|
||||
It "Is count of required parameters in template file equal or lesser than count of all parameters in parameters file" -TestCases $modules {
|
||||
param($module)
|
||||
$requiredParametersInTemplateFile = (Get-Content "$($module.Template)" `
|
||||
| ConvertFrom-Json -ErrorAction SilentlyContinue).Parameters.PSObject.Properties `
|
||||
| Where-Object -FilterScript { -not ($psitem.Value.PSObject.Properties.Name -eq "defaultValue")} `
|
||||
| Sort-Object -Property Name `
|
||||
| ForEach-Object Name
|
||||
ForEach ( $parameter in $module.Parameters ) {
|
||||
$allParametersInParametersFile = (Get-Content $parameter `
|
||||
| ConvertFrom-Json -ErrorAction SilentlyContinue).Parameters.PSObject.Properties `
|
||||
| Sort-Object -Property Name `
|
||||
| ForEach-Object Name
|
||||
$requiredParametersInTemplateFile.Count | Should -Not -BeGreaterThan $allParametersInParametersFile.Count
|
||||
}
|
||||
}
|
||||
|
||||
It "Has all parameters in parameters file existing in template file" -TestCases $Modules {
|
||||
Param( $Module )
|
||||
|
||||
$allParametersInTemplateFile = (Get-Content "$($Module.Template)" `
|
||||
| ConvertFrom-Json -ErrorAction SilentlyContinue).Parameters.PSObject.Properties `
|
||||
| Sort-Object -Property Name `
|
||||
| ForEach-Object Name
|
||||
ForEach ( $Parameter in $Module.Parameters ) {
|
||||
Write-Host "File analyzed: $Parameter";
|
||||
$allParametersInParametersFile = (Get-Content $Parameter `
|
||||
| ConvertFrom-Json -ErrorAction SilentlyContinue).Parameters.PSObject.Properties `
|
||||
| Sort-Object -Property Name `
|
||||
| ForEach-Object Name
|
||||
$result = @($allParametersInParametersFile| Where-Object {$allParametersInTemplateFile -notcontains $_});
|
||||
Write-Host "Invalid parameters: $(ConvertTo-Json $result)";
|
||||
@($allParametersInParametersFile| Where-Object {$allParametersInTemplateFile -notcontains $_}).Count | Should Be 0;
|
||||
It "Has all parameters in parameters file existing in template file" -TestCases $modules {
|
||||
param($module)
|
||||
$allParametersInTemplateFile = (Get-Content "$($module.Template)" `
|
||||
| ConvertFrom-Json -ErrorAction SilentlyContinue).Parameters.PSObject.Properties `
|
||||
| Sort-Object -Property Name `
|
||||
| ForEach-Object Name
|
||||
ForEach ($parameter in $module.Parameters) {
|
||||
Write-Output "File analyzed: $parameter"
|
||||
$allParametersInParametersFile = (Get-Content $parameter `
|
||||
| ConvertFrom-Json -ErrorAction SilentlyContinue).Parameters.PSObject.Properties `
|
||||
| Sort-Object -Property Name `
|
||||
| ForEach-Object Name
|
||||
$result = @($allParametersInParametersFile| Where-Object {$allParametersInTemplateFile -notcontains $psitem})
|
||||
Write-Output "Invalid parameters: $(ConvertTo-Json $result)"
|
||||
@($allParametersInParametersFile| Where-Object {$allParametersInTemplateFile -notcontains $psitem}).Count | Should -Be 0
|
||||
}
|
||||
}
|
||||
|
||||
It "Has required parameters in template file existing in parameters file" -TestCases $Modules {
|
||||
Param( $Module )
|
||||
|
||||
$requiredParametersInTemplateFile = (Get-Content "$($Module.Template)" `
|
||||
| ConvertFrom-Json -ErrorAction SilentlyContinue).Parameters.PSObject.Properties `
|
||||
| Where-Object -FilterScript { -not ($_.Value.PSObject.Properties.Name -eq "defaultValue") } `
|
||||
| Sort-Object -Property Name `
|
||||
| ForEach-Object Name
|
||||
ForEach ( $Parameter in $Module.Parameters ) {
|
||||
|
||||
$allParametersInParametersFile = (Get-Content $Parameter `
|
||||
| ConvertFrom-Json -ErrorAction SilentlyContinue).Parameters.PSObject.Properties `
|
||||
| Sort-Object -Property Name `
|
||||
| ForEach-Object Name
|
||||
|
||||
$invalid = $requiredParametersInTemplateFile | Where-Object {$allParametersInParametersFile -notcontains $_}
|
||||
if ($invalid.Count -gt 0) {
|
||||
Write-Host "Invalid parameters: $(ConvertTo-Json $invalid)"
|
||||
}
|
||||
@($requiredParametersInTemplateFile | Where-Object {$allParametersInParametersFile -notcontains $_}).Count | Should Be 0;
|
||||
It "Has required parameters in template file existing in parameters file" -TestCases $modules {
|
||||
param($module)
|
||||
$requiredParametersInTemplateFile = (Get-Content "$($module.Template)" `
|
||||
| ConvertFrom-Json -ErrorAction SilentlyContinue).Parameters.PSObject.Properties `
|
||||
| Where-Object -FilterScript { -not ($psitem.Value.PSObject.Properties.Name -eq "defaultValue") } `
|
||||
| Sort-Object -Property Name `
|
||||
| ForEach-Object Name
|
||||
ForEach ($parameter in $module.Parameters ) {
|
||||
$allParametersInParametersFile = (Get-Content $parameter `
|
||||
| ConvertFrom-Json -ErrorAction SilentlyContinue).Parameters.PSObject.Properties `
|
||||
| Sort-Object -Property Name `
|
||||
| ForEach-Object Name
|
||||
@($requiredParametersInTemplateFile| Where-Object {$allParametersInParametersFile -notcontains $psitem}).Count | Should -Be 0
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
#endregion
|
|
@ -0,0 +1,113 @@
|
|||
<#
|
||||
.NOTES
|
||||
==============================================================================================
|
||||
Copyright(c) Microsoft Corporation. All rights reserved.
|
||||
|
||||
Microsoft Consulting Services - AzureCAT - VDC Toolkit (v2.0)
|
||||
|
||||
File: output.tests.ps1
|
||||
|
||||
Purpose: Test - EventHub Namespace ARM Template Output Variables
|
||||
|
||||
Version: 2.0.0.0 - 1st September 2019 - Azure Virtual Datacenter Development Team
|
||||
==============================================================================================
|
||||
|
||||
.SYNOPSIS
|
||||
This script contains functionality used to test EventHub Namespace ARM Templates output variables.
|
||||
|
||||
.DESCRIPTION
|
||||
This script contains functionality used to test EventHub Namespace ARM Templates output variables.
|
||||
|
||||
Deployment steps of the script are outlined below.
|
||||
1) Outputs Variable Logic from pipeline
|
||||
|
||||
.PARAMETER namespaceName
|
||||
Specify the EventHub Namespace Name output parameter.
|
||||
|
||||
.PARAMETER namespaceResourceId
|
||||
Specify the EventHub Namespace ResourceId output parameter.
|
||||
|
||||
.PARAMETER namespaceResourceGroup
|
||||
Specify the EventHub Namespace ResourceGroup output parameter.
|
||||
|
||||
.PARAMETER namespaceConnectionString
|
||||
Specify the EventHub Namespace Connection String output parameter.
|
||||
|
||||
.PARAMETER sharedAccessPolicyPrimaryKey
|
||||
Specify the EventHub Namespace Shared Access Policy Primary Key output parameter.
|
||||
|
||||
.EXAMPLE
|
||||
Default:
|
||||
C:\PS>.\output.tests.ps1
|
||||
-namespaceName "$(namespaceName)"
|
||||
-namespaceResourceId "$(namespaceResourceId)"
|
||||
-namespaceResourceGroup "$(namespaceResourceGroup)"
|
||||
-namespaceConnectionString "$(namespaceConnectionString)"
|
||||
-sharedAccessPolicyPrimaryKey "$(sharedAccessPolicyPrimaryKey)"
|
||||
#>
|
||||
|
||||
#Requires -Version 5
|
||||
|
||||
[CmdletBinding()]
|
||||
param
|
||||
(
|
||||
[Parameter(Mandatory = $false)]
|
||||
[string]$namespaceName,
|
||||
|
||||
[Parameter(Mandatory = $false)]
|
||||
[string]$namespaceResourceId,
|
||||
|
||||
[Parameter(Mandatory = $false)]
|
||||
[string]$namespaceResourceGroup,
|
||||
|
||||
[Parameter(Mandatory = $false)]
|
||||
[string]$namespaceConnectionString,
|
||||
|
||||
[Parameter(Mandatory = $false)]
|
||||
[string]$sharedAccessPolicyPrimaryKey
|
||||
)
|
||||
|
||||
if (-not [string]::IsNullOrWhiteSpace($PSBoundParameters['namespaceName']))
|
||||
{
|
||||
Write-Output "EventHub Namespace Name: $($namespaceName)"
|
||||
}
|
||||
else
|
||||
{
|
||||
Write-Output "EventHub Namespace Name: []"
|
||||
}
|
||||
|
||||
if (-not [string]::IsNullOrWhiteSpace($PSBoundParameters['namespaceResourceId']))
|
||||
{
|
||||
Write-Output "EventHub Namespace ResourceId: $($namespaceResourceId)"
|
||||
}
|
||||
else
|
||||
{
|
||||
Write-Output "EventHub Namespace ResourceId: []"
|
||||
}
|
||||
|
||||
if (-not [string]::IsNullOrWhiteSpace($PSBoundParameters['namespaceResourceGroup']))
|
||||
{
|
||||
Write-Output "EventHub Namespace Resource Group: $($namespaceResourceGroup)"
|
||||
}
|
||||
else
|
||||
{
|
||||
Write-Output "EventHub Namespace Resource Group: []"
|
||||
}
|
||||
|
||||
if (-not [string]::IsNullOrWhiteSpace($PSBoundParameters['namespaceConnectionString']))
|
||||
{
|
||||
Write-Output "EventHub Namespace ConnectionString: $namespaceConnectionString"
|
||||
}
|
||||
else
|
||||
{
|
||||
Write-Output "EventHub Namespace ConnectionString: []"
|
||||
}
|
||||
|
||||
if (-not [string]::IsNullOrWhiteSpace($PSBoundParameters['sharedAccessPolicyPrimaryKey']))
|
||||
{
|
||||
Write-Output "EventHub Namespace Shared Access Policy Primary Key: $sharedAccessPolicyPrimaryKey"
|
||||
}
|
||||
else
|
||||
{
|
||||
Write-Output "EventHub Namespace Shared Access Policy Primary Key: []"
|
||||
}
|
|
@ -1,163 +0,0 @@
|
|||
<#
|
||||
.NOTES
|
||||
==============================================================================================
|
||||
Copyright(c) Microsoft Corporation. All rights reserved.
|
||||
|
||||
File: module.tests.ps1
|
||||
|
||||
Purpose: Pester - Test Key Vault ARM Templates
|
||||
|
||||
Version: 1.0.0.0 - 1st April 2019 - Azure Virtual Datacenter Development Team
|
||||
==============================================================================================
|
||||
|
||||
.SYNOPSIS
|
||||
This script contains functionality used to test Azure Key Vault ARM template synatax.
|
||||
|
||||
.DESCRIPTION
|
||||
This script contains functionality used to test Azure Key Vault ARM template synatax.
|
||||
|
||||
Deployment steps of the script are outlined below.
|
||||
1) Test Template File Syntax
|
||||
2) Test Parameter File Syntax
|
||||
3) Test Template and Parameter File Compactibility
|
||||
#>
|
||||
|
||||
#Requires -Version 5
|
||||
|
||||
#region Parameters
|
||||
|
||||
$here = Split-Path -Parent $MyInvocation.MyCommand.Path
|
||||
$here = Join-Path $here ".."
|
||||
$template = Split-Path -Leaf $here
|
||||
$TemplateFileTestCases = @()
|
||||
ForEach ( $File in (Get-ChildItem (Join-Path "$here" "Policy" -AdditionalChildPath @("deploy.json")) -Recurse -ErrorAction SilentlyContinue| Select-Object -ExpandProperty Name) ) {
|
||||
$TemplateFileTestCases += @{ TemplateFile = $File }
|
||||
}
|
||||
$ParameterFileTestCases = @()
|
||||
ForEach ( $File in (Get-ChildItem (Join-Path "$here" "Policy" -AdditionalChildPath @("*parameters.json")) -Recurse -ErrorAction SilentlyContinue| Select-Object -ExpandProperty Name) ) {
|
||||
$ParameterFileTestCases += @{ ParameterFile = Join-Path "Policy" $File }
|
||||
}
|
||||
$Modules = @();
|
||||
ForEach ( $File in (Get-ChildItem (Join-Path "$here" "Policy" -AdditionalChildPath @("deploy.json")) -ErrorAction SilentlyContinue ) ) {
|
||||
$Module = [PSCustomObject]@{
|
||||
'Template' = $null
|
||||
'Parameters' = $null
|
||||
}
|
||||
$Module.Template = $File.FullName;
|
||||
$Parameters = @();
|
||||
ForEach ( $ParameterFile in (Get-ChildItem (Join-Path "$here" "Policy" -AdditionalChildPath @("*parameters.json")) -Recurse -ErrorAction SilentlyContinue | Select-Object -ExpandProperty Name) ) {
|
||||
$Parameters += (Join-Path "$here" "Policy" -AdditionalChildPath @("$ParameterFile") )
|
||||
}
|
||||
$Module.Parameters = $Parameters;
|
||||
$Modules += @{ Module = $Module };
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
if ($null -ne $TemplateFileTestCases -and
|
||||
$TemplateFileTestCases.Count -gt 0) {
|
||||
|
||||
#region Run Pester Test Script
|
||||
Describe "Template: $template - Key Vault" -Tags Unit {
|
||||
|
||||
Context "Template File Syntax" {
|
||||
|
||||
It "Has a JSON template file" {
|
||||
(Join-Path "$here" "deploy.json") | Should Exist
|
||||
}
|
||||
|
||||
It "Converts from JSON and has the expected properties" -TestCases $TemplateFileTestCases {
|
||||
Param( $TemplateFile )
|
||||
$expectedProperties = '$schema',
|
||||
'contentVersion',
|
||||
'parameters',
|
||||
'variables',
|
||||
'resources',
|
||||
'outputs' | Sort-Object
|
||||
$templateProperties = (Get-Content (Join-Path "$here" "$TemplateFile") `
|
||||
| ConvertFrom-Json -ErrorAction SilentlyContinue) `
|
||||
| Get-Member -MemberType NoteProperty `
|
||||
| Sort-Object -Property Name `
|
||||
| ForEach-Object Name
|
||||
$templateProperties | Should Be $expectedProperties
|
||||
}
|
||||
}
|
||||
|
||||
Context "Parameter File Syntax" {
|
||||
|
||||
It "Parameter file does not contains the expected properties" -TestCases $ParameterFileTestCases {
|
||||
Param( $ParameterFile )
|
||||
$expectedProperties = '$schema',
|
||||
'contentVersion',
|
||||
'parameters' | Sort-Object
|
||||
Write-Host $ParameterFile
|
||||
Join-Path "$here" "$ParameterFile" | Write-Host
|
||||
$templateFileProperties = (Get-Content (Join-Path "$here" "$ParameterFile") `
|
||||
| ConvertFrom-Json -ErrorAction SilentlyContinue) `
|
||||
| Get-Member -MemberType NoteProperty `
|
||||
| Sort-Object -Property Name `
|
||||
| ForEach-Object Name
|
||||
$templateFileProperties | Should Be $expectedProperties
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Context "Template and Parameter Compactibility" {
|
||||
|
||||
It "Is count of required parameters in template file equal or lesser than count of all parameters in parameters file" -TestCases $Modules {
|
||||
Param( $Module )
|
||||
|
||||
$requiredParametersInTemplateFile = (Get-Content "$($Module.Template)" `
|
||||
| ConvertFrom-Json -ErrorAction SilentlyContinue).Parameters.PSObject.Properties `
|
||||
| Where-Object -FilterScript { -not ($_.Value.PSObject.Properties.Name -eq "defaultValue") } `
|
||||
| Sort-Object -Property Name `
|
||||
| ForEach-Object Name
|
||||
ForEach ( $Parameter in $Module.Parameters ) {
|
||||
$allParametersInParametersFile = (Get-Content $Parameter `
|
||||
| ConvertFrom-Json -ErrorAction SilentlyContinue).Parameters.PSObject.Properties `
|
||||
| Sort-Object -Property Name `
|
||||
| ForEach-Object Name
|
||||
$requiredParametersInTemplateFile.Count | Should Not BeGreaterThan $allParametersInParametersFile.Count;
|
||||
}
|
||||
}
|
||||
|
||||
It "Has all parameters in parameters file existing in template file" -TestCases $Modules {
|
||||
Param( $Module )
|
||||
|
||||
$allParametersInTemplateFile = (Get-Content "$($Module.Template)" `
|
||||
| ConvertFrom-Json -ErrorAction SilentlyContinue).Parameters.PSObject.Properties `
|
||||
| Sort-Object -Property Name `
|
||||
| ForEach-Object Name
|
||||
ForEach ( $Parameter in $Module.Parameters ) {
|
||||
Write-Host "File analyzed: $Parameter";
|
||||
$allParametersInParametersFile = (Get-Content $Parameter `
|
||||
| ConvertFrom-Json -ErrorAction SilentlyContinue).Parameters.PSObject.Properties `
|
||||
| Sort-Object -Property Name `
|
||||
| ForEach-Object Name
|
||||
$result = @($allParametersInParametersFile| Where-Object {$allParametersInTemplateFile -notcontains $_});
|
||||
Write-Host "Invalid parameters: $(ConvertTo-Json $result)";
|
||||
@($allParametersInParametersFile| Where-Object {$allParametersInTemplateFile -notcontains $_}).Count | Should Be 0;
|
||||
}
|
||||
}
|
||||
|
||||
It "Has required parameters in template file existing in parameters file" -TestCases $Modules {
|
||||
Param( $Module )
|
||||
|
||||
$requiredParametersInTemplateFile = (Get-Content "$($Module.Template)" `
|
||||
| ConvertFrom-Json -ErrorAction SilentlyContinue).Parameters.PSObject.Properties `
|
||||
| Where-Object -FilterScript { -not ($_.Value.PSObject.Properties.Name -eq "defaultValue") } `
|
||||
| Sort-Object -Property Name `
|
||||
| ForEach-Object Name
|
||||
ForEach ( $Parameter in $Module.Parameters ) {
|
||||
$allParametersInParametersFile = (Get-Content $Parameter `
|
||||
| ConvertFrom-Json -ErrorAction SilentlyContinue).Parameters.PSObject.Properties `
|
||||
| Sort-Object -Property Name `
|
||||
| ForEach-Object Name
|
||||
@($requiredParametersInTemplateFile| Where-Object {$allParametersInParametersFile -notcontains $_}).Count | Should Be 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
#endregion
|
||||
}
|
|
@ -1,163 +0,0 @@
|
|||
<#
|
||||
.NOTES
|
||||
==============================================================================================
|
||||
Copyright(c) Microsoft Corporation. All rights reserved.
|
||||
|
||||
File: module.tests.ps1
|
||||
|
||||
Purpose: Pester - Test Key Vault ARM Templates
|
||||
|
||||
Version: 1.0.0.0 - 1st April 2019 - Azure Virtual Datacenter Development Team
|
||||
==============================================================================================
|
||||
|
||||
.SYNOPSIS
|
||||
This script contains functionality used to test Azure Key Vault ARM template synatax.
|
||||
|
||||
.DESCRIPTION
|
||||
This script contains functionality used to test Azure Key Vault ARM template synatax.
|
||||
|
||||
Deployment steps of the script are outlined below.
|
||||
1) Test Template File Syntax
|
||||
2) Test Parameter File Syntax
|
||||
3) Test Template and Parameter File Compactibility
|
||||
#>
|
||||
|
||||
#Requires -Version 5
|
||||
|
||||
#region Parameters
|
||||
|
||||
$here = Split-Path -Parent $MyInvocation.MyCommand.Path
|
||||
$here = Join-Path $here ".."
|
||||
$template = Split-Path -Leaf $here
|
||||
$TemplateFileTestCases = @()
|
||||
ForEach ( $File in (Get-ChildItem (Join-Path "$here" "RBAC" -AdditionalChildPath @("deploy.json")) -ErrorAction SilentlyContinue -Recurse | Select-Object -ExpandProperty Name) ) {
|
||||
$TemplateFileTestCases += @{ TemplateFile = $File }
|
||||
}
|
||||
$ParameterFileTestCases = @()
|
||||
ForEach ( $File in (Get-ChildItem (Join-Path "$here" "RBAC" -AdditionalChildPath @("*parameters.json")) -ErrorAction SilentlyContinue -Recurse | Select-Object -ExpandProperty Name) ) {
|
||||
$ParameterFileTestCases += @{ ParameterFile = Join-Path "RBAC" $File }
|
||||
}
|
||||
$Modules = @();
|
||||
ForEach ( $File in (Get-ChildItem (Join-Path "$here" "RBAC" -AdditionalChildPath @("deploy.json")) -ErrorAction SilentlyContinue ) ) {
|
||||
$Module = [PSCustomObject]@{
|
||||
'Template' = $null
|
||||
'Parameters' = $null
|
||||
}
|
||||
$Module.Template = $File.FullName;
|
||||
$Parameters = @();
|
||||
ForEach ( $ParameterFile in (Get-ChildItem (Join-Path "$here" "RBAC" -AdditionalChildPath @("*parameters.json")) -Recurse | Select-Object -ExpandProperty Name) ) {
|
||||
$Parameters += (Join-Path "$here" "RBAC" -AdditionalChildPath @("$ParameterFile") )
|
||||
}
|
||||
$Module.Parameters = $Parameters;
|
||||
$Modules += @{ Module = $Module };
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
if ($null -ne $TemplateFileTestCases -and
|
||||
$TemplateFileTestCases.Count -gt 0) {
|
||||
|
||||
#region Run Pester Test Script
|
||||
Describe "Template: $template - Key Vault" -Tags Unit {
|
||||
|
||||
Context "Template File Syntax" {
|
||||
|
||||
It "Has a JSON template file" -TestCases $TemplateFileTestCases {
|
||||
(Join-Path "$here" "deploy.json") | Should Exist
|
||||
}
|
||||
|
||||
It "Converts from JSON and has the expected properties" -TestCases $TemplateFileTestCases {
|
||||
Param( $TemplateFile )
|
||||
Write-Host "TF: $TemplateFile"
|
||||
$expectedProperties = '$schema',
|
||||
'contentVersion',
|
||||
'parameters',
|
||||
'variables',
|
||||
'resources',
|
||||
'outputs' | Sort-Object
|
||||
$templateProperties = (Get-Content (Join-Path "$here" "$TemplateFile") `
|
||||
| ConvertFrom-Json -ErrorAction SilentlyContinue) `
|
||||
| Get-Member -MemberType NoteProperty `
|
||||
| Sort-Object -Property Name `
|
||||
| ForEach-Object Name
|
||||
$templateProperties | Should Be $expectedProperties
|
||||
}
|
||||
}
|
||||
|
||||
Context "Parameter File Syntax" {
|
||||
|
||||
It "Parameter file does not contains the expected properties" -TestCases $ParameterFileTestCases {
|
||||
Param( $ParameterFile )
|
||||
$expectedProperties = '$schema',
|
||||
'contentVersion',
|
||||
'parameters' | Sort-Object
|
||||
Write-Host $ParameterFile
|
||||
Join-Path "$here" "$ParameterFile" | Write-Host
|
||||
$templateFileProperties = (Get-Content (Join-Path "$here" "$ParameterFile") `
|
||||
| ConvertFrom-Json -ErrorAction SilentlyContinue) `
|
||||
| Get-Member -MemberType NoteProperty `
|
||||
| Sort-Object -Property Name `
|
||||
| ForEach-Object Name
|
||||
$templateFileProperties | Should Be $expectedProperties
|
||||
}
|
||||
}
|
||||
|
||||
Context "Template and Parameter Compactibility" {
|
||||
|
||||
It "Is count of required parameters in template file equal or lesser than count of all parameters in parameters file" -TestCases $Modules {
|
||||
Param( $Module )
|
||||
|
||||
$requiredParametersInTemplateFile = (Get-Content "$($Module.Template)" `
|
||||
| ConvertFrom-Json -ErrorAction SilentlyContinue).Parameters.PSObject.Properties `
|
||||
| Where-Object -FilterScript { -not ($_.Value.PSObject.Properties.Name -eq "defaultValue") } `
|
||||
| Sort-Object -Property Name `
|
||||
| ForEach-Object Name
|
||||
ForEach ( $Parameter in $Module.Parameters ) {
|
||||
$allParametersInParametersFile = (Get-Content $Parameter `
|
||||
| ConvertFrom-Json -ErrorAction SilentlyContinue).Parameters.PSObject.Properties `
|
||||
| Sort-Object -Property Name `
|
||||
| ForEach-Object Name
|
||||
$requiredParametersInTemplateFile.Count | Should Not BeGreaterThan $allParametersInParametersFile.Count;
|
||||
}
|
||||
}
|
||||
|
||||
It "Has all parameters in parameters file existing in template file" -TestCases $Modules {
|
||||
Param( $Module )
|
||||
|
||||
$allParametersInTemplateFile = (Get-Content "$($Module.Template)" `
|
||||
| ConvertFrom-Json -ErrorAction SilentlyContinue).Parameters.PSObject.Properties `
|
||||
| Sort-Object -Property Name `
|
||||
| ForEach-Object Name
|
||||
ForEach ( $Parameter in $Module.Parameters ) {
|
||||
Write-Host "File analyzed: $Parameter";
|
||||
$allParametersInParametersFile = (Get-Content $Parameter `
|
||||
| ConvertFrom-Json -ErrorAction SilentlyContinue).Parameters.PSObject.Properties `
|
||||
| Sort-Object -Property Name `
|
||||
| ForEach-Object Name
|
||||
$result = @($allParametersInParametersFile| Where-Object {$allParametersInTemplateFile -notcontains $_});
|
||||
Write-Host "Invalid parameters: $(ConvertTo-Json $result)";
|
||||
@($allParametersInParametersFile| Where-Object {$allParametersInTemplateFile -notcontains $_}).Count | Should Be 0;
|
||||
}
|
||||
}
|
||||
|
||||
It "Has required parameters in template file existing in parameters file" -TestCases $Modules {
|
||||
Param( $Module )
|
||||
|
||||
$requiredParametersInTemplateFile = (Get-Content "$($Module.Template)" `
|
||||
| ConvertFrom-Json -ErrorAction SilentlyContinue).Parameters.PSObject.Properties `
|
||||
| Where-Object -FilterScript { -not ($_.Value.PSObject.Properties.Name -eq "defaultValue") } `
|
||||
| Sort-Object -Property Name `
|
||||
| ForEach-Object Name
|
||||
ForEach ( $Parameter in $Module.Parameters ) {
|
||||
$allParametersInParametersFile = (Get-Content $Parameter `
|
||||
| ConvertFrom-Json -ErrorAction SilentlyContinue).Parameters.PSObject.Properties `
|
||||
| Sort-Object -Property Name `
|
||||
| ForEach-Object Name
|
||||
@($requiredParametersInTemplateFile| Where-Object {$allParametersInParametersFile -notcontains $_}).Count | Should Be 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
#endregion
|
||||
}
|
|
@ -0,0 +1,18 @@
|
|||
{
|
||||
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentParameters.json#",
|
||||
"contentVersion": "1.0.0.0",
|
||||
"parameters": {
|
||||
"eventHubName": {
|
||||
"value": "testeventHubName"
|
||||
},
|
||||
"namespaceName": {
|
||||
"value": "testnamespaceName"
|
||||
},
|
||||
"diagnosticStorageAccountId": {
|
||||
"value": "/subscriptions/00000000/resourceGroups/resourceGroup"
|
||||
},
|
||||
"logAnalyticsWorkspaceId": {
|
||||
"value": "/subscriptions/00000000/resourceGroups/resourceGroup"
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,9 +0,0 @@
|
|||
# Event Hub
|
||||
|
||||
This template deploys Event Hub
|
||||
|
||||
## Deployed Resources
|
||||
|
||||
The following resources are deployed as part of this code block.
|
||||
|
||||
+ **Event Hub**
|
|
@ -1,46 +1,98 @@
|
|||
{
|
||||
"$schema": "http://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
|
||||
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
|
||||
"contentVersion": "1.0.0.0",
|
||||
"parameters": {
|
||||
"eventHubName": {
|
||||
"type": "string",
|
||||
"metadata": {
|
||||
"description": "Optional. Name of the event hub within the namespace to which logs are streamed. Without this, an event hub is created for each log category."
|
||||
}
|
||||
},
|
||||
"eventHubSku": {
|
||||
"type": "string",
|
||||
"allowedValues": [ "Basic", "Standard" ],
|
||||
"defaultValue": "Standard",
|
||||
"metadata": {
|
||||
"description": "Required. The messaging tier for service Bus namespace"
|
||||
}
|
||||
},
|
||||
"namespaceName": {
|
||||
"type": "string",
|
||||
"metadata": {
|
||||
"description": "Optional. Name of EventHub namespace"
|
||||
"description": "Required. The name of the EventHub namespace"
|
||||
}
|
||||
},
|
||||
"eventHubName": {
|
||||
"type": "string",
|
||||
"metadata": {
|
||||
"description": "Required. The name of the EventHub"
|
||||
}
|
||||
},
|
||||
"messageRetentionInDays": {
|
||||
"type": "int",
|
||||
"defaultValue": 1,
|
||||
"minValue": 1,
|
||||
"maxValue": 7,
|
||||
"metadata": {
|
||||
"description": "Optional. How long to retain the data in EventHub"
|
||||
}
|
||||
},
|
||||
"partitionCount": {
|
||||
"type": "int",
|
||||
"defaultValue": 4,
|
||||
"minValue": 2,
|
||||
"maxValue": 32,
|
||||
"metadata": {
|
||||
"description": "Optional. Number of partitions chosen"
|
||||
}
|
||||
},
|
||||
"skuName": {
|
||||
"type": "string",
|
||||
"defaultValue": "Standard",
|
||||
"metadata": {
|
||||
"description": "Optional. EventHub Plan sku name"
|
||||
}
|
||||
},
|
||||
"skuTier": {
|
||||
"type": "string",
|
||||
"defaultValue": "Standard",
|
||||
"metadata": {
|
||||
"description": "Optional. EventHub Plan account tier"
|
||||
}
|
||||
},
|
||||
"skuCapacity": {
|
||||
"type": "int",
|
||||
"allowedValues": [ 1, 2, 4 ],
|
||||
"defaultValue": 1,
|
||||
"metadata": {
|
||||
"description": "Optional. MessagingUnits for premium namespace"
|
||||
"description": "Optional. EventHub Plan scale-out capacity of the resource"
|
||||
}
|
||||
},
|
||||
"consumerGroupName": {
|
||||
"location": {
|
||||
"type": "string",
|
||||
"defaultValue": "[resourceGroup().location]",
|
||||
"metadata": {
|
||||
"description": "Optional. Name of Consumer Group"
|
||||
"description": "Optional. Location for all Resources"
|
||||
}
|
||||
},
|
||||
"authorizationRulesRootManageSharedAccessKeyName": {
|
||||
"defaultValue": "RootManageSharedAccessKey",
|
||||
"diagnosticStorageAccountId": {
|
||||
"type": "string",
|
||||
"metadata": {
|
||||
"description": "Optional. Authorization Rules Root Managed Shared Access Key."
|
||||
"description": "Required. Resource identifier of the Diagnostic Storage Account"
|
||||
}
|
||||
},
|
||||
"logAnalyticsWorkspaceId": {
|
||||
"type": "string",
|
||||
"metadata": {
|
||||
"description": "Reguired. Resource identifier of Log Analytics Workspace"
|
||||
}
|
||||
},
|
||||
"logsRetentionInDays": {
|
||||
"type": "int",
|
||||
"defaultValue": 30,
|
||||
"minValue": 0,
|
||||
"maxValue": 365,
|
||||
"metadata": {
|
||||
"description": "Optional. Specifies the number of days that logs will be kept for, a value of 0 will retain data indefinitely"
|
||||
}
|
||||
},
|
||||
"cuaId": {
|
||||
"type": "string",
|
||||
"defaultValue": "",
|
||||
"metadata": {
|
||||
"description": "Optional. Customer Usage Attribution id (GUID). This GUID must be previously registered"
|
||||
}
|
||||
},
|
||||
"tagValues": {
|
||||
"type": "object",
|
||||
"defaultValue": "",
|
||||
"metadata": {
|
||||
"description": "Optional. Azure Resource Tags object"
|
||||
}
|
||||
},
|
||||
"diagnosticStorageAccountId": {
|
||||
|
@ -80,189 +132,215 @@
|
|||
}
|
||||
},
|
||||
"variables": {
|
||||
"deployServiceEndpoint": "[not(empty(parameters('networkAcls')))]",
|
||||
"virtualNetworkRules": {
|
||||
"copy": [
|
||||
{
|
||||
"name": "virtualNetworkRules",
|
||||
"count": "[if(not(variables('deployServiceEndpoint')), 0, length(parameters('networkAcls').virtualNetworkRules))]",
|
||||
"input": {
|
||||
"subnet": {
|
||||
"id": "[concat(parameters('vNetId'), '/subnets/', parameters('networkAcls').virtualNetworkRules[copyIndex('virtualNetworkRules')].subnet)]"
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"networkAcls": {
|
||||
"bypass": "[if(not(variables('deployServiceEndpoint')), json('null'), parameters('networkAcls').bypass)]",
|
||||
"defaultAction": "[if(not(variables('deployServiceEndpoint')), json('null'), parameters('networkAcls').defaultAction)]",
|
||||
"virtualNetworkRules": "[if(not(variables('deployServiceEndpoint')), json('null'), if(equals(length(parameters('networkAcls').virtualNetworkRules), 0), variables('emptyArray'), variables('virtualNetworkRules').virtualNetworkRules))]",
|
||||
"ipRules": "[if(not(variables('deployServiceEndpoint')), json('null'), if(equals(length(parameters('networkAcls').ipRules), 0), variables('emptyArray'), parameters('networkAcls').ipRules))]"
|
||||
},
|
||||
"emptyArray": []
|
||||
"namespaceName": "[parameters('namespaceName')]",
|
||||
"namespaceResourceId": "[resourceId('Microsoft.EventHub/Namespaces',parameters('namespaceName'))]",
|
||||
"namespaceApiVersion": "2017-04-01",
|
||||
"diagnosticStorageAccountId": "[parameters('diagnosticStorageAccountId')]",
|
||||
"diagnosticWorkspaceId": "[parameters('logAnalyticsWorkspaceId')]",
|
||||
"defaultSASKeyName": "RootManageSharedAccessKey",
|
||||
"authRuleResourceId": "[resourceId('Microsoft.EventHub/namespaces/authorizationRules', parameters('namespaceName'), variables('defaultSASKeyName'))]",
|
||||
"pidName": "[concat('pid-', parameters('cuaId'))]"
|
||||
},
|
||||
"resources": [
|
||||
{
|
||||
"apiVersion": "2017-04-01",
|
||||
"name": "[parameters('namespaceName')]",
|
||||
"condition": "[not(empty(parameters('cuaId')))]",
|
||||
"type": "Microsoft.Resources/deployments",
|
||||
"apiVersion": "2018-02-01",
|
||||
"name": "[variables('pidName')]",
|
||||
"properties": {
|
||||
"mode": "Incremental",
|
||||
"template": {
|
||||
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
|
||||
"contentVersion": "1.0.0.0",
|
||||
"resources": []
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "Microsoft.EventHub/namespaces",
|
||||
"location": "[resourceGroup().location]",
|
||||
"apiVersion": "[variables('namespaceApiVersion')]",
|
||||
"name": "[parameters('namespaceName')]",
|
||||
"location": "[parameters('location')]",
|
||||
"tags": "[if(empty(parameters('tagValues')), json('null'), parameters('tagValues'))]",
|
||||
"sku": {
|
||||
"name": "[parameters('eventHubSku')]",
|
||||
"tier": "[parameters('eventHubSku')]",
|
||||
"name": "[parameters('skuName')]",
|
||||
"tier": "[parameters('skuTier')]",
|
||||
"capacity": "[parameters('skuCapacity')]"
|
||||
},
|
||||
"tags": {
|
||||
"displayName": "[parameters('namespaceName')]"
|
||||
},
|
||||
"properties": {
|
||||
"zoneRedundant": false,
|
||||
"isAutoInflateEnabled": false,
|
||||
"maximumThroughputUnits": 0,
|
||||
"kafkaEnabled": false
|
||||
},
|
||||
"resources": [
|
||||
{
|
||||
"apiVersion": "2017-04-01",
|
||||
"name": "[parameters('eventHubName')]",
|
||||
"type": "eventhubs",
|
||||
"type": "Microsoft.EventHub/namespaces/providers/diagnosticSettings",
|
||||
"apiVersion": "2017-05-01-preview",
|
||||
"name": "[concat(variables('namespaceName'), '/','Microsoft.Insights/service')]",
|
||||
"location": "[parameters('location')]",
|
||||
"dependsOn": [
|
||||
"[concat('Microsoft.EventHub/namespaces/', parameters('namespaceName'))]"
|
||||
],
|
||||
"properties": {},
|
||||
"resources": [
|
||||
{
|
||||
"apiVersion": "2017-04-01",
|
||||
"name": "[parameters('consumerGroupName')]",
|
||||
"type": "consumergroups",
|
||||
"dependsOn": [ "[parameters('eventHubName')]" ],
|
||||
"properties": {
|
||||
"userMetadata": "User Metadata"
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "Microsoft.EventHub/namespaces/NetworkRuleSets",
|
||||
"apiVersion": "2018-01-01-preview",
|
||||
"name": "[concat(parameters('namespaceName'), '/default')]",
|
||||
"condition": "[not(empty(parameters('vNetId')))]",
|
||||
"location": "[resourceGroup().location]",
|
||||
"dependsOn": [
|
||||
"[concat('Microsoft.EventHub/namespaces/', parameters('namespaceName'))]"
|
||||
"[variables('namespaceResourceId')]"
|
||||
],
|
||||
"properties": {
|
||||
"defaultAction": "[variables('networkAcls').defaultAction]",
|
||||
"virtualNetworkRules": "[variables('networkAcls').virtualNetworkRules]",
|
||||
"ipRules": "[variables('networkAcls').ipRules]"
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "Microsoft.EventHub/namespaces/providers/diagnosticsettings",
|
||||
"apiVersion": "2016-09-01",
|
||||
"name": "[concat(parameters('namespaceName'), '/Microsoft.Insights/service')]",
|
||||
"location": "[resourceGroup().location]",
|
||||
"dependsOn": [
|
||||
"[concat('Microsoft.EventHub/namespaces/', parameters('namespaceName'))]"
|
||||
"storageAccountId": "[variables('diagnosticStorageAccountId')]",
|
||||
"workspaceId": "[variables('diagnosticWorkspaceId')]",
|
||||
"metrics": [
|
||||
{
|
||||
"category": "AllMetrics",
|
||||
"enabled": true,
|
||||
"retentionPolicy": {
|
||||
"days": "[parameters('logsRetentionInDays')]",
|
||||
"enabled": true
|
||||
}
|
||||
}
|
||||
],
|
||||
"properties": {
|
||||
"storageAccountId": "[parameters('diagnosticStorageAccountId')]",
|
||||
"workspaceId": "[parameters('workspaceId')]",
|
||||
"logs": [
|
||||
{
|
||||
"category": "ArchiveLogs",
|
||||
"enabled": true,
|
||||
"retentionPolicy": {
|
||||
"enabled": true,
|
||||
"days": "[parameters('logsRetentionInDays')]"
|
||||
}
|
||||
},
|
||||
{
|
||||
"category": "OperationalLogs",
|
||||
"enabled": true,
|
||||
"retentionPolicy": {
|
||||
"enabled": true,
|
||||
"days": "[parameters('logsRetentionInDays')]"
|
||||
}
|
||||
},
|
||||
{
|
||||
"category": "AutoScaleLogs",
|
||||
"enabled": true,
|
||||
"retentionPolicy": {
|
||||
"enabled": true,
|
||||
"days": "[parameters('logsRetentionInDays')]"
|
||||
}
|
||||
},
|
||||
{
|
||||
"category": "KafkaCoordinatorLogs",
|
||||
"enabled": true,
|
||||
"retentionPolicy": {
|
||||
"enabled": true,
|
||||
"days": "[parameters('logsRetentionInDays')]"
|
||||
}
|
||||
},
|
||||
{
|
||||
"category": "EventHubVNetConnectionEvent",
|
||||
"enabled": true,
|
||||
"retentionPolicy": {
|
||||
"enabled": true,
|
||||
"days": "[parameters('logsRetentionInDays')]"
|
||||
}
|
||||
},
|
||||
{
|
||||
"category": "CustomerManagedKeyUserLogs",
|
||||
"enabled": true,
|
||||
"retentionPolicy": {
|
||||
"enabled": true,
|
||||
"days": "[parameters('logsRetentionInDays')]"
|
||||
}
|
||||
}
|
||||
],
|
||||
"metrics": [
|
||||
{
|
||||
"category": "AllMetrics",
|
||||
"enabled": true,
|
||||
"retentionPolicy": {
|
||||
"days": "[parameters('logsRetentionInDays')]",
|
||||
"enabled": true
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
"logs": [
|
||||
{
|
||||
"category": "ArchiveLogs",
|
||||
"enabled": true,
|
||||
"retentionPolicy": {
|
||||
"days": "[parameters('logsRetentionInDays')]",
|
||||
"enabled": true
|
||||
}
|
||||
},
|
||||
{
|
||||
"category": "OperationalLogs",
|
||||
"enabled": true,
|
||||
"retentionPolicy": {
|
||||
"days": "[parameters('logsRetentionInDays')]",
|
||||
"enabled": true
|
||||
}
|
||||
},
|
||||
{
|
||||
"category": "AutoScaleLogs",
|
||||
"enabled": true,
|
||||
"retentionPolicy": {
|
||||
"days": "[parameters('logsRetentionInDays')]",
|
||||
"enabled": true
|
||||
}
|
||||
},
|
||||
{
|
||||
"category": "KafkaCoordinatorLogs",
|
||||
"enabled": true,
|
||||
"retentionPolicy": {
|
||||
"days": "[parameters('logsRetentionInDays')]",
|
||||
"enabled": true
|
||||
}
|
||||
},
|
||||
{
|
||||
"category": "EventHubVNetConnectionEvent",
|
||||
"enabled": true,
|
||||
"retentionPolicy": {
|
||||
"days": "[parameters('logsRetentionInDays')]",
|
||||
"enabled": true
|
||||
}
|
||||
},
|
||||
{
|
||||
"category": "CustomerManagedKeyUserLogs",
|
||||
"enabled": true,
|
||||
"retentionPolicy": {
|
||||
"days": "[parameters('logsRetentionInDays')]",
|
||||
"enabled": true
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "Microsoft.EventHub/namespaces/AuthorizationRules",
|
||||
"name": "[concat(parameters('namespaceName'), '/', parameters('authorizationRulesRootManageSharedAccessKeyName'))]",
|
||||
"apiVersion": "2017-04-01",
|
||||
"location": "[resourceGroup().location]",
|
||||
"scale": null,
|
||||
"apiVersion": "[variables('namespaceApiVersion')]",
|
||||
"name": "[concat(parameters('namespaceName'),'/RootManageSharedAccessKey')]",
|
||||
"location": "[parameters('location')]",
|
||||
"dependsOn": [
|
||||
"[variables('namespaceResourceId')]"
|
||||
],
|
||||
"properties": {
|
||||
"rights": [
|
||||
"Listen",
|
||||
"Manage",
|
||||
"Send"
|
||||
]
|
||||
},
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "Microsoft.EventHub/namespaces/AuthorizationRules",
|
||||
"apiVersion": "[variables('namespaceApiVersion')]",
|
||||
"name": "[concat(parameters('namespaceName'),'/SendListenAccess')]",
|
||||
"location": "[parameters('location')]",
|
||||
"dependsOn": [
|
||||
"[resourceId('Microsoft.EventHub/namespaces', parameters('namespaceName'))]"
|
||||
]
|
||||
"[variables('namespaceResourceId')]"
|
||||
],
|
||||
"properties": {
|
||||
"rights": [
|
||||
"Listen",
|
||||
"Send"
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "Microsoft.EventHub/namespaces/eventhubs",
|
||||
"apiVersion": "[variables('namespaceApiVersion')]",
|
||||
"name": "[concat(parameters('namespaceName'), '/',parameters('eventHubName'))]",
|
||||
"location": "[parameters('location')]",
|
||||
"dependsOn": [
|
||||
"[variables('namespaceResourceId')]"
|
||||
],
|
||||
"properties": {
|
||||
"messageRetentionInDays": "[parameters('messageRetentionInDays')]",
|
||||
"partitionCount": "[parameters('partitionCount')]",
|
||||
"status": "Active"
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "Microsoft.EventHub/namespaces/eventhubs/consumergroups",
|
||||
"apiVersion": "[variables('namespaceApiVersion')]",
|
||||
"name": "[concat(parameters('namespaceName'), '/',parameters('eventHubName'), '/$Default')]",
|
||||
"location": "[parameters('location')]",
|
||||
"dependsOn": [
|
||||
"[resourceId('Microsoft.EventHub/namespaces/eventhubs', parameters('namespaceName'), parameters('eventHubName'))]",
|
||||
"[variables('namespaceResourceId')]"
|
||||
],
|
||||
"properties": {}
|
||||
}
|
||||
],
|
||||
"outputs": {
|
||||
"diagnosticEventHubName": {
|
||||
"namespaceName": {
|
||||
"type": "string",
|
||||
"value": "[parameters('eventHubName')]"
|
||||
"value": "[variables('namespaceName')]",
|
||||
"metadata": {
|
||||
"description": "The Name of the EventHub Namespace"
|
||||
}
|
||||
},
|
||||
"diagnosticsEventHubAuthRuleId": {
|
||||
"namespaceResourceId": {
|
||||
"type": "string",
|
||||
"value": "[resourceId('Microsoft.EventHub/namespaces/AuthorizationRules', parameters('namespaceName'), parameters('authorizationRulesRootManageSharedAccessKeyName'))]"
|
||||
"value": "[variables('namespaceResourceId')]",
|
||||
"metadata": {
|
||||
"description": "The Resource Id of the EventHub Namespace"
|
||||
}
|
||||
},
|
||||
"diagnosticsResourceGroupId": {
|
||||
"namespaceResourceGroup": {
|
||||
"type": "string",
|
||||
"value": "[resourceGroup().id]"
|
||||
"value": "[resourceGroup().name]",
|
||||
"metadata": {
|
||||
"description": "The name of the Resource Group with the EventHub Namespace"
|
||||
}
|
||||
},
|
||||
"diagnosticsResourceGroupName": {
|
||||
"namespaceConnectionString": {
|
||||
"type": "string",
|
||||
"value": "[resourceGroup().name]"
|
||||
"value": "[listkeys(variables('authRuleResourceId'), variables('namespaceApiVersion')).primaryConnectionString]",
|
||||
"metadata": {
|
||||
"description": "The connection string of the EventHub Namespace"
|
||||
}
|
||||
},
|
||||
"sharedAccessPolicyPrimaryKey": {
|
||||
"type": "string",
|
||||
"value": "[listkeys(variables('authRuleResourceId'), variables('namespaceApiVersion')).primaryKey]",
|
||||
"metadata": {
|
||||
"description": "The shared access policy primary key for the EventHub Namespace"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,53 @@
|
|||
# EventHub Namespace
|
||||
|
||||
This module deploys EventHub Namespace.
|
||||
|
||||
## Resources
|
||||
|
||||
The following Resources are deployed.
|
||||
|
||||
+ **Microsoft.EventHub/namespaces**
|
||||
+ **Microsoft.EventHub/namespaces/providers/diagnosticSettings**
|
||||
+ **Microsoft.EventHub/namespaces/AuthorizationRules**
|
||||
+ **Microsoft.EventHub/namespaces/eventhubs**
|
||||
+ **Microsoft.EventHub/namespaces/eventhubs/consumergroups**
|
||||
|
||||
## Parameters
|
||||
|
||||
| Parameter Name | Default Value | Required | Description |
|
||||
| :- | :- | :- |:- |
|
||||
| `namespaceName` || **Required** | The name of the EventHub namespace
|
||||
| `eventHubName` || **Required** | The name of the EventHub
|
||||
| `messageRetentionInDays` | 1 | **Optional** | How long to retain the data in EventHub
|
||||
| `partitionCount` | 4 | **Optional** | Number of partitions chosen
|
||||
| `skuName` || **Optional** | EventHub Plan sku name
|
||||
| `skuTier` || **Optional** | EventHub Plan account tier
|
||||
| `skuCapacity` || **Optional** | EventHub Plan scale-out capacity of the resource
|
||||
| `location` | resourceGroup().location | **Optional** | Location for all Resources
|
||||
| `diagnosticStorageAccountId` || **Required** | Resource identifier of the Diagnostic Storage Account
|
||||
| `logAnalyticsWorkspaceId` || **Required** | Resource identifier of Log Analytics Workspace
|
||||
| `logsRetentionInDays` | 30 |**Optional** | Specifies the number of days that logs will be kept for, a value of 0 will retain data indefinitely
|
||||
| `cuaId` || **Optional** | Customer Usage Attribution Id (GUID). This GUID must be previously registered
|
||||
| `tagValues` || **Optional** | Optional. Azure Resource Tags object
|
||||
|
||||
## Outputs
|
||||
|
||||
| Output Name | Description |
|
||||
| :- | :- |
|
||||
| `namespaceName` | EventHub Namespace Name output parameter
|
||||
| `namespaceResourceId` | EventHub Namespace ResourceId output parameter
|
||||
| `namespaceResourceGroup` | EventHub Namespace ResourceGroup output parameter
|
||||
| `namespaceConnectionString` | EventHub Namespace Connection String
|
||||
| `sharedAccessPolicyPrimaryKey` | EventHub Namespace Shared Access Policy Primary Key
|
||||
|
||||
## Scripts
|
||||
|
||||
+ There is no Scripts for this Module
|
||||
|
||||
## Considerations
|
||||
|
||||
+ There is no deployment considerations for this Module
|
||||
|
||||
## Additional resources
|
||||
|
||||
+ [Microsoft EventHub template reference](https://docs.microsoft.com/en-us/azure/templates/microsoft.eventhub/allversions)
|
|
@ -0,0 +1,35 @@
|
|||
name: $(Build.DefinitionName)-$(SourceBranchName)-$(Date:yyyyMMdd).$(Rev:rr)
|
||||
|
||||
variables:
|
||||
ModuleName: MachineLearning
|
||||
ModuleVersion: 2.0
|
||||
RepoName: azure-devops
|
||||
ModulePath: modules/$(ModuleName)/$(ModuleVersion)
|
||||
ArtifactName: contents
|
||||
|
||||
resources:
|
||||
repositories:
|
||||
- repository: main
|
||||
type: git
|
||||
name: '$(RepoName)'
|
||||
|
||||
trigger:
|
||||
branches:
|
||||
include:
|
||||
- master
|
||||
- '*'
|
||||
paths:
|
||||
include:
|
||||
- modules/MachineLearning/2.0
|
||||
|
||||
jobs:
|
||||
- job: BuildModule
|
||||
displayName: Build Module
|
||||
workspace:
|
||||
clean: all
|
||||
|
||||
steps:
|
||||
- template: /azure-devops/ci/buildmodule.yaml
|
||||
parameters:
|
||||
ModulePath: $(ModulePath)
|
||||
ArtifactName: $(ArtifactName)
|
|
@ -0,0 +1,171 @@
|
|||
<#
|
||||
.NOTES
|
||||
==============================================================================================
|
||||
Copyright(c) Microsoft Corporation. All rights reserved.
|
||||
|
||||
Microsoft Consulting Services - AzureCAT - VDC Toolkit (v2.0)
|
||||
|
||||
File: module.tests.ps1
|
||||
|
||||
Purpose: Pester - Test Machine Learning ARM Templates
|
||||
|
||||
Version: 2.0.0.0 - 1st September 2019 - Azure Virtual Datacenter Development Team
|
||||
==============================================================================================
|
||||
|
||||
.SYNOPSIS
|
||||
This script contains functionality used to test Machine Learning ARM template synatax.
|
||||
|
||||
.DESCRIPTION
|
||||
This script contains functionality used to test Machine Learning ARM template synatax.
|
||||
|
||||
Deployment steps of the script are outlined below.
|
||||
1) Test Template File Syntax
|
||||
2) Test Parameter File Syntax
|
||||
3) Test Template and Parameter File Compactibility
|
||||
#>
|
||||
|
||||
#Requires -Version 5
|
||||
|
||||
#region Parameters
|
||||
$here = Split-Path -Parent $MyInvocation.MyCommand.Path
|
||||
$here = Join-Path -Path $here -ChildPath ".."
|
||||
$template = Split-Path -Leaf $here
|
||||
|
||||
#region - Template File Test Cases
|
||||
$templateFileTestCases = @()
|
||||
ForEach ($file in (Get-ChildItem (Join-Path -Path "$here" -ChildPath "deploy.json") -Recurse | Select-Object -ExpandProperty Name)) {
|
||||
$templateFileTestCases += @{ TemplateFile = $file }
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region - Parameter File Test Cases
|
||||
$parameterFileTestCases = @()
|
||||
ForEach ($file in (Get-ChildItem (Join-Path -Path "$here" -ChildPath "Tests" -AdditionalChildPath @("*parameters.json")) -Recurse -ErrorAction SilentlyContinue | Select-Object -ExpandProperty Name)) {
|
||||
$parameterFileTestCases += @{ ParameterFile = Join-Path -Path "Tests" $file }
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region - Module Test Cases
|
||||
$modules = @()
|
||||
ForEach ($file in (Get-ChildItem (Join-Path -Path "$here" -ChildPath "deploy.json"))) {
|
||||
$module = [PSCustomObject]@{
|
||||
'Template' = $null
|
||||
'Parameters' = $null
|
||||
}
|
||||
$module.Template = $file.FullName
|
||||
|
||||
$parameters = @()
|
||||
ForEach ($parameterFile in (Get-ChildItem (Join-Path -Path "$here" -ChildPath "Tests" -AdditionalChildPath @("*parameters.json")) -Recurse -ErrorAction SilentlyContinue | Select-Object -ExpandProperty Name)) {
|
||||
$parameters += (Join-Path -Path "$here" -ChildPath "Tests" -AdditionalChildPath @("$ParameterFile"))
|
||||
}
|
||||
$Module.Parameters = $Parameters
|
||||
$Modules += @{Module = $Module}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
#region - Run Pester Test Script
|
||||
Describe "Template: $template - Machine Learning" -Tags -Unit {
|
||||
|
||||
#region - Template File Syntax
|
||||
Context "Template File Syntax" {
|
||||
|
||||
It "Has a JSON template file" {
|
||||
(Join-Path -Path "$here" -ChildPath "deploy.json") | Should -Exist
|
||||
}
|
||||
|
||||
It "Converts from JSON and has the expected properties" -TestCases $templateFileTestCases {
|
||||
param($templateFile)
|
||||
$expectedProperties = '$schema',
|
||||
'contentVersion',
|
||||
'parameters',
|
||||
'variables',
|
||||
'resources',
|
||||
'outputs' | Sort-Object
|
||||
$templateProperties = (Get-Content (Join-Path -Path "$here" -ChildPath "$templateFile") `
|
||||
| ConvertFrom-Json -ErrorAction SilentlyContinue) `
|
||||
| Get-Member -MemberType NoteProperty `
|
||||
| Sort-Object -Property Name `
|
||||
| ForEach-Object Name
|
||||
$templateProperties | Should -Be $expectedProperties
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region - Parameter File Syntax
|
||||
Context "Parameter File Syntax" {
|
||||
|
||||
It "Parameter file does not contains the expected properties" -TestCases $parameterFileTestCases {
|
||||
param($parameterFile)
|
||||
$expectedProperties = '$schema',
|
||||
'contentVersion',
|
||||
'parameters' | Sort-Object
|
||||
Write-Output $parameterFile
|
||||
Join-Path -Path "$here" -ChildPath "$parameterFile" | Write-Output
|
||||
$templateFileProperties = (Get-Content (Join-Path -Path "$here" -ChildPath "$parameterFile") `
|
||||
| ConvertFrom-Json -ErrorAction SilentlyContinue) `
|
||||
| Get-Member -MemberType NoteProperty `
|
||||
| Sort-Object -Property Name `
|
||||
| ForEach-Object Name
|
||||
$templateFileProperties | Should -Be $expectedProperties
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region - Template and Parameter Compactibility
|
||||
Context "Template and Parameter Compactibility" {
|
||||
|
||||
It "Is count of required parameters in template file equal or lesser than count of all parameters in parameters file" -TestCases $modules {
|
||||
param($module)
|
||||
$requiredParametersInTemplateFile = (Get-Content "$($module.Template)" `
|
||||
| ConvertFrom-Json -ErrorAction SilentlyContinue).Parameters.PSObject.Properties `
|
||||
| Where-Object -FilterScript { -not ($psitem.Value.PSObject.Properties.Name -eq "defaultValue")} `
|
||||
| Sort-Object -Property Name `
|
||||
| ForEach-Object Name
|
||||
ForEach ( $parameter in $module.Parameters ) {
|
||||
$allParametersInParametersFile = (Get-Content $parameter `
|
||||
| ConvertFrom-Json -ErrorAction SilentlyContinue).Parameters.PSObject.Properties `
|
||||
| Sort-Object -Property Name `
|
||||
| ForEach-Object Name
|
||||
$requiredParametersInTemplateFile.Count | Should -Not -BeGreaterThan $allParametersInParametersFile.Count
|
||||
}
|
||||
}
|
||||
|
||||
It "Has all parameters in parameters file existing in template file" -TestCases $modules {
|
||||
param($module)
|
||||
$allParametersInTemplateFile = (Get-Content "$($module.Template)" `
|
||||
| ConvertFrom-Json -ErrorAction SilentlyContinue).Parameters.PSObject.Properties `
|
||||
| Sort-Object -Property Name `
|
||||
| ForEach-Object Name
|
||||
ForEach ($parameter in $module.Parameters) {
|
||||
Write-Output "File analyzed: $parameter"
|
||||
$allParametersInParametersFile = (Get-Content $parameter `
|
||||
| ConvertFrom-Json -ErrorAction SilentlyContinue).Parameters.PSObject.Properties `
|
||||
| Sort-Object -Property Name `
|
||||
| ForEach-Object Name
|
||||
$result = @($allParametersInParametersFile| Where-Object {$allParametersInTemplateFile -notcontains $psitem})
|
||||
Write-Output "Invalid parameters: $(ConvertTo-Json $result)"
|
||||
@($allParametersInParametersFile| Where-Object {$allParametersInTemplateFile -notcontains $psitem}).Count | Should -Be 0
|
||||
}
|
||||
}
|
||||
|
||||
It "Has required parameters in template file existing in parameters file" -TestCases $modules {
|
||||
param($module)
|
||||
$requiredParametersInTemplateFile = (Get-Content "$($module.Template)" `
|
||||
| ConvertFrom-Json -ErrorAction SilentlyContinue).Parameters.PSObject.Properties `
|
||||
| Where-Object -FilterScript { -not ($psitem.Value.PSObject.Properties.Name -eq "defaultValue") } `
|
||||
| Sort-Object -Property Name `
|
||||
| ForEach-Object Name
|
||||
ForEach ($parameter in $module.Parameters ) {
|
||||
$allParametersInParametersFile = (Get-Content $parameter `
|
||||
| ConvertFrom-Json -ErrorAction SilentlyContinue).Parameters.PSObject.Properties `
|
||||
| Sort-Object -Property Name `
|
||||
| ForEach-Object Name
|
||||
@($requiredParametersInTemplateFile| Where-Object {$allParametersInParametersFile -notcontains $psitem}).Count | Should -Be 0
|
||||
}
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
#endregion
|
|
@ -0,0 +1,84 @@
|
|||
<#
|
||||
.NOTES
|
||||
==============================================================================================
|
||||
Copyright(c) Microsoft Corporation. All rights reserved.
|
||||
|
||||
Microsoft Consulting Services - AzureCAT - VDC Toolkit (v2.0)
|
||||
|
||||
File: machine.learning.output.tests.ps1
|
||||
|
||||
Purpose: Test - Machine Learning ARM Template Output Variables
|
||||
|
||||
Version: 2.0.0.0 - 1st September 2019 - Azure Virtual Datacenter Development Team
|
||||
==============================================================================================
|
||||
|
||||
.SYNOPSIS
|
||||
This script contains functionality used to test Machine Learning ARM Template Output Variables.
|
||||
|
||||
.DESCRIPTION
|
||||
This script contains functionality used to test Machine Learning ARM Template Output Variables.
|
||||
|
||||
Deployment steps of the script are outlined below.
|
||||
1) Outputs Variable Logic from pipeline
|
||||
|
||||
.PARAMETER machinelearningName
|
||||
Specify the Machine Learning Name output parameter.
|
||||
|
||||
.PARAMETER machinelearningResourceId
|
||||
Specify the Machine Learning Resource Id output parameter.
|
||||
|
||||
.PARAMETER machinelearningResourceGroup
|
||||
Specify the Machine Learning ResourceGroup output parameter.
|
||||
|
||||
.EXAMPLE
|
||||
Default:
|
||||
C:\PS>.\machine.learning.output.tests.ps1
|
||||
-machinelearningName "$(machinelearningName)"
|
||||
-machinelearningResourceId "$(machinelearningResourceId)"
|
||||
-machinelearningResourceGroup "$(machinelearningResourceGroup)"
|
||||
#>
|
||||
|
||||
#Requires -Version 5
|
||||
|
||||
[CmdletBinding()]
|
||||
param
|
||||
(
|
||||
[Parameter(Mandatory = $false)]
|
||||
[string]$machinelearningName,
|
||||
|
||||
[Parameter(Mandatory = $false)]
|
||||
[string]$machinelearningResourceId,
|
||||
|
||||
[Parameter(Mandatory = $false)]
|
||||
[string]$machinelearningResourceGroup
|
||||
)
|
||||
|
||||
#region - Machine Learning Output Tests
|
||||
|
||||
if (-not [string]::IsNullOrWhiteSpace($PSBoundParameters['machinelearningName']))
|
||||
{
|
||||
Write-Output "Machine Learning Name: $($machinelearningName)"
|
||||
}
|
||||
else
|
||||
{
|
||||
Write-Output "Machine Learning Name: []"
|
||||
}
|
||||
|
||||
if (-not [string]::IsNullOrWhiteSpace($PSBoundParameters['machinelearningResourceId']))
|
||||
{
|
||||
Write-Output "Machine Learning ResourceId: $($machinelearningResourceId)"
|
||||
}
|
||||
else
|
||||
{
|
||||
Write-Output "Machine Learning Resource Id: []"
|
||||
}
|
||||
|
||||
if (-not [string]::IsNullOrWhiteSpace($PSBoundParameters['machinelearningResourceGroup']))
|
||||
{
|
||||
Write-Output "Machine Learnings ResourceGroup: $($machinelearningResourceGroup)"
|
||||
}
|
||||
else
|
||||
{
|
||||
Write-Output "Machine Learning ResourceGroup: []"
|
||||
}
|
||||
#endregion
|
|
@ -0,0 +1,21 @@
|
|||
{
|
||||
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentParameters.json#",
|
||||
"contentVersion": "1.0.0.0",
|
||||
"parameters": {
|
||||
"workspaceName": {
|
||||
"value": "testworkspaceName"
|
||||
},
|
||||
"planName": {
|
||||
"value": "testplanName"
|
||||
},
|
||||
"ownerEmail": {
|
||||
"value": "someone@ownerEmail.com.test"
|
||||
},
|
||||
"storageAccountResourceId": {
|
||||
"value": "/subscriptions/00000000/resourceGroups/resourceGroup"
|
||||
},
|
||||
"cuaId": {
|
||||
"value": "00000000-0000-0000-0000-000000000000"
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,9 +0,0 @@
|
|||
# Machine Learning service workspaces
|
||||
|
||||
This template creates an Machine Learning service workspaces.
|
||||
|
||||
## Deployed Resources
|
||||
|
||||
The following resources are deployed as part of this code block.
|
||||
|
||||
+ **Machine Learning service workspaces**
|
|
@ -0,0 +1,153 @@
|
|||
{
|
||||
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
|
||||
"contentVersion": "1.0.0.0",
|
||||
"parameters": {
|
||||
"workspaceName": {
|
||||
"type": "string",
|
||||
"metadata": {
|
||||
"description": "Required. The name of the Machine Learning Workspace"
|
||||
}
|
||||
},
|
||||
"planName": {
|
||||
"type": "string",
|
||||
"metadata": {
|
||||
"description": "Required. The name of the Machine Learning Plan"
|
||||
}
|
||||
},
|
||||
"ownerEmail": {
|
||||
"type": "string",
|
||||
"metadata": {
|
||||
"description": "Required. The Email address of the business owner for the Machine Learning Plan"
|
||||
}
|
||||
},
|
||||
"skuName": {
|
||||
"type": "string",
|
||||
"allowedValues": [
|
||||
"DevTest",
|
||||
"S1",
|
||||
"S2",
|
||||
"S3"
|
||||
],
|
||||
"defaultValue": "S1",
|
||||
"metadata": {
|
||||
"description": "Optional. Machine Learning Plan sku name"
|
||||
}
|
||||
},
|
||||
"skuTier": {
|
||||
"type": "string",
|
||||
"allowedValues": [
|
||||
"Standard"
|
||||
],
|
||||
"defaultValue": "Standard",
|
||||
"metadata": {
|
||||
"description": "Optional. Machine Learning Plan account tier"
|
||||
}
|
||||
},
|
||||
"skuCapacity": {
|
||||
"type": "int",
|
||||
"defaultValue": 1,
|
||||
"metadata": {
|
||||
"description": "Optional. Machine Learning Plan scale-out capacity of the resource"
|
||||
}
|
||||
},
|
||||
"storageAccountResourceId": {
|
||||
"type": "string",
|
||||
"metadata": {
|
||||
"description": "Required. Resource identifier of the Storage Account"
|
||||
}
|
||||
},
|
||||
"location": {
|
||||
"type": "string",
|
||||
"defaultValue": "[resourceGroup().location]",
|
||||
"metadata": {
|
||||
"description": "Optional. Location for all resources"
|
||||
}
|
||||
},
|
||||
"cuaId": {
|
||||
"type": "string",
|
||||
"defaultValue": "",
|
||||
"metadata": {
|
||||
"description": "Optional. Customer Usage Attribution id (GUID). This GUID must be previously registered"
|
||||
}
|
||||
},
|
||||
"tagValues": {
|
||||
"type": "object",
|
||||
"defaultValue": "",
|
||||
"metadata": {
|
||||
"description": "Optional. Azure Resource Tags object"
|
||||
}
|
||||
}
|
||||
},
|
||||
"variables": {
|
||||
"machinelearningName": "[parameters('workspaceName')]",
|
||||
"machinelearningResourceId": "[resourceId('Microsoft.MachineLearning/workspaces', parameters('workspaceName'))]",
|
||||
"machinelearningApiVersion": "2016-04-01",
|
||||
"storageAccountResourceId": "[parameters('storageAccountResourceId')]",
|
||||
"pidName": "[concat('pid-', parameters('cuaId'))]"
|
||||
},
|
||||
"resources": [
|
||||
{
|
||||
"condition": "[not(empty(parameters('cuaId')))]",
|
||||
"type": "Microsoft.Resources/deployments",
|
||||
"apiVersion": "2018-02-01",
|
||||
"name": "[variables('pidName')]",
|
||||
"properties": {
|
||||
"mode": "Incremental",
|
||||
"template": {
|
||||
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
|
||||
"contentVersion": "1.0.0.0",
|
||||
"resources": []
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "Microsoft.MachineLearning/workspaces",
|
||||
"apiVersion": "[variables('machinelearningApiVersion')]",
|
||||
"name": "[parameters('workspaceName')]",
|
||||
"location": "[parameters('location')]",
|
||||
"tags": "[if(empty(parameters('tagValues')), json('null'), parameters('tagValues'))]",
|
||||
"properties": {
|
||||
"userStorageAccountId": "[variables('storageAccountResourceId')]",
|
||||
"ownerEmail": "[parameters('ownerEmail')]"
|
||||
},
|
||||
"dependsOn": [
|
||||
"[variables('storageAccountResourceId')]"
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "Microsoft.MachineLearning/commitmentPlans",
|
||||
"apiVersion": "2016-05-01-preview",
|
||||
"name": "[parameters('planName')]",
|
||||
"location": "[parameters('location')]",
|
||||
"tags": "[if(empty(parameters('tagValues')), json('null'), parameters('tagValues'))]",
|
||||
"sku": {
|
||||
"name": "[parameters('skuName')]",
|
||||
"tier": "[parameters('skuTier')]",
|
||||
"capacity": "[parameters('skuCapacity')]"
|
||||
}
|
||||
}
|
||||
],
|
||||
"outputs": {
|
||||
"machinelearningName": {
|
||||
"type": "string",
|
||||
"value": "[variables('machinelearningName')]",
|
||||
"metadata": {
|
||||
"description": "The Name of the Machine Learning"
|
||||
}
|
||||
},
|
||||
"machinelearningResourceId": {
|
||||
"type": "string",
|
||||
"value": "[variables('machinelearningResourceId')]",
|
||||
"metadata": {
|
||||
"description": "The Resource Id of the Machine Learning"
|
||||
}
|
||||
},
|
||||
"machinelearningResourceGroup": {
|
||||
"type": "string",
|
||||
"value": "[resourceGroup().name]",
|
||||
"metadata": {
|
||||
"description": "The name of the Resource Group with the Machine Learning"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,44 +0,0 @@
|
|||
{
|
||||
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
|
||||
"contentVersion": "1.0.0.0",
|
||||
"parameters": {
|
||||
"workspaceName": {
|
||||
"type": "string",
|
||||
"metadata": {
|
||||
"description": "Specifies the name of the Azure Machine Learning service workspace."
|
||||
}
|
||||
},
|
||||
"location": {
|
||||
"type": "string",
|
||||
"defaultValue": "southcentralus",
|
||||
"allowedValues": [
|
||||
"eastus",
|
||||
"eastus2",
|
||||
"southcentralus",
|
||||
"southeastasia",
|
||||
"westcentralus",
|
||||
"westeurope",
|
||||
"westus2"
|
||||
],
|
||||
"metadata": {
|
||||
"description": "Specifies the location for all resources."
|
||||
}
|
||||
}
|
||||
},
|
||||
"variables": {},
|
||||
"resources": [
|
||||
{
|
||||
"type": "Microsoft.MachineLearningServices/workspaces",
|
||||
"apiVersion": "2018-11-19",
|
||||
"name": "[parameters('workspaceName')]",
|
||||
"location": "[parameters('location')]",
|
||||
"identity": {
|
||||
"type": "systemAssigned"
|
||||
},
|
||||
"properties": {
|
||||
"friendlyName": "[parameters('workspaceName')]"
|
||||
}
|
||||
}
|
||||
],
|
||||
"outputs": {}
|
||||
}
|
|
@ -0,0 +1,44 @@
|
|||
# Machine Learning
|
||||
|
||||
This module deploys a Machine Learning Workspace Plans.
|
||||
|
||||
## Resources
|
||||
|
||||
The following Resources are deployed.
|
||||
|
||||
+ **Microsoft.MachineLearning/workspaces**
|
||||
+ **Microsoft.MachineLearning/commitmentPlans**
|
||||
|
||||
## Parameters
|
||||
|
||||
| Parameter Name | Default Value | Required | Description |
|
||||
| :- | :- | :- |:- |
|
||||
| `workspaceName` || **Required** | T1he name of the Azure Machine Learning service workspace
|
||||
| `planName` || **Required** | The name of the Machine Learning Plan
|
||||
| `ownerEmail` || **Required** | The Email address of the business owner for the Machine Learning Plan
|
||||
| `skuName` || **Optional** | Machine Learning Plan sku name
|
||||
| `skuTier` || **Optional** | Machine Learning Plan account tier
|
||||
| `skuCapacity` || **Optional** | Machine Learning Plan scale-out capacity of the resource
|
||||
| `storageAccountResourceId` || **Required** | Resource identifier of the Storage Account
|
||||
| `location` | resourceGroup().location | **Optional** | Location for all resources
|
||||
| `cuaId` || **Optional** | Customer Usage Attribution Id (GUID). This GUID must be previously registered
|
||||
| `tagValues` || **Optional** | Optional. Azure Resource Tags object
|
||||
|
||||
## Outputs
|
||||
| Output Name | Description |
|
||||
| :- | :- |
|
||||
| `machinelearningName` | Machine Learning Name output parameter
|
||||
| `machinelearningResourceId` | Machine Learning ResourceId output parameter
|
||||
| `machinelearningResourceGroup` | Machine Learning ResourceGroup output parameter
|
||||
|
||||
## Scripts
|
||||
|
||||
+ There is no Scripts for this Module
|
||||
|
||||
## Considerations
|
||||
|
||||
+ There is no deployment considerations for this Module
|
||||
|
||||
## Additional resources
|
||||
|
||||
+ [Microsoft Machine Learning template reference](https://docs.microsoft.com/en-us/azure/templates/microsoft.machinelearning/allversions)
|
|
@ -0,0 +1,35 @@
|
|||
name: $(Build.DefinitionName)-$(SourceBranchName)-$(Date:yyyyMMdd).$(Rev:rr)
|
||||
|
||||
variables:
|
||||
ModuleName: MachineLearningServices
|
||||
ModuleVersion: 2.0
|
||||
RepoName: azure-devops
|
||||
ModulePath: modules/$(ModuleName)/$(ModuleVersion)
|
||||
ArtifactName: contents
|
||||
|
||||
resources:
|
||||
repositories:
|
||||
- repository: main
|
||||
type: git
|
||||
name: '$(RepoName)'
|
||||
|
||||
trigger:
|
||||
branches:
|
||||
include:
|
||||
- master
|
||||
- '*'
|
||||
paths:
|
||||
include:
|
||||
- modules/MachineLearningServices/2.0
|
||||
|
||||
jobs:
|
||||
- job: BuildModule
|
||||
displayName: Build Module
|
||||
workspace:
|
||||
clean: all
|
||||
|
||||
steps:
|
||||
- template: /azure-devops/ci/buildmodule.yaml
|
||||
parameters:
|
||||
ModulePath: $(ModulePath)
|
||||
ArtifactName: $(ArtifactName)
|
|
@ -0,0 +1,171 @@
|
|||
<#
|
||||
.NOTES
|
||||
==============================================================================================
|
||||
Copyright(c) Microsoft Corporation. All rights reserved.
|
||||
|
||||
Microsoft Consulting Services - AzureCAT - VDC Toolkit (v2.0)
|
||||
|
||||
File: module.tests.ps1
|
||||
|
||||
Purpose: Pester - Test Machine Learning ARM Templates
|
||||
|
||||
Version: 2.0.0.0 - 1st September 2019 - Azure Virtual Datacenter Development Team
|
||||
==============================================================================================
|
||||
|
||||
.SYNOPSIS
|
||||
This script contains functionality used to test Machine Learning ARM template synatax.
|
||||
|
||||
.DESCRIPTION
|
||||
This script contains functionality used to test Machine Learning ARM template synatax.
|
||||
|
||||
Deployment steps of the script are outlined below.
|
||||
1) Test Template File Syntax
|
||||
2) Test Parameter File Syntax
|
||||
3) Test Template and Parameter File Compactibility
|
||||
#>
|
||||
|
||||
#Requires -Version 5
|
||||
|
||||
#region Parameters
|
||||
$here = Split-Path -Parent $MyInvocation.MyCommand.Path
|
||||
$here = Join-Path -Path $here -ChildPath ".."
|
||||
$template = Split-Path -Leaf $here
|
||||
|
||||
#region - Template File Test Cases
|
||||
$templateFileTestCases = @()
|
||||
ForEach ($file in (Get-ChildItem (Join-Path -Path "$here" -ChildPath "deploy.json") -Recurse | Select-Object -ExpandProperty Name)) {
|
||||
$templateFileTestCases += @{ TemplateFile = $file }
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region - Parameter File Test Cases
|
||||
$parameterFileTestCases = @()
|
||||
ForEach ($file in (Get-ChildItem (Join-Path -Path "$here" -ChildPath "Tests" -AdditionalChildPath @("*parameters.json")) -Recurse -ErrorAction SilentlyContinue | Select-Object -ExpandProperty Name)) {
|
||||
$parameterFileTestCases += @{ ParameterFile = Join-Path -Path "Tests" $file }
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region - Module Test Cases
|
||||
$modules = @()
|
||||
ForEach ($file in (Get-ChildItem (Join-Path -Path "$here" -ChildPath "deploy.json"))) {
|
||||
$module = [PSCustomObject]@{
|
||||
'Template' = $null
|
||||
'Parameters' = $null
|
||||
}
|
||||
$module.Template = $file.FullName
|
||||
|
||||
$parameters = @()
|
||||
ForEach ($parameterFile in (Get-ChildItem (Join-Path -Path "$here" -ChildPath "Tests" -AdditionalChildPath @("*parameters.json")) -Recurse -ErrorAction SilentlyContinue | Select-Object -ExpandProperty Name)) {
|
||||
$parameters += (Join-Path -Path "$here" -ChildPath "Tests" -AdditionalChildPath @("$ParameterFile"))
|
||||
}
|
||||
$Module.Parameters = $Parameters
|
||||
$Modules += @{Module = $Module}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
#region - Run Pester Test Script
|
||||
Describe "Template: $template - Machine Learning" -Tags -Unit {
|
||||
|
||||
#region - Template File Syntax
|
||||
Context "Template File Syntax" {
|
||||
|
||||
It "Has a JSON template file" {
|
||||
(Join-Path -Path "$here" -ChildPath "deploy.json") | Should -Exist
|
||||
}
|
||||
|
||||
It "Converts from JSON and has the expected properties" -TestCases $templateFileTestCases {
|
||||
param($templateFile)
|
||||
$expectedProperties = '$schema',
|
||||
'contentVersion',
|
||||
'parameters',
|
||||
'variables',
|
||||
'resources',
|
||||
'outputs' | Sort-Object
|
||||
$templateProperties = (Get-Content (Join-Path -Path "$here" -ChildPath "$templateFile") `
|
||||
| ConvertFrom-Json -ErrorAction SilentlyContinue) `
|
||||
| Get-Member -MemberType NoteProperty `
|
||||
| Sort-Object -Property Name `
|
||||
| ForEach-Object Name
|
||||
$templateProperties | Should -Be $expectedProperties
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region - Parameter File Syntax
|
||||
Context "Parameter File Syntax" {
|
||||
|
||||
It "Parameter file does not contains the expected properties" -TestCases $parameterFileTestCases {
|
||||
param($parameterFile)
|
||||
$expectedProperties = '$schema',
|
||||
'contentVersion',
|
||||
'parameters' | Sort-Object
|
||||
Write-Output $parameterFile
|
||||
Join-Path -Path "$here" -ChildPath "$parameterFile" | Write-Output
|
||||
$templateFileProperties = (Get-Content (Join-Path -Path "$here" -ChildPath "$parameterFile") `
|
||||
| ConvertFrom-Json -ErrorAction SilentlyContinue) `
|
||||
| Get-Member -MemberType NoteProperty `
|
||||
| Sort-Object -Property Name `
|
||||
| ForEach-Object Name
|
||||
$templateFileProperties | Should -Be $expectedProperties
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region - Template and Parameter Compactibility
|
||||
Context "Template and Parameter Compactibility" {
|
||||
|
||||
It "Is count of required parameters in template file equal or lesser than count of all parameters in parameters file" -TestCases $modules {
|
||||
param($module)
|
||||
$requiredParametersInTemplateFile = (Get-Content "$($module.Template)" `
|
||||
| ConvertFrom-Json -ErrorAction SilentlyContinue).Parameters.PSObject.Properties `
|
||||
| Where-Object -FilterScript { -not ($psitem.Value.PSObject.Properties.Name -eq "defaultValue")} `
|
||||
| Sort-Object -Property Name `
|
||||
| ForEach-Object Name
|
||||
ForEach ( $parameter in $module.Parameters ) {
|
||||
$allParametersInParametersFile = (Get-Content $parameter `
|
||||
| ConvertFrom-Json -ErrorAction SilentlyContinue).Parameters.PSObject.Properties `
|
||||
| Sort-Object -Property Name `
|
||||
| ForEach-Object Name
|
||||
$requiredParametersInTemplateFile.Count | Should -Not -BeGreaterThan $allParametersInParametersFile.Count
|
||||
}
|
||||
}
|
||||
|
||||
It "Has all parameters in parameters file existing in template file" -TestCases $modules {
|
||||
param($module)
|
||||
$allParametersInTemplateFile = (Get-Content "$($module.Template)" `
|
||||
| ConvertFrom-Json -ErrorAction SilentlyContinue).Parameters.PSObject.Properties `
|
||||
| Sort-Object -Property Name `
|
||||
| ForEach-Object Name
|
||||
ForEach ($parameter in $module.Parameters) {
|
||||
Write-Output "File analyzed: $parameter"
|
||||
$allParametersInParametersFile = (Get-Content $parameter `
|
||||
| ConvertFrom-Json -ErrorAction SilentlyContinue).Parameters.PSObject.Properties `
|
||||
| Sort-Object -Property Name `
|
||||
| ForEach-Object Name
|
||||
$result = @($allParametersInParametersFile| Where-Object {$allParametersInTemplateFile -notcontains $psitem})
|
||||
Write-Output "Invalid parameters: $(ConvertTo-Json $result)"
|
||||
@($allParametersInParametersFile| Where-Object {$allParametersInTemplateFile -notcontains $psitem}).Count | Should -Be 0
|
||||
}
|
||||
}
|
||||
|
||||
It "Has required parameters in template file existing in parameters file" -TestCases $modules {
|
||||
param($module)
|
||||
$requiredParametersInTemplateFile = (Get-Content "$($module.Template)" `
|
||||
| ConvertFrom-Json -ErrorAction SilentlyContinue).Parameters.PSObject.Properties `
|
||||
| Where-Object -FilterScript { -not ($psitem.Value.PSObject.Properties.Name -eq "defaultValue") } `
|
||||
| Sort-Object -Property Name `
|
||||
| ForEach-Object Name
|
||||
ForEach ($parameter in $module.Parameters ) {
|
||||
$allParametersInParametersFile = (Get-Content $parameter `
|
||||
| ConvertFrom-Json -ErrorAction SilentlyContinue).Parameters.PSObject.Properties `
|
||||
| Sort-Object -Property Name `
|
||||
| ForEach-Object Name
|
||||
@($requiredParametersInTemplateFile| Where-Object {$allParametersInParametersFile -notcontains $psitem}).Count | Should -Be 0
|
||||
}
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
#endregion
|
|
@ -0,0 +1,84 @@
|
|||
<#
|
||||
.NOTES
|
||||
==============================================================================================
|
||||
Copyright(c) Microsoft Corporation. All rights reserved.
|
||||
|
||||
Microsoft Consulting Services - AzureCAT - VDC Toolkit (v2.0)
|
||||
|
||||
File: output.tests.ps1
|
||||
|
||||
Purpose: Test - Machine Learning ARM Template Output Variables
|
||||
|
||||
Version: 2.0.0.0 - 1st September 2019 - Azure Virtual Datacenter Development Team
|
||||
==============================================================================================
|
||||
|
||||
.SYNOPSIS
|
||||
This script contains functionality used to test Machine Learning ARM Template Output Variables.
|
||||
|
||||
.DESCRIPTION
|
||||
This script contains functionality used to test Machine Learning ARM Template Output Variables.
|
||||
|
||||
Deployment steps of the script are outlined below.
|
||||
1) Outputs Variable Logic from pipeline
|
||||
|
||||
.PARAMETER machinelearningName
|
||||
Specify the Machine Learning Name output parameter.
|
||||
|
||||
.PARAMETER machinelearningResourceId
|
||||
Specify the Machine Learning Resource Id output parameter.
|
||||
|
||||
.PARAMETER machinelearningResourceGroup
|
||||
Specify the Machine Learning ResourceGroup output parameter.
|
||||
|
||||
.EXAMPLE
|
||||
Default:
|
||||
C:\PS>.\output.tests.ps1
|
||||
-machinelearningName "$(machinelearningName)"
|
||||
-machinelearningResourceId "$(machinelearningResourceId)"
|
||||
-machinelearningResourceGroup "$(machinelearningResourceGroup)"
|
||||
#>
|
||||
|
||||
#Requires -Version 5
|
||||
|
||||
[CmdletBinding()]
|
||||
param
|
||||
(
|
||||
[Parameter(Mandatory = $false)]
|
||||
[string]$machinelearningName,
|
||||
|
||||
[Parameter(Mandatory = $false)]
|
||||
[string]$machinelearningResourceId,
|
||||
|
||||
[Parameter(Mandatory = $false)]
|
||||
[string]$machinelearningResourceGroup
|
||||
)
|
||||
|
||||
#region - Machine Learning Output Tests
|
||||
|
||||
if (-not [string]::IsNullOrWhiteSpace($PSBoundParameters['machinelearningName']))
|
||||
{
|
||||
Write-Output "Machine Learning Name: $($machinelearningName)"
|
||||
}
|
||||
else
|
||||
{
|
||||
Write-Output "Machine Learning Name: []"
|
||||
}
|
||||
|
||||
if (-not [string]::IsNullOrWhiteSpace($PSBoundParameters['machinelearningResourceId']))
|
||||
{
|
||||
Write-Output "Machine Learning ResourceId: $($machinelearningResourceId)"
|
||||
}
|
||||
else
|
||||
{
|
||||
Write-Output "Machine Learning Resource Id: []"
|
||||
}
|
||||
|
||||
if (-not [string]::IsNullOrWhiteSpace($PSBoundParameters['machinelearningResourceGroup']))
|
||||
{
|
||||
Write-Output "Machine Learnings ResourceGroup: $($machinelearningResourceGroup)"
|
||||
}
|
||||
else
|
||||
{
|
||||
Write-Output "Machine Learning ResourceGroup: []"
|
||||
}
|
||||
#endregion
|
|
@ -0,0 +1,21 @@
|
|||
{
|
||||
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentParameters.json#",
|
||||
"contentVersion": "1.0.0.0",
|
||||
"parameters": {
|
||||
"workspaceName": {
|
||||
"value": "testworkspaceName"
|
||||
},
|
||||
"storageAccountResourceId": {
|
||||
"value": "/subscriptions/00000000/resourceGroups/resourceGroup"
|
||||
},
|
||||
"keyVaultResourceId": {
|
||||
"value": "/subscriptions/00000000/resourceGroups/resourceGroup"
|
||||
},
|
||||
"appInsightsResourceId": {
|
||||
"value": "/subscriptions/00000000/resourceGroups/resourceGroup"
|
||||
},
|
||||
"cuaId": {
|
||||
"value": "00000000-0000-0000-0000-000000000000"
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,118 @@
|
|||
{
|
||||
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
|
||||
"contentVersion": "1.0.0.0",
|
||||
"parameters": {
|
||||
"workspaceName": {
|
||||
"type": "string",
|
||||
"metadata": {
|
||||
"description": "Required. The name of the Machine Learning Services Workspace"
|
||||
}
|
||||
},
|
||||
"storageAccountResourceId": {
|
||||
"type": "string",
|
||||
"metadata": {
|
||||
"description": "Required. Resource identifier of the Storage Account"
|
||||
}
|
||||
},
|
||||
"keyVaultResourceId": {
|
||||
"type": "string",
|
||||
"metadata": {
|
||||
"description": "Required. Resource identifier of the KeyVault"
|
||||
}
|
||||
},
|
||||
"appInsightsResourceId": {
|
||||
"type": "string",
|
||||
"metadata": {
|
||||
"description": "Required. Resource identifier of the Application Insights"
|
||||
}
|
||||
},
|
||||
"location": {
|
||||
"type": "string",
|
||||
"defaultValue": "[resourceGroup().location]",
|
||||
"metadata": {
|
||||
"description": "Optional. Location for all Resources"
|
||||
}
|
||||
},
|
||||
"cuaId": {
|
||||
"type": "string",
|
||||
"defaultValue": "",
|
||||
"metadata": {
|
||||
"description": "Optional. Customer Usage Attribution id (GUID). This GUID must be previously registered"
|
||||
}
|
||||
},
|
||||
"tagValues": {
|
||||
"type": "object",
|
||||
"defaultValue": "",
|
||||
"metadata": {
|
||||
"description": "Optional. Azure Resource Tags object"
|
||||
}
|
||||
}
|
||||
},
|
||||
"variables": {
|
||||
"machinelearningName": "[parameters('workspaceName')]",
|
||||
"machinelearningResourceId": "[resourceId('Microsoft.MachineLearningServices/workspaces', parameters('workspaceName'))]",
|
||||
"machinelearningApiVersion": "2019-05-01",
|
||||
"storageAccountResourceId": "[parameters('storageAccountResourceId')]",
|
||||
"keyVaultResourceId": "[parameters('keyVaultResourceId')]",
|
||||
"appInsightsResourceId": "[parameters('appInsightsResourceId')]",
|
||||
"pidName": "[concat('pid-',parameters('cuaId'))]"
|
||||
},
|
||||
"resources": [
|
||||
{
|
||||
"condition": "[not(empty(parameters('cuaId')))]",
|
||||
"type": "Microsoft.Resources/deployments",
|
||||
"apiVersion": "2018-02-01",
|
||||
"name": "[variables('pidName')]",
|
||||
"properties": {
|
||||
"mode": "Incremental",
|
||||
"template": {
|
||||
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
|
||||
"contentVersion": "1.0.0.0",
|
||||
"resources": []
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "Microsoft.MachineLearningServices/workspaces",
|
||||
"apiVersion": "[variables('machinelearningApiVersion')]",
|
||||
"name": "[parameters('workspaceName')]",
|
||||
"location": "[parameters('location')]",
|
||||
"tags": "[if(empty(parameters('tagValues')), json('null'), parameters('tagValues'))]",
|
||||
"properties": {
|
||||
"friendlyName": "[parameters('workspaceName')]",
|
||||
"keyVault": "[variables('keyVaultResourceId')]",
|
||||
"applicationInsights": "[variables('appInsightsResourceId')]",
|
||||
"storageAccount": "[variables('storageAccountResourceId')]"
|
||||
},
|
||||
"identity": {
|
||||
"type": "systemAssigned"
|
||||
},
|
||||
"dependsOn": [
|
||||
"[variables('storageAccountResourceId')]"
|
||||
]
|
||||
}
|
||||
],
|
||||
"outputs": {
|
||||
"machinelearningName": {
|
||||
"type": "string",
|
||||
"value": "[variables('machinelearningName')]",
|
||||
"metadata": {
|
||||
"description": "The Name of the Machine Learning"
|
||||
}
|
||||
},
|
||||
"machinelearningResourceId": {
|
||||
"type": "string",
|
||||
"value": "[variables('machinelearningResourceId')]",
|
||||
"metadata": {
|
||||
"description": "The Resource Id of the Machine Learning"
|
||||
}
|
||||
},
|
||||
"machinelearningResourceGroup": {
|
||||
"type": "string",
|
||||
"value": "[resourceGroup().name]",
|
||||
"metadata": {
|
||||
"description": "The name of the Resource Group with the Machine Learning"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,40 @@
|
|||
# Machine Learning Services
|
||||
|
||||
This module deploys a Machine Learning Services Workspace.
|
||||
|
||||
## Resources
|
||||
|
||||
The following Resources are deployed.
|
||||
|
||||
+ **Microsoft.MachineLearningServices/workspaces**
|
||||
|
||||
## Parameters
|
||||
|
||||
| Parameter Name | Default Value | Required | Description |
|
||||
| :- | :- | :- |:- |
|
||||
| `workspaceName` || **Required** | T1he name of the Azure Machine Learning service workspace
|
||||
| `storageAccountResourceId` || **Required** | Resource identifier of the Storage Account
|
||||
| `keyVaultResourceId` || **Required** | Resource identifier of the KeyVault
|
||||
| `appInsightsResourceId` || **Required** | Resource identifier of the Application Insights
|
||||
| `location` | resourceGroup().location | **Optional** | Location for all resources
|
||||
| `cuaId` || **Optional** | Customer Usage Attribution Id (GUID). This GUID must be previously registered
|
||||
| `tagValues` || **Optional** | Optional. Azure Resource Tags object
|
||||
|
||||
## Outputs
|
||||
| Output Name | Description |
|
||||
| :- | :- |
|
||||
| `machinelearningName` | Machine Learning Services Name output parameter
|
||||
| `machinelearningResourceId` | Machine Learning Services ResourceId output parameter
|
||||
| `machinelearningResourceGroup` | Machine Learning Services ResourceGroup output parameter
|
||||
|
||||
## Scripts
|
||||
|
||||
+ There is no Scripts for this Module
|
||||
|
||||
## Considerations
|
||||
|
||||
+ There is no deployment considerations for this Module
|
||||
|
||||
## Additional resources
|
||||
|
||||
+ [Microsoft Machine Learning Services template reference](https://docs.microsoft.com/en-us/azure/templates/microsoft.machinelearningservices/allversions)
|
|
@ -0,0 +1,35 @@
|
|||
name: $(Build.DefinitionName)-$(SourceBranchName)-$(Date:yyyyMMdd).$(Rev:rr)
|
||||
|
||||
variables:
|
||||
ModuleName: StreamAnalytics
|
||||
ModuleVersion: 2.0
|
||||
RepoName: azure-devops
|
||||
ModulePath: modules/$(ModuleName)/$(ModuleVersion)
|
||||
ArtifactName: contents
|
||||
|
||||
resources:
|
||||
repositories:
|
||||
- repository: main
|
||||
type: git
|
||||
name: '$(RepoName)'
|
||||
|
||||
trigger:
|
||||
branches:
|
||||
include:
|
||||
- master
|
||||
- '*'
|
||||
paths:
|
||||
include:
|
||||
- modules/StreamAnalytics/2.0
|
||||
|
||||
jobs:
|
||||
- job: BuildModule
|
||||
displayName: Build Module
|
||||
workspace:
|
||||
clean: all
|
||||
|
||||
steps:
|
||||
- template: /azure-devops/ci/buildmodule.yaml
|
||||
parameters:
|
||||
ModulePath: $(ModulePath)
|
||||
ArtifactName: $(ArtifactName)
|
|
@ -0,0 +1,171 @@
|
|||
<#
|
||||
.NOTES
|
||||
==============================================================================================
|
||||
Copyright(c) Microsoft Corporation. All rights reserved.
|
||||
|
||||
Microsoft Consulting Services - AzureCAT - VDC Toolkit (v2.0)
|
||||
|
||||
File: module.tests.ps1
|
||||
|
||||
Purpose: Pester - Test Stream Analytics ARM Templates
|
||||
|
||||
Version: 2.0.0.0 - 1st September 2019 - Azure Virtual Datacenter Development Team
|
||||
==============================================================================================
|
||||
|
||||
.SYNOPSIS
|
||||
This script contains functionality used to test Stream Analytics ARM template synatax.
|
||||
|
||||
.DESCRIPTION
|
||||
This script contains functionality used to test Stream Analytics ARM template synatax.
|
||||
|
||||
Deployment steps of the script are outlined below.
|
||||
1) Test Template File Syntax
|
||||
2) Test Parameter File Syntax
|
||||
3) Test Template and Parameter File Compactibility
|
||||
#>
|
||||
|
||||
#Requires -Version 5
|
||||
|
||||
#region Parameters
|
||||
$here = Split-Path -Parent $MyInvocation.MyCommand.Path
|
||||
$here = Join-Path -Path $here -ChildPath ".."
|
||||
$template = Split-Path -Leaf $here
|
||||
|
||||
#region - Template File Test Cases
|
||||
$templateFileTestCases = @()
|
||||
ForEach ($file in (Get-ChildItem (Join-Path -Path "$here" -ChildPath "deploy.json") -Recurse | Select-Object -ExpandProperty Name)) {
|
||||
$templateFileTestCases += @{ TemplateFile = $file }
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region - Parameter File Test Cases
|
||||
$parameterFileTestCases = @()
|
||||
ForEach ($file in (Get-ChildItem (Join-Path -Path "$here" -ChildPath "Tests" -AdditionalChildPath @("*parameters.json")) -Recurse -ErrorAction SilentlyContinue | Select-Object -ExpandProperty Name)) {
|
||||
$parameterFileTestCases += @{ ParameterFile = Join-Path -Path "Tests" $file }
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region - Module Test Cases
|
||||
$modules = @()
|
||||
ForEach ($file in (Get-ChildItem (Join-Path -Path "$here" -ChildPath "deploy.json"))) {
|
||||
$module = [PSCustomObject]@{
|
||||
'Template' = $null
|
||||
'Parameters' = $null
|
||||
}
|
||||
$module.Template = $file.FullName
|
||||
|
||||
$parameters = @()
|
||||
ForEach ($parameterFile in (Get-ChildItem (Join-Path -Path "$here" -ChildPath "Tests" -AdditionalChildPath @("*parameters.json")) -Recurse -ErrorAction SilentlyContinue | Select-Object -ExpandProperty Name)) {
|
||||
$parameters += (Join-Path -Path "$here" -ChildPath "Tests" -AdditionalChildPath @("$ParameterFile"))
|
||||
}
|
||||
$Module.Parameters = $Parameters
|
||||
$Modules += @{Module = $Module}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
#region - Run Pester Test Script
|
||||
Describe "Template: $template - Stream Analytics" -Tags -Unit {
|
||||
|
||||
#region - Template File Syntax
|
||||
Context "Template File Syntax" {
|
||||
|
||||
It "Has a JSON template file" {
|
||||
(Join-Path -Path "$here" -ChildPath "deploy.json") | Should -Exist
|
||||
}
|
||||
|
||||
It "Converts from JSON and has the expected properties" -TestCases $templateFileTestCases {
|
||||
param($templateFile)
|
||||
$expectedProperties = '$schema',
|
||||
'contentVersion',
|
||||
'parameters',
|
||||
'variables',
|
||||
'resources',
|
||||
'outputs' | Sort-Object
|
||||
$templateProperties = (Get-Content (Join-Path -Path "$here" -ChildPath "$templateFile") `
|
||||
| ConvertFrom-Json -ErrorAction SilentlyContinue) `
|
||||
| Get-Member -MemberType NoteProperty `
|
||||
| Sort-Object -Property Name `
|
||||
| ForEach-Object Name
|
||||
$templateProperties | Should -Be $expectedProperties
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region - Parameter File Syntax
|
||||
Context "Parameter File Syntax" {
|
||||
|
||||
It "Parameter file does not contains the expected properties" -TestCases $parameterFileTestCases {
|
||||
param($parameterFile)
|
||||
$expectedProperties = '$schema',
|
||||
'contentVersion',
|
||||
'parameters' | Sort-Object
|
||||
Write-Output $parameterFile
|
||||
Join-Path -Path "$here" -ChildPath "$parameterFile" | Write-Output
|
||||
$templateFileProperties = (Get-Content (Join-Path -Path "$here" -ChildPath "$parameterFile") `
|
||||
| ConvertFrom-Json -ErrorAction SilentlyContinue) `
|
||||
| Get-Member -MemberType NoteProperty `
|
||||
| Sort-Object -Property Name `
|
||||
| ForEach-Object Name
|
||||
$templateFileProperties | Should -Be $expectedProperties
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region - Template and Parameter Compactibility
|
||||
Context "Template and Parameter Compactibility" {
|
||||
|
||||
It "Is count of required parameters in template file equal or lesser than count of all parameters in parameters file" -TestCases $modules {
|
||||
param($module)
|
||||
$requiredParametersInTemplateFile = (Get-Content "$($module.Template)" `
|
||||
| ConvertFrom-Json -ErrorAction SilentlyContinue).Parameters.PSObject.Properties `
|
||||
| Where-Object -FilterScript { -not ($psitem.Value.PSObject.Properties.Name -eq "defaultValue")} `
|
||||
| Sort-Object -Property Name `
|
||||
| ForEach-Object Name
|
||||
ForEach ( $parameter in $module.Parameters ) {
|
||||
$allParametersInParametersFile = (Get-Content $parameter `
|
||||
| ConvertFrom-Json -ErrorAction SilentlyContinue).Parameters.PSObject.Properties `
|
||||
| Sort-Object -Property Name `
|
||||
| ForEach-Object Name
|
||||
$requiredParametersInTemplateFile.Count | Should -Not -BeGreaterThan $allParametersInParametersFile.Count
|
||||
}
|
||||
}
|
||||
|
||||
It "Has all parameters in parameters file existing in template file" -TestCases $modules {
|
||||
param($module)
|
||||
$allParametersInTemplateFile = (Get-Content "$($module.Template)" `
|
||||
| ConvertFrom-Json -ErrorAction SilentlyContinue).Parameters.PSObject.Properties `
|
||||
| Sort-Object -Property Name `
|
||||
| ForEach-Object Name
|
||||
ForEach ($parameter in $module.Parameters) {
|
||||
Write-Output "File analyzed: $parameter"
|
||||
$allParametersInParametersFile = (Get-Content $parameter `
|
||||
| ConvertFrom-Json -ErrorAction SilentlyContinue).Parameters.PSObject.Properties `
|
||||
| Sort-Object -Property Name `
|
||||
| ForEach-Object Name
|
||||
$result = @($allParametersInParametersFile| Where-Object {$allParametersInTemplateFile -notcontains $psitem})
|
||||
Write-Output "Invalid parameters: $(ConvertTo-Json $result)"
|
||||
@($allParametersInParametersFile| Where-Object {$allParametersInTemplateFile -notcontains $psitem}).Count | Should -Be 0
|
||||
}
|
||||
}
|
||||
|
||||
It "Has required parameters in template file existing in parameters file" -TestCases $modules {
|
||||
param($module)
|
||||
$requiredParametersInTemplateFile = (Get-Content "$($module.Template)" `
|
||||
| ConvertFrom-Json -ErrorAction SilentlyContinue).Parameters.PSObject.Properties `
|
||||
| Where-Object -FilterScript { -not ($psitem.Value.PSObject.Properties.Name -eq "defaultValue") } `
|
||||
| Sort-Object -Property Name `
|
||||
| ForEach-Object Name
|
||||
ForEach ($parameter in $module.Parameters ) {
|
||||
$allParametersInParametersFile = (Get-Content $parameter `
|
||||
| ConvertFrom-Json -ErrorAction SilentlyContinue).Parameters.PSObject.Properties `
|
||||
| Sort-Object -Property Name `
|
||||
| ForEach-Object Name
|
||||
@($requiredParametersInTemplateFile| Where-Object {$allParametersInParametersFile -notcontains $psitem}).Count | Should -Be 0
|
||||
}
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
#endregion
|
|
@ -0,0 +1,81 @@
|
|||
<#
|
||||
.NOTES
|
||||
==============================================================================================
|
||||
Copyright(c) Microsoft Corporation. All rights reserved.
|
||||
|
||||
Microsoft Consulting Services - AzureCAT - VDC Toolkit (v2.0)
|
||||
|
||||
File: stream.analytics.output.tests.ps1
|
||||
|
||||
Purpose: Test - Stream Analytics ARM Template Output Variables
|
||||
|
||||
Version: 2.0.0.0 - 1st August 2019 - Azure Virtual Datacenter Development Team
|
||||
==============================================================================================
|
||||
|
||||
.SYNOPSIS
|
||||
This script contains functionality used to test Stream Analytics ARM Templates output variables.
|
||||
|
||||
.DESCRIPTION
|
||||
This script contains functionality used to test Stream Analytics ARM Templates output variables.
|
||||
|
||||
Deployment steps of the script are outlined below.
|
||||
1) Outputs Variable Logic from pipeline
|
||||
|
||||
.PARAMETER streamAnalyticsName
|
||||
Specify the Stream Analytics Name output parameter.
|
||||
|
||||
.PARAMETER streamAnalyticsResourceId
|
||||
Specify the Stream Analytics ResourceId output parameter.
|
||||
|
||||
.PARAMETER streamAnalyticsResourceGroup
|
||||
Specify the Stream Analytics ResourceGroup output parameter.
|
||||
|
||||
.EXAMPLE
|
||||
Default:
|
||||
C:\PS>.\stream.analytics.output.tests.ps1
|
||||
-streamAnalyticsName "$(streamAnalyticsName)"
|
||||
-streamAnalyticsResourceId "$(streamAnalyticsResourceId)"
|
||||
-streamAnalyticsResourceGroup "$(streamAnalyticsResourceGroup)"
|
||||
#>
|
||||
|
||||
#Requires -Version 5
|
||||
|
||||
[CmdletBinding()]
|
||||
param
|
||||
(
|
||||
[Parameter(Mandatory = $false)]
|
||||
[string]$streamAnalyticsName,
|
||||
|
||||
[Parameter(Mandatory = $false)]
|
||||
[string]$streamAnalyticsResourceId,
|
||||
|
||||
[Parameter(Mandatory = $false)]
|
||||
[string]$streamAnalyticsResourceGroup
|
||||
)
|
||||
|
||||
if (-not [string]::IsNullOrWhiteSpace($PSBoundParameters['streamAnalyticsName']))
|
||||
{
|
||||
Write-Output "Stream Analytics Name: $($streamAnalyticsName)"
|
||||
}
|
||||
else
|
||||
{
|
||||
Write-Output "Stream Analytics Name: []"
|
||||
}
|
||||
|
||||
if (-not [string]::IsNullOrWhiteSpace($PSBoundParameters['streamAnalyticsResourceId']))
|
||||
{
|
||||
Write-Output "Stream Analytics ResourceId: $($streamAnalyticsResourceId)"
|
||||
}
|
||||
else
|
||||
{
|
||||
Write-Output "Stream Analytics ResourceId: []"
|
||||
}
|
||||
|
||||
if (-not [string]::IsNullOrWhiteSpace($PSBoundParameters['streamAnalyticsResourceGroup']))
|
||||
{
|
||||
Write-Output "Stream Analytics Resource Group: $($streamAnalyticsResourceGroup)"
|
||||
}
|
||||
else
|
||||
{
|
||||
Write-Output "Stream Analytics Resource Group: []"
|
||||
}
|
|
@ -3,10 +3,7 @@
|
|||
"contentVersion": "1.0.0.0",
|
||||
"parameters": {
|
||||
"streamAnalyticsJobName": {
|
||||
"value": null
|
||||
},
|
||||
"numberOfStreamingUnits": {
|
||||
"value": 1
|
||||
}
|
||||
"value": "teststreamAnalyticsJobName"
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,29 +0,0 @@
|
|||
# Stream Analytics
|
||||
|
||||
This template creates a Standard Stream Analytics Job. For more information, see here:
|
||||
|
||||
https://docs.microsoft.com/en-us/azure/stream-analytics/stream-analytics-create-a-job
|
||||
|
||||
https://docs.microsoft.com/en-us/azure/templates/microsoft.streamanalytics/allversions
|
||||
|
||||
## Resources
|
||||
|
||||
The following Resources are deployed.
|
||||
|
||||
+ **StreamAnalytics** : Streaming Jobs
|
||||
|
||||
|
||||
## Parameters
|
||||
|
||||
+ streamAnalyticsJobName - Stream Analytics Job Name
|
||||
+ numberOfStreamingUnits - Number of Streaming Units
|
||||
|
||||
|
||||
## Outputs
|
||||
|
||||
There is no Outputs in this Module
|
||||
|
||||
|
||||
## Scripts
|
||||
|
||||
There is no Scripts in this Module
|
|
@ -0,0 +1,122 @@
|
|||
{
|
||||
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json",
|
||||
"contentVersion": "1.0.0.0",
|
||||
"parameters": {
|
||||
"streamAnalyticsJobName": {
|
||||
"type": "string",
|
||||
"metadata": {
|
||||
"description": "Required. Stream Analytics Job Name"
|
||||
}
|
||||
},
|
||||
"numberOfStreamingUnits": {
|
||||
"type": "int",
|
||||
"allowedValues": [
|
||||
1,
|
||||
3,
|
||||
6,
|
||||
12,
|
||||
18,
|
||||
24,
|
||||
30,
|
||||
36,
|
||||
42,
|
||||
48
|
||||
],
|
||||
"defaultValue": "1",
|
||||
"metadata": {
|
||||
"description": "Optional. Number of Streaming Units"
|
||||
}
|
||||
},
|
||||
"location": {
|
||||
"type": "string",
|
||||
"defaultValue": "[resourceGroup().location]",
|
||||
"metadata": {
|
||||
"description": "Optional. Location for all Resources"
|
||||
}
|
||||
},
|
||||
"cuaId": {
|
||||
"type": "string",
|
||||
"defaultValue": "",
|
||||
"metadata": {
|
||||
"description": "Optional. Customer Usage Attribution id (GUID). This GUID must be previously registered"
|
||||
}
|
||||
},
|
||||
"tagValues": {
|
||||
"type": "object",
|
||||
"defaultValue": "",
|
||||
"metadata": {
|
||||
"description": "Optional. Azure Resource Tags object"
|
||||
}
|
||||
}
|
||||
},
|
||||
"variables": {
|
||||
"streamAnalyticsName": "[parameters('streamAnalyticsJobName')]",
|
||||
"streamAnalyticsResourceId": "[resourceId('Microsoft.StreamAnalytics/StreamingJobs',parameters('streamAnalyticsJobName'))]",
|
||||
"streamAnalyticsApiVersion": "2016-03-01",
|
||||
"pidName": "[concat('pid-', parameters('cuaId'))]"
|
||||
},
|
||||
"resources": [
|
||||
{
|
||||
"condition": "[not(empty(parameters('cuaId')))]",
|
||||
"type": "Microsoft.Resources/deployments",
|
||||
"apiVersion": "2018-02-01",
|
||||
"name": "[variables('pidName')]",
|
||||
"properties": {
|
||||
"mode": "Incremental",
|
||||
"template": {
|
||||
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
|
||||
"contentVersion": "1.0.0.0",
|
||||
"resources": []
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "Microsoft.StreamAnalytics/StreamingJobs",
|
||||
"apiVersion": "[variables('streamAnalyticsApiVersion')]",
|
||||
"name": "[parameters('streamAnalyticsJobName')]",
|
||||
"location": "[parameters('location')]",
|
||||
"tags": "[if(empty(parameters('tagValues')), json('null'), parameters('tagValues'))]",
|
||||
"properties": {
|
||||
"sku": {
|
||||
"name": "standard"
|
||||
},
|
||||
"outputErrorPolicy": "stop",
|
||||
"eventsOutOfOrderPolicy": "adjust",
|
||||
"eventsOutOfOrderMaxDelayInSeconds": 0,
|
||||
"eventsLateArrivalMaxDelayInSeconds": 5,
|
||||
"dataLocale": "en-US",
|
||||
"inputs": [],
|
||||
"transformation": {
|
||||
"name": "Transformation",
|
||||
"properties": {
|
||||
"streamingUnits": "[parameters('numberOfStreamingUnits')]",
|
||||
"query": "SELECT\r\n *\r\nINTO\r\n [YourOutputAlias]\r\nFROM\r\n [YourInputAlias]"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"outputs": {
|
||||
"streamAnalyticsName": {
|
||||
"type": "string",
|
||||
"value": "[variables('streamAnalyticsName')]",
|
||||
"metadata": {
|
||||
"description": "The Name of the Stream Analytics"
|
||||
}
|
||||
},
|
||||
"streamAnalyticsResourceId": {
|
||||
"type": "string",
|
||||
"value": "[variables('streamAnalyticsResourceId')]",
|
||||
"metadata": {
|
||||
"description": "The Resource Id of the Stream Analytics"
|
||||
}
|
||||
},
|
||||
"streamAnalyticsResourceGroup": {
|
||||
"type": "string",
|
||||
"value": "[resourceGroup().name]",
|
||||
"metadata": {
|
||||
"description": "The name of the Resource Group with the Stream Analytics"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,39 @@
|
|||
# Stream Analytics
|
||||
|
||||
This module deploys a Standard Stream Analytics Job
|
||||
|
||||
## Resources
|
||||
|
||||
The following Resources are deployed.
|
||||
|
||||
+ **Microsoft.StreamAnalytics/StreamingJobs**
|
||||
|
||||
## Parameters
|
||||
|
||||
| Parameter Name | Default Value | Required | Description |
|
||||
| :- | :- | :- |:- |
|
||||
| `streamAnalyticsJobName` || **Required** | Stream Analytics Job Name
|
||||
| `numberOfStreamingUnits` | 1 | **Optional** | Number of Streaming Units
|
||||
| `location` | resourceGroup().location | **Optional** | Location for all Resources
|
||||
| `cuaId` || **Optional** | Customer Usage Attribution Id (GUID). This GUID must be previously registered
|
||||
| `tagValues` || **Optional** | Optional. Azure Resource Tags object
|
||||
|
||||
## Outputs
|
||||
|
||||
| Output Name | Description |
|
||||
| :- | :- |
|
||||
| `streamAnalyticsName` | Stream Analytics Name output parameter
|
||||
| `streamAnalyticsResourceId` | Stream Analytics ResourceId output parameter
|
||||
| `streamAnalyticsResourceGroup` | Stream Analytics ResourceGroup output parameter
|
||||
|
||||
## Scripts
|
||||
|
||||
+ There is no Scripts for this Module
|
||||
|
||||
## Considerations
|
||||
|
||||
+ There is no deployment considerations for this Module
|
||||
|
||||
## Additional resources
|
||||
|
||||
+ [Microsoft Stream Analytics template reference](https://docs.microsoft.com/en-us/azure/templates/microsoft.streamanalytics/allversions)
|
|
@ -1,62 +0,0 @@
|
|||
{
|
||||
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json",
|
||||
"contentVersion": "1.0.0.0",
|
||||
"parameters": {
|
||||
"streamAnalyticsJobName": {
|
||||
"type": "string",
|
||||
"minLength": 3,
|
||||
"maxLength": 63,
|
||||
"metadata": {
|
||||
"description": "Stream Analytics Job Name"
|
||||
}
|
||||
},
|
||||
"numberOfStreamingUnits": {
|
||||
"type": "int",
|
||||
"minValue": 1,
|
||||
"maxValue": 48,
|
||||
"allowedValues": [
|
||||
1,
|
||||
3,
|
||||
6,
|
||||
12,
|
||||
18,
|
||||
24,
|
||||
30,
|
||||
36,
|
||||
42,
|
||||
48
|
||||
],
|
||||
"metadata": {
|
||||
"description": "Number of Streaming Units"
|
||||
}
|
||||
}
|
||||
},
|
||||
"variables": {},
|
||||
"resources": [
|
||||
{
|
||||
"type": "Microsoft.StreamAnalytics/StreamingJobs",
|
||||
"apiVersion": "2016-03-01",
|
||||
"name": "[parameters('streamAnalyticsJobName')]",
|
||||
"location": "[resourceGroup().location]",
|
||||
"properties": {
|
||||
"sku": {
|
||||
"name": "standard"
|
||||
},
|
||||
"outputErrorPolicy": "stop",
|
||||
"eventsOutOfOrderPolicy": "adjust",
|
||||
"eventsOutOfOrderMaxDelayInSeconds": 0,
|
||||
"eventsLateArrivalMaxDelayInSeconds": 5,
|
||||
"dataLocale": "en-US",
|
||||
"inputs": [],
|
||||
"transformation": {
|
||||
"name": "Transformation",
|
||||
"properties": {
|
||||
"streamingUnits": "[parameters('numberOfStreamingUnits')]",
|
||||
"query": "SELECT\r\n *\r\nINTO\r\n [YourOutputAlias]\r\nFROM\r\n [YourInputAlias]"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"outputs": {}
|
||||
}
|
Загрузка…
Ссылка в новой задаче