зеркало из https://github.com/Azure/vdc.git
event.hub module updates
This commit is contained in:
Родитель
00082f9472
Коммит
9ff74cfa55
|
@ -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)
|
|
@ -0,0 +1,170 @@
|
|||
<#
|
||||
.NOTES
|
||||
==============================================================================================
|
||||
Copyright(c) Microsoft Corporation. All rights reserved.
|
||||
|
||||
Microsoft Consulting Services - AzureCAT - VDC Toolkit (v2.0)
|
||||
|
||||
File: event.hub.akv.secrects.ps1
|
||||
|
||||
Purpose: Set EventHub Namespace Secrets Automation Script
|
||||
|
||||
Version: 2.0.0.0 - 1st September 2019 - Azure Virtual Datacenter Development Team
|
||||
==============================================================================================
|
||||
|
||||
.SYNOPSIS
|
||||
Set EventHub Namespace Key Vault Secrets Automation Script
|
||||
|
||||
.DESCRIPTION
|
||||
Set EventHub Namespace Key Vault Secrets Automation Script
|
||||
|
||||
Deployment steps of the script are outlined below.
|
||||
1) Set Azure KeyVault Parameters
|
||||
2) Set EventHub Namespace Parameters
|
||||
3) Create Azure KeyVault Secret
|
||||
|
||||
.PARAMETER keyVaultName
|
||||
Specify the Azure KeyVault Name parameter.
|
||||
|
||||
.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>.\event.hub.akv.secrects.ps1
|
||||
-keyVaultName "$(keyVaultName)"
|
||||
-namespaceName "$(namespaceName)"
|
||||
-namespaceResourceId "$(namespaceResourceId)"
|
||||
-namespaceResourceGroup "$(namespaceResourceGroup)"
|
||||
-namespaceConnectionString "$(namespaceConnectionString)"
|
||||
-sharedAccessPolicyPrimaryKey "$(sharedAccessPolicyPrimaryKey)"
|
||||
#>
|
||||
|
||||
#Requires -Version 5
|
||||
#Requires -Module Az.KeyVault
|
||||
|
||||
[CmdletBinding()]
|
||||
param
|
||||
(
|
||||
[Parameter(Mandatory = $false)]
|
||||
[string]$keyVaultName,
|
||||
|
||||
[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
|
||||
)
|
||||
|
||||
#region - Key Vault Parameters
|
||||
if (-not [string]::IsNullOrWhiteSpace($PSBoundParameters['keyVaultName']))
|
||||
{
|
||||
Write-Output "KeyVault Name: $keyVaultName"
|
||||
$kVSecretParameters = @{ }
|
||||
|
||||
#region - EventHub Namespace Parameters
|
||||
if (-not [string]::IsNullOrWhiteSpace($PSBoundParameters['namespaceName']))
|
||||
{
|
||||
Write-Output "EventHub Namespace Name: $namespaceName"
|
||||
$kVSecretParameters.Add("EventHub--namespace--Name", $($namespaceName))
|
||||
}
|
||||
else
|
||||
{
|
||||
Write-Output "EventHub Namespace Name: []"
|
||||
}
|
||||
|
||||
if (-not [string]::IsNullOrWhiteSpace($PSBoundParameters['namespaceResourceId']))
|
||||
{
|
||||
Write-Output "namespace ResourceId: $namespaceResourceId"
|
||||
$kVSecretParameters.Add("EventHub--namespace--ResourceId", $($namespaceResourceId))
|
||||
}
|
||||
else
|
||||
{
|
||||
Write-Output "EventHub Namespace ResourceId: []"
|
||||
}
|
||||
|
||||
if (-not [string]::IsNullOrWhiteSpace($PSBoundParameters['namespaceResourceGroup']))
|
||||
{
|
||||
Write-Output "EventHub Namespace ResourceGroup: $namespaceResourceGroup"
|
||||
$kVSecretParameters.Add("EventHub--namespace--ResourceGroup", $($namespaceResourceGroup))
|
||||
}
|
||||
else
|
||||
{
|
||||
Write-Output "EventHub Namespace ResourceGroup: []"
|
||||
}
|
||||
|
||||
if (-not [string]::IsNullOrWhiteSpace($PSBoundParameters['namespaceConnectionString']))
|
||||
{
|
||||
Write-Output "EventHub Namespace ConnectionString: $namespaceConnectionString"
|
||||
$kVSecretParameters.Add("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"
|
||||
$kVSecretParameters.Add("EventHub--namespace--SharedAccessPolicyPrimaryKey", $($sharedAccessPolicyPrimaryKey))
|
||||
}
|
||||
else
|
||||
{
|
||||
Write-Output "EventHub Namespace Shared Access Policy Primary Key: []"
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region - Set Azure KeyVault Secret
|
||||
$kVSecretParameters.Keys | ForEach-Object {
|
||||
$key = $psitem
|
||||
$value = $kVSecretParameters.Item($psitem)
|
||||
|
||||
if (-not [string]::IsNullOrWhiteSpace($value))
|
||||
{
|
||||
Write-Output "Key Vault Secret: $key : $value"
|
||||
|
||||
$value = $kVSecretParameters.Item($psitem)
|
||||
|
||||
Write-Output "Setting Secret for $key"
|
||||
$paramSetAzKeyVaultSecret = @{
|
||||
VaultName = $keyVaultName
|
||||
Name = $key
|
||||
SecretValue = (ConvertTo-SecureString $value -AsPlainText -Force)
|
||||
Verbose = $true
|
||||
ErrorAction = 'SilentlyContinue'
|
||||
}
|
||||
Set-AzKeyVaultSecret @paramSetAzKeyVaultSecret
|
||||
}
|
||||
else
|
||||
{
|
||||
Write-Output "KeyVault Secret: []"
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
else
|
||||
{
|
||||
Write-Output "KeyVault Name: []"
|
||||
}
|
||||
#endregion
|
|
@ -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,27 +0,0 @@
|
|||
{
|
||||
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentParameters.json#",
|
||||
"contentVersion": "1.0.0.0",
|
||||
"parameters": {
|
||||
"location": {
|
||||
"value": "West US 2"
|
||||
},
|
||||
"eventHubName": {
|
||||
"value": "org-event-hub-name"
|
||||
},
|
||||
"eventHubSku": {
|
||||
"value": "Standard"
|
||||
},
|
||||
"namespaceName": {
|
||||
"value": "org-eventhubnamespace"
|
||||
},
|
||||
"skuCapacity": {
|
||||
"value": 1
|
||||
},
|
||||
"consumerGroupName": {
|
||||
"value": "org-consumer"
|
||||
},
|
||||
"authorizationRulesRootManageSharedAccessKeyName": {
|
||||
"value": "RootManageSharedAccessKey"
|
||||
}
|
||||
}
|
||||
}
|
|
@ -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,140 +1,324 @@
|
|||
{
|
||||
"$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": {
|
||||
"location": {
|
||||
"namespaceName": {
|
||||
"type": "string",
|
||||
"allowedValues": [
|
||||
"Australia Southeast",
|
||||
"Canada Central",
|
||||
"Central India",
|
||||
"East US",
|
||||
"Japan East",
|
||||
"Southeast Asia",
|
||||
"UK South",
|
||||
"West Europe",
|
||||
"West US 2"
|
||||
],
|
||||
"metadata": {
|
||||
"description": "Optional. Region used when establishing the workspace."
|
||||
"description": "Required. The name of the EventHub namespace"
|
||||
}
|
||||
},
|
||||
"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."
|
||||
"description": "Required. The name of the EventHub"
|
||||
}
|
||||
},
|
||||
"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"
|
||||
}
|
||||
},
|
||||
"skuCapacity": {
|
||||
"messageRetentionInDays": {
|
||||
"type": "int",
|
||||
"allowedValues": [ 1, 2, 4 ],
|
||||
"defaultValue": 1,
|
||||
"minValue": 1,
|
||||
"maxValue": 7,
|
||||
"metadata": {
|
||||
"description": "Optional. MessagingUnits for premium namespace"
|
||||
"description": "Optional. How long to retain the data in EventHub"
|
||||
}
|
||||
},
|
||||
"consumerGroupName": {
|
||||
"type": "string",
|
||||
"partitionCount": {
|
||||
"type": "int",
|
||||
"defaultValue": 4,
|
||||
"minValue": 2,
|
||||
"maxValue": 32,
|
||||
"metadata": {
|
||||
"description": "Optional. Name of Consumer Group"
|
||||
"description": "Optional. Number of partitions chosen"
|
||||
}
|
||||
},
|
||||
"authorizationRulesRootManageSharedAccessKeyName": {
|
||||
"defaultValue": "RootManageSharedAccessKey",
|
||||
"location": {
|
||||
"type": "string",
|
||||
"defaultValue": "[resourceGroup().location]",
|
||||
"metadata": {
|
||||
"description": "Optional. Location of the Azure Analysis Services server"
|
||||
}
|
||||
},
|
||||
"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"
|
||||
}
|
||||
},
|
||||
"tagEnvironment": {
|
||||
"type": "string",
|
||||
"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"
|
||||
}
|
||||
}
|
||||
},
|
||||
"variables": {
|
||||
"namespaceName": "[parameters('namespaceName')]",
|
||||
"namespaceResourceId": "[resourceId('Microsoft.EventHub/Namespaces',parameters('namespaceName'))]",
|
||||
"diagnosticStorageAccountId": "[parameters('diagnosticStorageAccountId')]",
|
||||
"diagnosticWorkspaceId": "[parameters('logAnalyticsWorkspaceId')]",
|
||||
"defaultSASKeyName": "RootManageSharedAccessKey",
|
||||
"authRuleResourceId": "[resourceId('Microsoft.EventHub/namespaces/authorizationRules', parameters('namespaceName'), variables('defaultSASKeyName'))]",
|
||||
"apiVersion": "[providers('Microsoft.EventHub','namespaces').apiVersions[0]]",
|
||||
"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",
|
||||
"apiVersion": "[variables('apiVersion')]",
|
||||
"name": "[parameters('namespaceName')]",
|
||||
"location": "[parameters('location')]",
|
||||
"sku": {
|
||||
"name": "[parameters('eventHubSku')]",
|
||||
"tier": "[parameters('eventHubSku')]",
|
||||
"capacity": "[parameters('skuCapacity')]"
|
||||
},
|
||||
"tags": {
|
||||
"displayName": "[parameters('namespaceName')]"
|
||||
"Environment": "[parameters('tagEnvironment')]",
|
||||
"Application": "[parameters('tagApplication')]",
|
||||
"Project": "[parameters('tagProject')]",
|
||||
"Owner": "[parameters('tagOwner')]",
|
||||
"OwnerEmail": "[parameters('tagOwnerEmail')]"
|
||||
},
|
||||
"sku": {
|
||||
"name": "Standard",
|
||||
"tier": "Standard",
|
||||
"capacity": 1
|
||||
},
|
||||
"properties": {
|
||||
"zoneRedundant": false,
|
||||
"isAutoInflateEnabled": false,
|
||||
"maximumThroughputUnits": 0,
|
||||
"kafkaEnabled": false
|
||||
},
|
||||
"properties": {},
|
||||
"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'))]"
|
||||
"[variables('namespaceResourceId')]"
|
||||
],
|
||||
"properties": {},
|
||||
"resources": [
|
||||
{
|
||||
"apiVersion": "2017-04-01",
|
||||
"name": "[parameters('consumerGroupName')]",
|
||||
"type": "consumergroups",
|
||||
"dependsOn": [ "[parameters('eventHubName')]" ],
|
||||
"properties": {
|
||||
"userMetadata": "User Metadata"
|
||||
"properties": {
|
||||
"storageAccountId": "[variables('diagnosticStorageAccountId')]",
|
||||
"workspaceId": "[variables('diagnosticWorkspaceId')]",
|
||||
"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",
|
||||
"name": "[concat(parameters('namespaceName'),'/RootManageSharedAccessKey')]",
|
||||
"location": "[parameters('location')]",
|
||||
"scale": null,
|
||||
"dependsOn": [
|
||||
"[variables('namespaceResourceId')]"
|
||||
],
|
||||
"properties": {
|
||||
"rights": [
|
||||
"Listen",
|
||||
"Manage",
|
||||
"Send"
|
||||
]
|
||||
},
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "Microsoft.EventHub/namespaces/AuthorizationRules",
|
||||
"apiVersion": "2017-04-01",
|
||||
"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": "2017-04-01",
|
||||
"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": "2017-04-01",
|
||||
"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('apiVersion')).primaryConnectionString]",
|
||||
"metadata": {
|
||||
"description": "The connection string of the EventHub Namespace"
|
||||
}
|
||||
},
|
||||
"sharedAccessPolicyPrimaryKey": {
|
||||
"type": "string",
|
||||
"value": "[listkeys(variables('authRuleResourceId'), variables('apiVersion')).primaryKey]"
|
||||
},
|
||||
"metadata": {
|
||||
"description": "The shared access policy primary key for the EventHub Namespace"
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,56 @@
|
|||
# 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 Event Hub
|
||||
| `partitionCount` | 4 | **Optional** | Number of partitions chosen
|
||||
| `location` || **Optional** | Location of the Azure Analysis Services server
|
||||
| `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
|
||||
|
||||
## 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
|
||||
|
||||
| Script Name | Description |
|
||||
| :- | :- |
|
||||
| `event.hub.akv.secrects.ps1` | Set EventHub Namespace KeyVault Secrets Automation Script
|
||||
|
||||
## 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)
|
Загрузка…
Ссылка в новой задаче