Skip to content

Commit 0aa5ce4

Browse files
author
Florian Wagner
authored
Adding Documentation (#19)
* Update to support PowerShell Core & Linux Signed-off-by: Florian Wagner <florian.wagner@microsoft.com> * PowerShell style doc - fixed nslookup in CreateSSL Signed-off-by: Florian Wagner <florian.wagner@microsoft.com> * PowerShell style doc - fixed nslookup in CreateSSL Signed-off-by: Florian Wagner <florian.wagner@microsoft.com> * Documentation Update Signed-off-by: Florian Wagner <florian.wagner@microsoft.com> * Filename corrections and adding links Signed-off-by: Florian Wagner <florian.wagner@microsoft.com>
1 parent f426b23 commit 0aa5ce4

55 files changed

Lines changed: 1052 additions & 29 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

Deploy/CreateSSL.ps1

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ param(
3535
[Parameter(HelpMessage="The domain (CN) name for the SSL certificate")]
3636
[string] $YOUR_DOMAIN,
3737

38-
3938
# $True -> Use Let's Encrypt staging for script testing (Bot cannot be reached from Bot Framework Service) - Default: $False
4039
[Parameter(HelpMessage="`$True -> Use Let's Encrypt staging for script testing (Bot cannot be reached from Bot Framework Service) - Default: `$False")]
4140
[bool] $LETS_ENCRYPT_STAGING = $False,
@@ -99,7 +98,6 @@ elseif ($YOUR_DOMAIN -ne $TrafficManager.fqdn) {
9998
Write-Host "### WARNING, there is no CNAME entry for domain '$YOUR_DOMAIN' pointing to '$($TrafficManager.fqdn)'."
10099
Write-Host "### Please check your DNS entry, or create the missing CNAME entry. Sleeping for $waitretrysec seconds and try again..."
101100
Start-Sleep -s $waitretrysec
102-
103101
# Not working in PowerShellCore: $resolved = Resolve-DnsName -Name $YOUR_DOMAIN -DnsOnly 2> $null
104102
# Changing to nslookup
105103
$resolved = nslookup $YOUR_DOMAIN 2> $null

Deploy/HelperFunctions.ps1

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@ function Get-TerraformAutoApproveFlag {
4141
}
4242
}
4343

44-
4544
function Get-ScriptPath {
4645
<#
4746
.SYNOPSIS

Doc/CreateMarkdown-FromPS1.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# CreateMarkdown-FromPS1.ps1
2+
3+
Creates Markdown files from PowerShell Get-Help output
4+
5+
## Description
6+
7+
Creates Markdown files from PowerShell Get-Help output
8+
9+
Helper Tool to create GitHub Markdown files from PS1 scripts.
10+
Will check for all PS1 scripts in a given folder and try to create a markdown file.
11+
If flowcharts are available integrates those into the markdown.
12+
Since this is a helper script for the repos documentation it has limitations on usage
13+
14+
## Parameters
15+
16+
| Name | Type | Required | Default | Description |
17+
| - | - | - | - | - |
18+
| dir | String | true | | Directory with PS1 scripts |
19+
| savepath | String | false | . | Markdown file directory |
20+
21+
## Examples
22+
23+
```powershell
24+
.\CreateMarkdown-FromPS1.ps1 -dir ..\Deploy -savepath .\Deploy
25+
26+
.\CreateMarkdown-FromPS1.ps1 -dir . -savepath .
27+
28+
```
29+

Doc/CreateMarkdown-FromPS1.ps1

Lines changed: 154 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,154 @@
1+
<#
2+
.SYNOPSIS
3+
Creates Markdown files from PowerShell Get-Help output
4+
5+
.DESCRIPTION
6+
Creates Markdown files from PowerShell Get-Help output
7+
8+
Helper Tool to create GitHub Markdown files from PS1 scripts.
9+
Will check for all PS1 scripts in a given folder and try to create a markdown file.
10+
If flowcharts are available integrates those into the markdown.
11+
Since this is a helper script for the repos documentation it has limitations on usage
12+
13+
.EXAMPLE
14+
.\CreateMarkdown-FromPS1.ps1 -dir ..\Deploy -savepath .\Deploy
15+
16+
.EXAMPLE
17+
.\CreateMarkdown-FromPS1.ps1 -dir . -savepath .
18+
19+
.INPUTS
20+
None. You cannot pipe objects.
21+
22+
.OUTPUTS
23+
None.
24+
25+
#>
26+
param(
27+
# Directory with PS1 scripts
28+
[Parameter(Mandatory=$True,HelpMessage="Directory with PS1 scripts")]
29+
[string] $dir,
30+
31+
# Markdown file directory
32+
[Parameter(HelpMessage="Markdown file directory")]
33+
[string] $savepath = "."
34+
)
35+
36+
function Get-ParameterMarkdownTable {
37+
param (
38+
# Get-Help Object
39+
[Parameter(Mandatory=$True,HelpMessage="Get-Help Object")]
40+
[object] $help
41+
)
42+
43+
$result = "| Name | Type | Required | Default | Description |`n| - | - | - | - | - |"
44+
45+
#Write-Host $help
46+
47+
$help.parameters[0].parameter.foreach({
48+
#Write-Host "`nParameter: $_"
49+
# try parse default from description
50+
$description = $_.description.text
51+
$default = ""
52+
if(($_.description.text -match "- Default: (.+)$"))
53+
{
54+
$default = $Matches[1]
55+
$description = $_.description.text.replace("- Default: $default", "")
56+
}
57+
if(($_.defaultValue -ne ""))
58+
{
59+
$default = $_.defaultValue
60+
}
61+
62+
$result += "`n| $($_.name) | $($_.type.name) | $($_.required) | $($default) | $($description) |"
63+
})
64+
65+
return $result
66+
}
67+
68+
function Get-Examples {
69+
param (
70+
# Get-Help Object
71+
[Parameter(Mandatory=$True,HelpMessage="Get-Help Object")]
72+
[object] $help
73+
)
74+
75+
$result = "``````powershell`n"
76+
$help.Examples[0].example.foreach({
77+
#Write-Host "`Examples: $($_.code)"
78+
79+
$result += "$($_.code)`n`n"
80+
})
81+
$result += "```````n";
82+
return $result
83+
}
84+
85+
function Get-FlowChart {
86+
param (
87+
# Filename
88+
[Parameter(Mandatory=$True,HelpMessage="Filename")]
89+
[string] $file
90+
)
91+
92+
$fileparts = $file.Split('.')
93+
$flowchartfile = "flowchart/$($fileparts[0]).flowchart"
94+
if (Test-Path -Path $flowchartfile)
95+
{
96+
# render flowchart
97+
diagrams flowchart $flowchartfile > $null
98+
99+
return "`n`n## Flowchart`n`n<div align='center'>`n`n![Flowchart for $file](../$flowchartfile.svg)`n</div>"
100+
101+
} else {
102+
return ""
103+
}
104+
105+
}
106+
107+
function ConvertHelpToMarkdown {
108+
109+
param (
110+
# PS1 file name
111+
[Parameter(Mandatory=$True,HelpMessage="PS1 file name")]
112+
[object] $file,
113+
114+
# Markdown file directory
115+
[Parameter(HelpMessage="Markdown file directory")]
116+
[string] $savepath = "."
117+
)
118+
119+
Write-Host "Processing $($file.name)..."
120+
$help = Get-Help -Name "$($file.FullName)" -full
121+
#$help
122+
123+
if ($help.description -ne $null)
124+
{
125+
# Headline + SYNOPSIS
126+
$markdown = "# $($file.name)`n`n$($help.synopsis)"
127+
128+
# Description
129+
$markdown += "`n`n## Description`n`n$($help.description.text)"
130+
131+
# Parameters
132+
$parameters = Get-ParameterMarkdownTable -help $help
133+
$markdown += "`n`n## Parameters`n`n$($parameters)"
134+
135+
# Examples
136+
$examples = Get-Examples -help $help
137+
$markdown += "`n`n## Examples`n`n$($examples)"
138+
139+
# flowchart
140+
$markdown += Get-FlowChart -file $file.name
141+
142+
$markdownfile = $file.name.replace("ps1","md")
143+
Set-Content -Path "$savepath/$markdownfile" -Value $markdown
144+
Write-Host "Created $savepath/$markdownfile..."
145+
} else {
146+
Write-Host "Skipped $($file.name)..."
147+
}
148+
}
149+
150+
# Load ps1 files in folder
151+
$FILES = @(Get-ChildItem -Path $dir -File -Recurse) | Where-Object -FilterScript {$_.name.contains(".ps1")}
152+
# Create Markdown files
153+
$FILES.ForEach({ConvertHelpToMarkdown -file $_ -savepath $savepath})
154+

Doc/Deploy/ActivateSSL.md

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# ActivateSSL.ps1
2+
3+
Activate Custom Domain Name SSL Certificate and activate TrafficManager Endpoints
4+
5+
## Description
6+
7+
Activate Custom Domain Name SSL Certificate and activate TrafficManager Endpoints
8+
9+
This script will do following steps:
10+
11+
1. Import information from previous Terraform runs
12+
2. Terraform execution to activate certificate and map TrafficManager endpoints
13+
3. Update Bot Endpoint
14+
15+
After the script is successfully executed the bot should be in a usable state from WebChat
16+
17+
## Parameters
18+
19+
| Name | Type | Required | Default | Description |
20+
| - | - | - | - | - |
21+
| YOUR_DOMAIN | String | false | | The domain (CN) name for the SSL certificate |
22+
| AUTOAPPROVE | Boolean | false | False | Terraform and SSL creation Automation Flag. $False -> Interactive, Approval $True -> Automatic Approval |
23+
| KEYVAULT_CERT_NAME | String | false | SSLcert | KeyVault certificate key name |
24+
25+
## Examples
26+
27+
```powershell
28+
.\ActivateSSL.ps1 -YOUR_DOMAIN bot.mydomain.com
29+
30+
```
31+
32+
33+
## Flowchart
34+
35+
<div align='center'>
36+
37+
![Flowchart for ActivateSSL.ps1](../flowchart/ActivateSSL.flowchart.svg)
38+
</div>

Doc/Deploy/CheckExistingSSL.md

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# CheckExistingSSL.ps1
2+
3+
Check if already a SSL certificate was imported to KeyVault
4+
5+
## Description
6+
7+
Check if already a SSL certificate was imported to KeyVault
8+
9+
This script will do following steps:
10+
11+
1. Read values from Terraform IaC run (Bot deployment scripts)
12+
2. Check if certificate exists in Key Vault
13+
14+
Returns $True if certificate already exists
15+
16+
## Parameters
17+
18+
| Name | Type | Required | Default | Description |
19+
| - | - | - | - | - |
20+
| KEYVAULT_CERT_NAME | String | false | SSLcert | KeyVault certificate key name |
21+
22+
## Examples
23+
24+
```powershell
25+
.\CheckExistingSSL.ps1 -KEYVAULT_CERT_NAME SSLcert
26+
27+
```
28+
29+
30+
## Flowchart
31+
32+
<div align='center'>
33+
34+
![Flowchart for CheckExistingSSL.ps1](../flowchart/CheckExistingSSL.flowchart.svg)
35+
</div>

Doc/Deploy/CreateOrImportSSL.md

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
# CreateOrImportSSL.ps1
2+
3+
Import existing or create/issue new SSL certificate
4+
5+
## Description
6+
7+
Import existing or create/issue new SSL certificate
8+
9+
This script will do following steps:
10+
11+
1. Validate Parameters
12+
13+
2. Deactivate SSL Endpoints (in FORCE mode e.g. changing certificate or changing to custom domain name)
14+
15+
In Import Mode
16+
3. Execute Import script
17+
18+
In Issuing Mode
19+
3. Execute Issuing script
20+
21+
4. Terraform execution to activate certificate
22+
23+
After the script is successfully executed the Bot should be in a usable from within Bot Framework Service (WebChat) and Bot Emulator
24+
25+
## Parameters
26+
27+
| Name | Type | Required | Default | Description |
28+
| - | - | - | - | - |
29+
| YOUR_CERTIFICATE_EMAIL | String | false | | Mail to be associated with Let's Encrypt certificate |
30+
| YOUR_DOMAIN | String | false | | The domain (CN) name for the SSL certificate |
31+
| LETS_ENCRYPT_STAGING | Boolean | false | False | $True -> Use Let's Encrypt staging for script testing (Bot cannot be reached from Bot Framework Service) |
32+
| PFX_FILE_LOCATION | String | false | | SSL CERT (PFX Format) file location |
33+
| PFX_FILE_PASSWORD | String | false | | SSL CERT (PFX Format) file password |
34+
| KEYVAULT_CERT_NAME | String | false | SSLcert | KeyVault certificate key name |
35+
| AUTOAPPROVE | Boolean | false | False | Terraform and SSL creation Automation Flag. $False -> Interactive, Approval $True -> Automatic Approval |
36+
| ALREADYCONFIRMED | Boolean | false | False | Flag to determine if run from within OneClickDeploy.ps1 |
37+
| FORCE | Boolean | false | False | Force Reimport or Reissuing if certificate already exists |
38+
| RERUN | Boolean | false | False | To change existing infrastructure, e.g. skips DNS check. $False -> first run/no infrastructure, $True -> subsequent run, existing infrastructure |
39+
40+
## Examples
41+
42+
```powershell
43+
.\CreateOrImportSSL.ps1 -YOUR_CERTIFICATE_EMAIL my@mymail.com -YOUR_DOMAIN bot.mydomain.com -LETS_ENCRYPT_STAGING $False -AUTOAPPROVE $True
44+
45+
.\CreateOrImportSSL.ps1 -PFX_FILE_LOCATION ../SSL/mybot.pfx -PFX_FILE_PASSWORD securesecret -AUTOAPPROVE $False
46+
47+
```
48+
49+
50+
## Flowchart
51+
52+
<div align='center'>
53+
54+
![Flowchart for CreateOrImportSSL.ps1](../flowchart/CreateOrImportSSL.flowchart.svg)
55+
</div>

Doc/Deploy/CreateSSL.md

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# CreateSSL.ps1
2+
3+
Issue new SSL certificate from Let's Encrypt
4+
5+
## Description
6+
7+
Issue new SSL certificate from Let's Encrypt
8+
9+
This script will do following steps:
10+
11+
1. Read values from previous Infrastructure Deployment run (Terraform & Bot Deployment)
12+
2. If custom domain is set, check if it points to TrafficManager DNS entry
13+
3. Terraform execution to spin up container who issues SSL cert and stores in KeyVault
14+
4. Check if certificate was created
15+
5. Terraform destroy to clean up resources only need for SSL issuing
16+
17+
After the script is successfully executed the certificate should be stored in KeyVault
18+
19+
## Parameters
20+
21+
| Name | Type | Required | Default | Description |
22+
| - | - | - | - | - |
23+
| YOUR_CERTIFICATE_EMAIL | String | true | | Mail to be associated with Let's Encrypt certificate |
24+
| YOUR_DOMAIN | String | false | | The domain (CN) name for the SSL certificate |
25+
| LETS_ENCRYPT_STAGING | Boolean | false | False | $True -> Use Let's Encrypt staging for script testing (Bot cannot be reached from Bot Framework Service) |
26+
| AUTOAPPROVE | Boolean | false | False | Terraform Automation Flag. $False -> Interactive, Approval $True -> Automatic Approval |
27+
| KEYVAULT_CERT_NAME | String | false | SSLcert | KeyVault certificate key name |
28+
| MAX_WAIT_TIME_MIN | Int32 | false | 15 | Maximum wait time for DNS resolve and certificate generation in minutes. Default 15 min |
29+
30+
## Examples
31+
32+
```powershell
33+
.\CreateSSL.ps1 -YOUR_CERTIFICATE_EMAIL my@mymail.com -YOUR_DOMAIN bot.mydomain.com -LETS_ENCRYPT_STAGING $False -AUTOAPPROVE $True
34+
35+
```
36+
37+
38+
## Flowchart
39+
40+
<div align='center'>
41+
42+
![Flowchart for CreateSSL.ps1](../flowchart/CreateSSL.flowchart.svg)
43+
</div>

0 commit comments

Comments
 (0)