Skip to content

Commit dd70dfb

Browse files
committed
minor changes
1 parent d6f571a commit dd70dfb

17 files changed

+135
-2951
lines changed

.github/workflows/build.yml

+7-7
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,23 @@
1+
name: Publish to Powershell Gallery
2+
13
on:
24
push:
35
branches:
46
- master
57

68
jobs:
7-
build:
8-
9-
runs-on: windows-2019
10-
9+
PublishtoGallery:
10+
runs-on: windows-latest
1111
steps:
12-
- uses: actions/checkout@v1
12+
- uses: actions/checkout@v2
1313
- name: Install Prerequisites
1414
run: .\build\vsts-prerequisites.ps1
1515
shell: powershell
1616
- name: Validate
1717
run: .\build\vsts-validate.ps1
1818
shell: powershell
19-
- name: Build
19+
- name: Publish
2020
run: .\build\vsts-build.ps1 -ApiKey $env:APIKEY
2121
shell: powershell
2222
env:
23-
APIKEY: ${{ secrets.ApiKey }}
23+
APIKEY: ${{ secrets.APIKEY }}

AzDnsAsCode/bin/readme.md

-7
This file was deleted.

AzDnsAsCode/functions/Get-AzDnsAsCodeZoneConfig.ps1

+26-27
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
function Get-AzDnsAsCodeZoneConfig
2-
{
1+
function Get-AzDnsAsCodeZoneConfig
2+
{
33
<#
44
.SYNOPSIS
55
Execute a request against the Azure Management Api to set DNS Entries
@@ -8,58 +8,57 @@ function Get-AzDnsAsCodeZoneConfig
88
Execute a request against the Azure Management Api to set DNS Entries
99
1010
.EXAMPLE
11-
PS C:\> Get-AzDnsAsCodeZoneConfig -Method Get -DNSZone contoso.com -Domain api
11+
PS C:\> Get-AzDnsAsCodeZoneConfig -Method Get -DNSZone contoso.com -Domain api
1212
PS C:\> Get-AzDnsAsCodeZoneConfig -Method Get -DNSZone contoso.com -Type A
13+
14+
Get Config for a zone
1315
#>
1416

1517
[CmdletBinding(DefaultParameterSetName='default')]
1618
param (
17-
[Parameter (Mandatory=$true)][ValidateSet('GET')][string]$Method,
19+
[Parameter (Mandatory=$false)][ValidateSet('GET')][string]$Method,
1820
[Parameter (Mandatory=$false)][ValidateSet('A','AAAA','CNAME','MX','NS','SOA','SRV','TXT','PTR')][string]$Type,
19-
[Parameter (Mandatory=$true)][ValidatePattern("^((?!-))(xn--)?[a-z0-9][a-z0-9-_]{0,61}[a-z0-9]{0,1}\.(xn--)?([a-z0-9\-]{1,61}|[a-z0-9-]{1,30}\.[a-z]{2,})$")]$DNSZone,
21+
[Parameter (Mandatory=$false)][ValidatePattern("^((?!-))(xn--)?[a-z0-9][a-z0-9-_]{0,61}[a-z0-9]{0,1}\.(xn--)?([a-z0-9\-]{1,61}|[a-z0-9-]{1,30}\.[a-z]{2,})$")]$DNSZone,
2022
[Parameter (Mandatory=$false)][ValidatePattern("(^@)|\w+")][string]$Domain,
2123
# Azure required Parameters
22-
[Parameter (Mandatory=$false)][String]$ApiVersion = '2018-05-01',
23-
[Parameter (Mandatory=$true)][String]$SubscriptionID = '',
24-
[Parameter (Mandatory=$true)][String]$TenantId = '',
25-
[Parameter (Mandatory=$true)][String]$ResourceGroup = ''
24+
[Parameter (Mandatory=$true)][String]$SubscriptionID,
25+
[Parameter (Mandatory=$true)][String]$TenantId,
26+
[Parameter (Mandatory=$true)][String]$ResourceGroup
2627
)
2728

28-
29-
#region URL
30-
if ($type -and $Domain) {
31-
$uri = "https://management.azure.com/subscriptions/$SubscriptionId/resourceGroups/$ResourceGroup/providers/Microsoft.Network/dnszones/$DNSZone/$($Type)/$($Domain)?api-version=$APIversion"
29+
#region URL
30+
if ($type -and $Domain) {
31+
$uri = "https://management.azure.com/subscriptions/$SubscriptionId/resourceGroups/$ResourceGroup/providers/Microsoft.Network/dnszones/$DNSZone/$($Type)/$($Domain)?api-version=$($script:APIversion)"
3232
}
33-
elseif ($Type) {
34-
$uri = "https://management.azure.com/subscriptions/$SubscriptionId/resourceGroups/$ResourceGroup/providers/Microsoft.Network/dnszones/$DNSZone/$($Type)?api-version=$APIversion"
33+
elseif ($Type) {
34+
$uri = "https://management.azure.com/subscriptions/$SubscriptionId/resourceGroups/$ResourceGroup/providers/Microsoft.Network/dnszones/$DNSZone/$($Type)?api-version=$($script:APIversion)"
3535
}
36-
else {
37-
$uri = "https://management.azure.com/subscriptions/$SubscriptionId/resourceGroups/$ResourceGroup/providers/Microsoft.Network/dnszones/$DNSZone/all?api-version=$APIversion"
36+
else {
37+
$uri = "https://management.azure.com/subscriptions/$SubscriptionId/resourceGroups/$ResourceGroup/providers/Microsoft.Network/dnszones/$DNSZone/all?api-version=$($script:APIversion)"
3838
}
3939
#endregion URL
4040

4141
#region API Call
42-
$uri
4342
$response = AzAPICall -uri $uri -method Get -listenOn Content
44-
"---------------------------------------------------------------------------------------------------"
45-
"Response -> "
46-
#endregion API Call
43+
Write-Output "---------------------------------------------------------------------------------------------------"
44+
Write-Output "Response -> "
45+
#endregion API Call
4746
#region Output
48-
if ($response.Count) {
49-
"Anzahl Records: " + $response.value.Count
47+
if ($response.Count) {
48+
Write-Output "Anzahl Records: " + $response.value.Count
5049
$output = $response.value | Select-Object name, `
5150
@{Name = "Type"; Expression = {($_.properties | Get-Member | Where-Object {$_.Name -like "*Recor*"}).Name -replace "Records","" -replace "Record",""}}, `
5251
@{Name = "TTL"; Expression = {"$($_.properties.TTL)"}}, `
5352
@{Name = "Properties"; Expression = { [string]($_.properties | Select-Object -ExpandProperty "*Recor*")}}, `
5453
@{Name = "MetaData"; Expression = {"$($_.properties.metadata)"}} | Format-Table -AutoSize
55-
}
54+
}
5655
else {
57-
"Anzahl Records: 1"
58-
$output = $response | Select-Object name, `
56+
Write-Output "Anzahl Records: 1"
57+
$output = $response.Value | Select-Object name, `
5958
@{Name = "Type"; Expression = {($_.properties | Get-Member | Where-Object {$_.Name -like "*Recor*"}).Name -replace "Records","" -replace "Record",""}}, `
6059
@{Name = "TTL"; Expression = {"$($_.properties.TTL)"}}, `
6160
@{Name = "Properties"; Expression = { [string]($_.properties | Select-Object -ExpandProperty "*Recor*")}}, `
62-
@{Name = "MetaData"; Expression = {"$($_.properties.metadata)"}} | Format-Table -AutoSize
61+
@{Name = "MetaData"; Expression = {"$($_.properties.metadata)"}} | Format-Table -AutoSize
6362
}
6463
return $output
6564
#endregion Output
+12-12
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
1-
function New-AzDnsAsCodeZone
2-
{
1+
function New-AzDnsAsCodeZone
2+
{
33
<#
44
.SYNOPSIS
55
Execute a request to create a new Azure DNS Zone
66
77
.DESCRIPTION
88
Execute a request to create a new Azure DNS Zone
99
10-
1110
.PARAMETER Name
1211
Which rest method to use.
1312
Defaults to PUT
@@ -16,6 +15,8 @@ function New-AzDnsAsCodeZone
1615
PS C:\> New-AzDnsAsCodeZone -Name 'contoso.com' -RessourceGroupid '<RessourceGroupid>' -SubscriptionId '<SubscriptionId>'
1716
1817
PS C:\> New-AzDnsAsCodeZone -Name 'contoso.com' -RessourceGroupid '<RessourceGroupid>' -SubscriptionId '<SubscriptionId>' -MetaData @{ 'Company'= 'consto' }
18+
19+
Set up a new Zone in Azure DNS Service
1920
#>
2021
[CmdletBinding()]
2122
param (
@@ -27,27 +28,26 @@ function New-AzDnsAsCodeZone
2728

2829
[Parameter (Mandatory=$true)][String]$TenantId,
2930

30-
[Parameter (Mandatory=$true)][String]$ResourceGroup,
31-
32-
[Parameter (Mandatory=$false)][String]$ApiVersion = '2018-05-01'
31+
[Parameter (Mandatory=$true)][String]$ResourceGroup
3332
)
3433
$ScriptDir = Split-Path $script:MyInvocation.MyCommand.Path
3534
$body = Get-Content $ScriptDir\internal\configurations\newzone.json #| ConvertFrom-Json
3635
<# MetaData
37-
If ($Null -eq $MetaData) {
36+
If ($Null -eq $MetaData) {
3837
#$body.tags.psobject.properties.Remove('key1')
3938
$body.PSObject.Properties.Remove('tags')
4039
}
41-
else {
40+
else {
4241
$body.tags = $MetaData
4342
}#>
4443
#$body | ConvertTo-Json -Depth 10
4544

46-
$uri = "https://management.azure.com/subscriptions/$SubscriptionId/resourceGroups/$ResourceGroup/providers/Microsoft.Network/dnszones/$($DNSZoneName)?api-version=$APIversion"
45+
$uri = "https://management.azure.com/subscriptions/$SubscriptionId/resourceGroups/$ResourceGroup/providers/Microsoft.Network/dnszones/$($DNSZoneName)?api-version=$($script:APIversion)"
4746

4847
$response = AzAPICall -uri $Uri -Method PUT -currentTask "Creating new DNSZone $($DNSZoneName)" -body $body -listenOn Content
4948
###Todo check if Zone is already exist with (Request Header IF-MATCH)
50-
$response | Select-Object name, properties.maxNumberOfRecordSets `
51-
@{Name = "NameServer"; Expression = {"$($_.properties.nameServers)"}} | Format-Table -AutoSize
49+
$response | Select-Object name, `
50+
@{Name = "maxNumberOfRecordSets"; Expression = {"$($_.properties.maxNumberOfRecordSets)"}}, `
51+
@{Name = "NameServer"; Expression = {"$($_.properties.nameServers)"}} | Format-Table -AutoSize
5252

53-
}
53+
}
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
function Remove-AzDnsAsCodeZone
2-
{
1+
function Remove-AzDnsAsCodeZone
2+
{
33
<#
44
.SYNOPSIS
55
Execute a request to create a new Azure DNS Zone
@@ -13,7 +13,9 @@ function Remove-AzDnsAsCodeZone
1313
Defaults to PUT
1414
1515
.EXAMPLE
16-
PS C:\> emove-AzDnsAsCodeZone -Name 'contoso.com' -RessourceGroupid '<RessourceGroupid>' -SubscriptionId '<SubscriptionId>'
16+
PS C:\> Remove-AzDnsAsCodeZone -Name 'contoso.com' -RessourceGroupid '<RessourceGroupid>' -SubscriptionId '<SubscriptionId>'
17+
18+
Remove a DNS Zone inside of Azure DNS Service
1719
#>
1820
[CmdletBinding()]
1921
param (
@@ -23,14 +25,21 @@ function Remove-AzDnsAsCodeZone
2325

2426
[Parameter (Mandatory=$true)][String]$TenantId,
2527

26-
[Parameter (Mandatory=$true)][String]$ResourceGroup,
27-
28-
[Parameter (Mandatory=$false)][String]$ApiVersion = '2018-05-01'
28+
[Parameter (Mandatory=$true)][String]$ResourceGroup
2929
)
3030

31-
$uri = "https://management.azure.com/subscriptions/$SubscriptionId/resourceGroups/$ResourceGroup/providers/Microsoft.Network/dnszones/$($Name)?api-version=$APIversion"
32-
33-
$response = AzAPICall -uri $uri -Method DELETE -currentTask "Remove DNSZone $($Name)"
31+
#region Set uri
32+
$uri = "https://management.azure.com/subscriptions/$SubscriptionId/resourceGroups/$ResourceGroup/providers/Microsoft.Network/dnszones/$($Name)?api-version=$($script:APIversion)"
33+
#endregion Set uri
34+
35+
#region send apicall
36+
Write-Output "Remove DNS Zone $($Name)"
37+
$response = AzAPICall -uri $uri -Method DELETE -currentTask "Remove DNSZone $($Name)"
38+
#endregion send apicall
3439

35-
$response
36-
}
40+
#region response
41+
Write-Output "---------------------------------------------------------------------------------------------------"
42+
Write-Output "Response ->"
43+
$response
44+
#region response
45+
}

AzDnsAsCode/functions/Set-AzDnsAsCodeConfig.ps1

+25-25
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
function Set-AzDnsAsCodeConfig
2-
{
2+
{
33
<#
44
.SYNOPSIS
55
Execute a request against the Azure Management Api to set DNS Entries
@@ -9,6 +9,8 @@
99
1010
.EXAMPLE
1111
PS C:\> Set-AzDnsAsCodeConfig -Method PUT -Type A -DNSZone contoso.com -Domain api -TTL 3600 -Target 127.0.0.1
12+
13+
Set up a new DNS Config for one DNS entry
1214
#>
1315

1416
[CmdletBinding(DefaultParameterSetName='default')]
@@ -17,11 +19,11 @@
1719
[Parameter (Mandatory=$false)][ValidateSet('A','AAAA','CNAME','MX','NS','SOA','SRV','TXT','PTR')][string]$Type,
1820
[Parameter (Mandatory=$true)][ValidatePattern("^((?!-))(xn--)?[a-z0-9][a-z0-9-_]{0,61}[a-z0-9]{0,1}\.(xn--)?([a-z0-9\-]{1,61}|[a-z0-9-]{1,30}\.[a-z]{2,})$")]$DNSZone,
1921
[Parameter (Mandatory=$false)][ValidatePattern("(^@)|\w+")][string]$Domain,
20-
[Parameter (Mandatory=$false)][int]$TTL,
22+
[Parameter (Mandatory=$false)][int]$TTL,
2123
[string]$Target,
22-
# MX Paramter
24+
# MX Paramter
2325
[Parameter(ParameterSetName='MX', Mandatory=$true)][int]$MXPreference,
24-
# SRV Paramter
26+
# SRV Paramter
2527
[Parameter(ParameterSetName='SRV', Mandatory=$true)][int]$SRVPort,
2628
[Parameter(ParameterSetName='SRV', Mandatory=$true)][int]$SRVweight,
2729
[Parameter(ParameterSetName='SRV', Mandatory=$true)][int]$SRVPriority,
@@ -31,37 +33,35 @@
3133
[Parameter(ParameterSetName='SOA')][string]$SOAserialnumber,
3234
[Parameter(ParameterSetName='SOA')][string]$SOArefreshtime,
3335
[Parameter(ParameterSetName='SOA')][string]$SOAretrytime,
34-
[Parameter(ParameterSetName='SOA')][string]$SOAexpireTime,
36+
[Parameter(ParameterSetName='SOA')][string]$SOAexpireTime,
3537
[Parameter(ParameterSetName='SOA')][string]$SOAminimumTTL,
3638
$body, # for Multivalue Entries
3739
[switch]$outputEnabled = $false,
3840
# Azure required Parameters
39-
[Parameter (Mandatory=$false)][String]$ApiVersion = '2018-05-01',
4041
[Parameter (Mandatory=$true)][String]$SubscriptionID,
4142
[Parameter (Mandatory=$true)][String]$TenantId,
4243
[Parameter (Mandatory=$true)][String]$ResourceGroup
4344
)
4445

4546

4647
#region URL
47-
48-
$uri = "https://management.azure.com/subscriptions/$SubscriptionId/resourceGroups/$ResourceGroup/providers/Microsoft.Network/dnszones/$DNSZone/$Type/$($Domain)?api-version=$APIversion"
48+
$uri = "https://management.azure.com/subscriptions/$SubscriptionId/resourceGroups/$ResourceGroup/providers/Microsoft.Network/dnszones/$DNSZone/$Type/$($Domain)?api-version=$($script:APIversion)"
4949
#endregion URL
5050
#region Body
51-
if (-not $body) {
51+
if (-not $body) {
5252
$ScriptDir = Split-Path $script:MyInvocation.MyCommand.Path
5353
$body = Get-Content $ScriptDir\internal\configurations\body.json | ConvertFrom-Json
5454
if ($Method -eq 'PUT') {
5555
switch ($type) {
56-
A {
57-
#Var setzen
56+
A {
57+
#Var setzen
5858
$body.$Method.$type.Value.properties.ARecords[0].ipv4Address = $Target
5959
$body.$Method.$type.Value.properties.TTL = $TTL
6060
$body.$Method.$type.Value.properties.metadata.Key1 = $Domain
6161
$body = $body.$Method.$Type.Value | ConvertTo-Json -Depth 10
6262
}
63-
AAAA {
64-
#Var setzen
63+
AAAA {
64+
#Var setzen
6565
$body.$Method.$type.Value.properties.AAAARecords[0].ipv6Address = $Target
6666
$body.$Method.$type.Value.properties.TTL = $TTL
6767
$body.$Method.$type.Value.properties.metadata.Key1 = $Domain
@@ -73,7 +73,6 @@
7373
$body.$Method.$type.Value.properties.TTL = $TTL
7474
$body.$Method.$type.Value.properties.metadata.Key1 = $Domain
7575
$body = $body.$Method.$Type.Value | ConvertTo-Json -Depth 10
76-
7776
}
7877
MX {
7978
#Var setzen
@@ -82,7 +81,6 @@
8281
$body.$Method.$type.Value.properties.TTL = $TTL
8382
$body.$Method.$type.Value.properties.metadata.Key1 = $Domain
8483
$body = $body.$Method.$Type.Value | ConvertTo-Json -Depth 10
85-
8684
}
8785
NS {
8886
#Var setzen
@@ -134,25 +132,27 @@
134132
else {
135133
$response = AzAPICall -uri $uri -method $Method -body $body -listenOn Content
136134
}
137-
"Response:"
138-
#endregion API Call
135+
Write-Output "---------------------------------------------------------------------------------------------------"
136+
Write-Output "Response:"
137+
#endregion API Call
139138
#region Output
140139
if ($Method -eq 'DELETE' -and [string]::IsNullOrWhiteSpace($response)) {"DELETE complete"}
141-
else {
142-
if ($all) { "Anzahl Records: " + $response.value.Count
143-
$output = $response.Value | Select-Object name, `
144-
@{Name = "Type"; Expression = {($_.properties | Get-Member | Where-Object {$_.Name -like "*Recor*"}).Name -replace "Records","" -replace "Record",""}}, `
145-
@{Name = "TTL"; Expression = {"$($_.properties.TTL)"}}, `
146-
@{Name = "Properties"; Expression = { [string]($_.properties | Select-Object -ExpandProperty "*Recor*")}}, `
147-
@{Name = "MetaData"; Expression = {"$($_.properties.metadata)"}} | Format-Table -AutoSize
140+
else {
141+
if ($all) { "Anzahl Records: " + $response.value.Count
142+
$output = $response.Value | Select-Object name, `
143+
@{Name = "Type"; Expression = {($_.properties | Get-Member | Where-Object {$_.Name -like "*Recor*"}).Name -replace "Records","" -replace "Record",""}}, `
144+
@{Name = "TTL"; Expression = {"$($_.properties.TTL)"}}, `
145+
@{Name = "Properties"; Expression = { [string]($_.properties | Select-Object -ExpandProperty "*Recor*")}}, `
146+
@{Name = "MetaData"; Expression = {"$($_.properties.metadata)"}} | Format-Table -AutoSize
148147
}
149148
else {
150149
$output = $response | Select-Object name, `
151150
@{Name = "Type"; Expression = {($_.properties | Get-Member | Where-Object {$_.Name -like "*Recor*"}).Name -replace "Records","" -replace "Record",""}}, `
152151
@{Name = "TTL"; Expression = {"$($_.properties.TTL)"}}, `
153152
@{Name = "Properties"; Expression = { [string]($_.properties | Select-Object -ExpandProperty "*Recor*")}}, `
154153
@{Name = "MetaData"; Expression = {"$($_.properties.metadata)"}} | Format-Table -AutoSize
155-
}
154+
}
156155
}
157156
#endregion Output
157+
return $output
158158
}

0 commit comments

Comments
 (0)