This commit is contained in:
dwas01 2019-09-11 01:45:20 +12:00
Родитель 00082f9472
Коммит 9ff74cfa55
13 изменённых файлов: 753 добавлений и 538 удалений

Просмотреть файл

@ -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. Copyright(c) Microsoft Corporation. All rights reserved.
Microsoft Consulting Services - AzureCAT - VDC Toolkit (v2.0)
File: module.tests.ps1 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 .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 .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. Deployment steps of the script are outlined below.
1) Test Template File Syntax 1) Test Template File Syntax
@ -25,146 +27,145 @@
#Requires -Version 5 #Requires -Version 5
#region Parameters #region Parameters
$here = Split-Path -Parent $MyInvocation.MyCommand.Path $here = Split-Path -Parent $MyInvocation.MyCommand.Path
$here = Join-Path $here ".." $here = Join-Path -Path $here -ChildPath ".."
$template = Split-Path -Leaf $here $template = Split-Path -Leaf $here
$TemplateFileTestCases = @()
ForEach ( $File in (Get-ChildItem (Join-Path "$here" "deploy.json") -Recurse | Select-Object -ExpandProperty Name) ) { #region - Template File Test Cases
$TemplateFileTestCases += @{ TemplateFile = $File } $templateFileTestCases = @()
ForEach ($file in (Get-ChildItem (Join-Path -Path "$here" -ChildPath "deploy.json") -Recurse | Select-Object -ExpandProperty Name)) {
$templateFileTestCases += @{ TemplateFile = $file }
} }
$ParameterFileTestCases = @() #endregion
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 } #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 = @(); #endregion
ForEach ( $File in (Get-ChildItem (Join-Path "$here" "deploy.json") ) ) {
$Module = [PSCustomObject]@{ #region - Module Test Cases
$modules = @()
ForEach ($file in (Get-ChildItem (Join-Path -Path "$here" -ChildPath "deploy.json"))) {
$module = [PSCustomObject]@{
'Template' = $null 'Template' = $null
'Parameters' = $null 'Parameters' = $null
} }
$Module.Template = $File.FullName; $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 = @()
$Parameters += (Join-Path "$here" "Tests" -AdditionalChildPath @("$ParameterFile") ) 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; $Module.Parameters = $Parameters
$Modules += @{ Module = $Module }; $Modules += @{Module = $Module}
} }
#endregion
#endregion #endregion
#region Run Pester Test Script #region - Run Pester Test Script
Describe "Template: $template - Storage Accounts" -Tags Unit { Describe "Template: $template - EventHub Namespace" -Tags -Unit {
#region - Template File Syntax
Context "Template File Syntax" { Context "Template File Syntax" {
It "Has a JSON template file" { 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 { It "Converts from JSON and has the expected properties" -TestCases $templateFileTestCases {
Param( $TemplateFile ) param($templateFile)
$expectedProperties = '$schema', $expectedProperties = '$schema',
'contentVersion', 'contentVersion',
'parameters', 'parameters',
'variables', 'variables',
'resources', 'resources',
'outputs' | Sort-Object 'outputs' | Sort-Object
$templateProperties = (Get-Content (Join-Path "$here" "$TemplateFile") ` $templateProperties = (Get-Content (Join-Path -Path "$here" -ChildPath "$templateFile") `
| ConvertFrom-Json -ErrorAction SilentlyContinue) ` | ConvertFrom-Json -ErrorAction SilentlyContinue) `
| Get-Member -MemberType NoteProperty ` | Get-Member -MemberType NoteProperty `
| Sort-Object -Property Name ` | Sort-Object -Property Name `
| ForEach-Object Name | ForEach-Object Name
$templateProperties | Should Be $expectedProperties $templateProperties | Should -Be $expectedProperties
} }
} }
#endregion
#region - Parameter File Syntax
Context "Parameter File Syntax" { Context "Parameter File Syntax" {
It "Parameter file does not contains the expected properties" -TestCases $ParameterFileTestCases { It "Parameter file does not contains the expected properties" -TestCases $parameterFileTestCases {
Param( $ParameterFile ) param($parameterFile)
$expectedProperties = '$schema', $expectedProperties = '$schema',
'contentVersion', 'contentVersion',
'parameters' | Sort-Object 'parameters' | Sort-Object
Write-Host $ParameterFile Write-Output $parameterFile
Join-Path "$here" "$ParameterFile" | Write-Host Join-Path -Path "$here" -ChildPath "$parameterFile" | Write-Output
$templateFileProperties = (Get-Content (Join-Path "$here" "$ParameterFile") ` $templateFileProperties = (Get-Content (Join-Path -Path "$here" -ChildPath "$parameterFile") `
| ConvertFrom-Json -ErrorAction SilentlyContinue) ` | ConvertFrom-Json -ErrorAction SilentlyContinue) `
| Get-Member -MemberType NoteProperty ` | Get-Member -MemberType NoteProperty `
| Sort-Object -Property Name ` | Sort-Object -Property Name `
| ForEach-Object Name | ForEach-Object Name
$templateFileProperties | Should Be $expectedProperties $templateFileProperties | Should -Be $expectedProperties
} }
} }
#endregion
#region - Template and Parameter Compactibility
Context "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 { It "Is count of required parameters in template file equal or lesser than count of all parameters in parameters file" -TestCases $modules {
Param( $Module ) param($module)
$requiredParametersInTemplateFile = (Get-Content "$($module.Template)" `
$requiredParametersInTemplateFile = (Get-Content "$($Module.Template)" `
| ConvertFrom-Json -ErrorAction SilentlyContinue).Parameters.PSObject.Properties ` | ConvertFrom-Json -ErrorAction SilentlyContinue).Parameters.PSObject.Properties `
| Where-Object -FilterScript { -not ($_.Value.PSObject.Properties.Name -eq "defaultValue") } ` | Where-Object -FilterScript { -not ($psitem.Value.PSObject.Properties.Name -eq "defaultValue")} `
| Sort-Object -Property Name ` | Sort-Object -Property Name `
| ForEach-Object Name | ForEach-Object Name
ForEach ( $Parameter in $Module.Parameters ) { ForEach ( $parameter in $module.Parameters ) {
$allParametersInParametersFile = (Get-Content $Parameter ` $allParametersInParametersFile = (Get-Content $parameter `
| ConvertFrom-Json -ErrorAction SilentlyContinue).Parameters.PSObject.Properties ` | ConvertFrom-Json -ErrorAction SilentlyContinue).Parameters.PSObject.Properties `
| Sort-Object -Property Name ` | Sort-Object -Property Name `
| ForEach-Object Name | ForEach-Object Name
if ($requiredParametersInTemplateFile.Count -gt $allParametersInParametersFile.Count) { $requiredParametersInTemplateFile.Count | Should -Not -BeGreaterThan $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 "Has all parameters in parameters file existing in template file" -TestCases $Modules { It "Has all parameters in parameters file existing in template file" -TestCases $modules {
Param( $Module ) param($module)
$allParametersInTemplateFile = (Get-Content "$($module.Template)" `
$allParametersInTemplateFile = (Get-Content "$($Module.Template)" `
| ConvertFrom-Json -ErrorAction SilentlyContinue).Parameters.PSObject.Properties ` | ConvertFrom-Json -ErrorAction SilentlyContinue).Parameters.PSObject.Properties `
| Sort-Object -Property Name ` | Sort-Object -Property Name `
| ForEach-Object Name | ForEach-Object Name
ForEach ( $Parameter in $Module.Parameters ) { ForEach ($parameter in $module.Parameters) {
Write-Host "File analyzed: $Parameter"; Write-Output "File analyzed: $parameter"
$allParametersInParametersFile = (Get-Content $Parameter ` $allParametersInParametersFile = (Get-Content $parameter `
| ConvertFrom-Json -ErrorAction SilentlyContinue).Parameters.PSObject.Properties ` | ConvertFrom-Json -ErrorAction SilentlyContinue).Parameters.PSObject.Properties `
| Sort-Object -Property Name ` | Sort-Object -Property Name `
| ForEach-Object Name | ForEach-Object Name
$result = @($allParametersInParametersFile| Where-Object {$allParametersInTemplateFile -notcontains $_}); $result = @($allParametersInParametersFile| Where-Object {$allParametersInTemplateFile -notcontains $psitem})
Write-Host "Invalid parameters: $(ConvertTo-Json $result)"; Write-Output "Invalid parameters: $(ConvertTo-Json $result)"
@($allParametersInParametersFile| Where-Object {$allParametersInTemplateFile -notcontains $_}).Count | Should Be 0; @($allParametersInParametersFile| Where-Object {$allParametersInTemplateFile -notcontains $psitem}).Count | Should -Be 0
} }
} }
It "Has required parameters in template file existing in parameters file" -TestCases $Modules { It "Has required parameters in template file existing in parameters file" -TestCases $modules {
Param( $Module ) param($module)
$requiredParametersInTemplateFile = (Get-Content "$($module.Template)" `
$requiredParametersInTemplateFile = (Get-Content "$($Module.Template)" `
| ConvertFrom-Json -ErrorAction SilentlyContinue).Parameters.PSObject.Properties ` | ConvertFrom-Json -ErrorAction SilentlyContinue).Parameters.PSObject.Properties `
| Where-Object -FilterScript { -not ($_.Value.PSObject.Properties.Name -eq "defaultValue") } ` | Where-Object -FilterScript { -not ($psitem.Value.PSObject.Properties.Name -eq "defaultValue") } `
| Sort-Object -Property Name ` | Sort-Object -Property Name `
| ForEach-Object Name | ForEach-Object Name
ForEach ( $Parameter in $Module.Parameters ) { ForEach ($parameter in $module.Parameters ) {
$allParametersInParametersFile = (Get-Content $parameter `
$allParametersInParametersFile = (Get-Content $Parameter `
| ConvertFrom-Json -ErrorAction SilentlyContinue).Parameters.PSObject.Properties ` | ConvertFrom-Json -ErrorAction SilentlyContinue).Parameters.PSObject.Properties `
| Sort-Object -Property Name ` | Sort-Object -Property Name `
| ForEach-Object Name | ForEach-Object Name
@($requiredParametersInTemplateFile| Where-Object {$allParametersInParametersFile -notcontains $psitem}).Count | Should -Be 0
$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;
} }
} }
} }
#endregion
} }
#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", "contentVersion": "1.0.0.0",
"parameters": { "parameters": {
"location": { "namespaceName": {
"type": "string", "type": "string",
"allowedValues": [
"Australia Southeast",
"Canada Central",
"Central India",
"East US",
"Japan East",
"Southeast Asia",
"UK South",
"West Europe",
"West US 2"
],
"metadata": { "metadata": {
"description": "Optional. Region used when establishing the workspace." "description": "Required. The name of the EventHub namespace"
} }
}, },
"eventHubName": { "eventHubName": {
"type": "string", "type": "string",
"metadata": { "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": { "messageRetentionInDays": {
"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": {
"type": "int", "type": "int",
"allowedValues": [ 1, 2, 4 ],
"defaultValue": 1, "defaultValue": 1,
"minValue": 1,
"maxValue": 7,
"metadata": { "metadata": {
"description": "Optional. MessagingUnits for premium namespace" "description": "Optional. How long to retain the data in EventHub"
} }
}, },
"consumerGroupName": { "partitionCount": {
"type": "string", "type": "int",
"defaultValue": 4,
"minValue": 2,
"maxValue": 32,
"metadata": { "metadata": {
"description": "Optional. Name of Consumer Group" "description": "Optional. Number of partitions chosen"
} }
}, },
"authorizationRulesRootManageSharedAccessKeyName": { "location": {
"defaultValue": "RootManageSharedAccessKey", "type": "string",
"defaultValue": "[resourceGroup().location]",
"metadata": {
"description": "Optional. Location of the Azure Analysis Services server"
}
},
"diagnosticStorageAccountId": {
"type": "string", "type": "string",
"metadata": { "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": { "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": [ "resources": [
{ {
"apiVersion": "2017-04-01", "condition": "[not(empty(parameters('cuaId')))]",
"name": "[parameters('namespaceName')]", "type": "Microsoft.Resources/deployments",
"type": "Microsoft.EventHub/namespaces", "apiVersion": "2018-02-01",
"location": "[parameters('location')]", "name": "[variables('pidName')]",
"sku": {
"name": "[parameters('eventHubSku')]",
"tier": "[parameters('eventHubSku')]",
"capacity": "[parameters('skuCapacity')]"
},
"tags": {
"displayName": "[parameters('namespaceName')]"
},
"properties": {},
"resources": [
{
"apiVersion": "2017-04-01",
"name": "[parameters('eventHubName')]",
"type": "eventhubs",
"dependsOn": [
"[concat('Microsoft.EventHub/namespaces/', parameters('namespaceName'))]"
],
"properties": {},
"resources": [
{
"apiVersion": "2017-04-01",
"name": "[parameters('consumerGroupName')]",
"type": "consumergroups",
"dependsOn": [ "[parameters('eventHubName')]" ],
"properties": { "properties": {
"userMetadata": "User Metadata" "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')]",
"tags": {
"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
},
"resources": [
{
"type": "Microsoft.EventHub/namespaces/providers/diagnosticSettings",
"apiVersion": "2017-05-01-preview",
"name": "[concat(variables('namespaceName'), '/','Microsoft.Insights/service')]",
"location": "[parameters('location')]",
"dependsOn": [
"[variables('namespaceResourceId')]"
],
"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", "type": "Microsoft.EventHub/namespaces/AuthorizationRules",
"name": "[concat(parameters('namespaceName'), '/', parameters('authorizationRulesRootManageSharedAccessKeyName'))]",
"apiVersion": "2017-04-01", "apiVersion": "2017-04-01",
"name": "[concat(parameters('namespaceName'),'/RootManageSharedAccessKey')]",
"location": "[parameters('location')]", "location": "[parameters('location')]",
"scale": null, "dependsOn": [
"[variables('namespaceResourceId')]"
],
"properties": { "properties": {
"rights": [ "rights": [
"Listen", "Listen",
"Manage", "Manage",
"Send" "Send"
] ]
}
}, },
{
"type": "Microsoft.EventHub/namespaces/AuthorizationRules",
"apiVersion": "2017-04-01",
"name": "[concat(parameters('namespaceName'),'/SendListenAccess')]",
"location": "[parameters('location')]",
"dependsOn": [ "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": { "outputs": {
"diagnosticEventHubName": { "namespaceName": {
"type": "string", "type": "string",
"value": "[parameters('eventHubName')]" "value": "[variables('namespaceName')]",
"metadata": {
"description": "The Name of the EventHub Namespace"
}
}, },
"diagnosticsEventHubAuthRuleId": { "namespaceResourceId": {
"type": "string", "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", "type": "string",
"value": "[resourceGroup().id]" "value": "[resourceGroup().name]",
"metadata": {
"description": "The name of the Resource Group with the EventHub Namespace"
}
}, },
"diagnosticsResourceGroupName": { "namespaceConnectionString": {
"type": "string", "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)