forked from Azure/azure-devtestlab
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor the LabCreator.ps1 sample to a set of reusable functions (Az…
…ure#744) * First checkin. Todo add select functions * Add SelectLab * Adding ShowMenu * Force loading of AzLab module in the calling script as we cannot know where the user has stored it * Add first examples * Finish samples * Add Json sample * Update table of contents * Change library to module in title * Removing LabCreator & csv files and adding timing to PublishAll.ps1 * Fix Nichole comments
- Loading branch information
Showing
16 changed files
with
974 additions
and
414 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,4 +12,5 @@ packages/ | |
*.csproj.user | ||
**/obj/* | ||
**/Properties/PublishProfiles/* | ||
*.cred | ||
*.cred | ||
debug.log |
11 changes: 11 additions & 0 deletions
11
samples/ClassroomLabs/Modules/Library/Tools/Examples/PickALab.ps1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
[CmdletBinding()] | ||
param( | ||
[parameter(Mandatory = $true, ValueFromPipelineByPropertyName = $true)] | ||
[string] | ||
$CsvConfigFile | ||
) | ||
|
||
Import-Module ../../Az.LabServices.psm1 -Force | ||
Import-Module ../LabCreationLibrary.psm1 -Force | ||
|
||
$CsvConfigFile | Import-LabsCsv | Show-LabMenu -PickLab | Publish-Labs |
19 changes: 19 additions & 0 deletions
19
samples/ClassroomLabs/Modules/Library/Tools/Examples/PickLabAndProperties.ps1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
[CmdletBinding()] | ||
param( | ||
[parameter(Mandatory = $true, ValueFromPipelineByPropertyName = $true)] | ||
[string] | ||
$CsvConfigFile, | ||
|
||
[Parameter(Mandatory = $false, HelpMessage = "Which lab properties to show a prompt for")] | ||
[ValidateNotNullOrEmpty()] | ||
[string[]] | ||
$Properties | ||
) | ||
|
||
Import-Module ../../Az.LabServices.psm1 -Force | ||
Import-Module ../LabCreationLibrary.psm1 -Force | ||
|
||
$CsvConfigFile ` | ||
| Import-LabsCsv ` | ||
| Show-LabMenu -PickLab -Properties $Properties ` | ||
| Publish-Labs |
19 changes: 19 additions & 0 deletions
19
samples/ClassroomLabs/Modules/Library/Tools/Examples/PickProperties.ps1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
[CmdletBinding()] | ||
param( | ||
[parameter(Mandatory = $true, ValueFromPipelineByPropertyName = $true)] | ||
[string] | ||
$CsvConfigFile, | ||
|
||
[Parameter(Mandatory = $false, HelpMessage = "Which lab properties to show a prompt for")] | ||
[ValidateNotNullOrEmpty()] | ||
[string[]] | ||
$Properties | ||
) | ||
|
||
Import-Module ../../Az.LabServices.psm1 -Force | ||
Import-Module ../LabCreationLibrary.psm1 -Force | ||
|
||
$CsvConfigFile ` | ||
| Import-LabsCsv ` | ||
| Show-LabMenu -Properties $Properties ` | ||
| Publish-Labs |
20 changes: 20 additions & 0 deletions
20
samples/ClassroomLabs/Modules/Library/Tools/Examples/PublishAll.ps1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
[CmdletBinding()] | ||
param( | ||
[parameter(Mandatory = $true, ValueFromPipelineByPropertyName = $true)] | ||
[string] | ||
$CsvConfigFile, | ||
|
||
[parameter(Mandatory = $false, ValueFromPipelineByPropertyName = $true)] | ||
[int] | ||
$ThrottleLimit = 5 | ||
) | ||
|
||
$outerScriptstartTime = Get-Date | ||
Write-Host "Executing Lab Creation Script, starting at $outerScriptstartTime" -ForegroundColor Green | ||
|
||
Import-Module ../../Az.LabServices.psm1 -Force | ||
Import-Module ../LabCreationLibrary.psm1 -Force | ||
|
||
$CsvConfigFile | Import-LabsCsv | Publish-Labs | ||
|
||
Write-Host "Completed running Bulk Lab Creation script, total duration $(((Get-Date) - $outerScriptstartTime).TotalMinutes) minutes" -ForegroundColor Green |
15 changes: 15 additions & 0 deletions
15
samples/ClassroomLabs/Modules/Library/Tools/Examples/PublishAllJson.ps1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
[CmdletBinding()] | ||
param( | ||
[parameter(Mandatory = $true, ValueFromPipelineByPropertyName = $true)] | ||
[string] | ||
$JsonConfigFile, | ||
|
||
[parameter(Mandatory = $false, ValueFromPipelineByPropertyName = $true)] | ||
[int] | ||
$ThrottleLimit = 5 | ||
) | ||
|
||
Import-Module ../../Az.LabServices.psm1 -Force | ||
Import-Module ../LabCreationLibrary.psm1 -Force | ||
|
||
Get-Content -Raw -Path $JsonConfigFile | ConvertFrom-Json | Publish-Labs |
20 changes: 20 additions & 0 deletions
20
samples/ClassroomLabs/Modules/Library/Tools/Examples/PublishById.ps1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
[CmdletBinding()] | ||
param( | ||
[parameter(Mandatory = $true, ValueFromPipelineByPropertyName = $true)] | ||
[string] | ||
$CsvConfigFile, | ||
|
||
[parameter(Mandatory = $true, ValueFromPipelineByPropertyName = $true, HelpMessage = "If a lab contains any of these tags, it will be selected")] | ||
[ValidateNotNullOrEmpty()] | ||
[string] | ||
$AnId | ||
) | ||
|
||
Import-Module ../../Az.LabServices.psm1 -Force | ||
Import-Module ../LabCreationLibrary.psm1 -Force | ||
|
||
$CsvConfigFile ` | ||
| Import-LabsCsv ` | ||
| Select-Lab -Id $AnId ` | ||
| Set-LabProperty -ResourceGroup Staging -MaxUsers 50 ` | ||
| Publish-Labs |
20 changes: 20 additions & 0 deletions
20
samples/ClassroomLabs/Modules/Library/Tools/Examples/PublishByTag.ps1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
[CmdletBinding()] | ||
param( | ||
[parameter(Mandatory = $true, ValueFromPipelineByPropertyName = $true)] | ||
[string] | ||
$CsvConfigFile, | ||
|
||
[parameter(Mandatory = $true, ValueFromPipelineByPropertyName = $true, HelpMessage = "If a lab contains any of these tags, it will be selected")] | ||
[ValidateNotNullOrEmpty()] | ||
[string[]] | ||
$SomeTags, | ||
|
||
[parameter(Mandatory = $false, ValueFromPipelineByPropertyName = $true)] | ||
[int] | ||
$ThrottleLimit = 5 | ||
) | ||
|
||
Import-Module ../../Az.LabServices.psm1 -Force | ||
Import-Module ../LabCreationLibrary.psm1 -Force | ||
|
||
$CsvConfigFile | Import-LabsCsv | Select-Lab -SomeTags $SomeTags | Publish-Labs |
21 changes: 21 additions & 0 deletions
21
samples/ClassroomLabs/Modules/Library/Tools/Examples/PublishStaging.ps1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
[CmdletBinding()] | ||
param( | ||
[parameter(Mandatory = $true, ValueFromPipelineByPropertyName = $true)] | ||
[string] | ||
$CsvConfigFile, | ||
|
||
[parameter(Mandatory = $true, ValueFromPipelineByPropertyName = $true, HelpMessage = "If a lab contains any of these tags, it will be selected")] | ||
[ValidateNotNullOrEmpty()] | ||
[string] | ||
$AnId, | ||
|
||
[parameter(Mandatory = $false, ValueFromPipelineByPropertyName = $true)] | ||
[int] | ||
$ThrottleLimit = 5 | ||
|
||
) | ||
|
||
Import-Module ../../Az.LabServices.psm1 -Force | ||
Import-Module ../LabCreationLibrary.psm1 -Force | ||
|
||
$CsvConfigFile | Import-LabsCsv | Select-Lab -AnId $AnId | Publish-Labs |
File renamed without changes.
4 changes: 4 additions & 0 deletions
4
samples/ClassroomLabs/Modules/Library/Tools/Examples/hogwarts.csv
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
Id,Tags,ResourceGroupName,Location,LabAccountName,LabName,ImageName,AadGroupId,MaxUsers,UsageQuota,UsageMode,SharedPassword,Size,Title,Descr,TemplateVmState, UserName,Password,LinuxRdp, Emails,LabOwnerEmails, idleGracePeriod, idleOsGracePeriod, idleNoConnectGracePeriod, Invitation, Schedules | ||
id001,[email protected];[email protected],hogwarts-rg2,westeurope,Muggle,"History of Magic",CentOS-Based*,00000000-0000-0000-0000-000000000000,2,20,Restricted,FALSE,Basic,"History of Magic","Those who don't know history ...",Enabled,test0000,Test00000000,TRUE,"[email protected];[email protected]","[email protected];[email protected]",7,8,9,"History of Magic", | ||
id002,[email protected];[email protected],hogwarts-rg2,westeurope,Wizardy,Transfiguration,CentOS-Based*,,2,20,Restricted,FALSE,Basic,"Transfiguration","Who are you?",, test0000,Test00000000,TRUE,"[email protected];[email protected]",,7,8,9,"Transfiguration", | ||
id003,[email protected];[email protected],hogwarts-rg2,westeurope,Wizardy,Charms,CentOS-Based*,,2,20,Restricted,FALSE,Basic,"Charms","Encanted",Disabled,test0000,Test00000000,TRUE,"[email protected]",,15,0,10, "Charms", charms |
101 changes: 101 additions & 0 deletions
101
samples/ClassroomLabs/Modules/Library/Tools/Examples/hogwarts.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
[ | ||
{ | ||
"Id": "id001", | ||
"Tags": "[email protected];[email protected]", | ||
"ResourceGroupName": "hogwarts-rg2", | ||
"Location": "westeurope", | ||
"LabAccountName": "Muggle", | ||
"LabName": "History of Magic", | ||
"ImageName": "CentOS-Based*", | ||
"AadGroupId": "00000000-0000-0000-0000-000000000000", | ||
"MaxUsers": "2", | ||
"UsageQuota": "20", | ||
"UsageMode": "Restricted", | ||
"SharedPassword": false, | ||
"Size": "Basic", | ||
"Title": "History of Magic", | ||
"Descr": "Those who don't know history ...", | ||
"TemplateVmState": "Enabled", | ||
"UserName": "test0000", | ||
"Password": "Test00000000", | ||
"LinuxRdp": true, | ||
"Emails": [ | ||
"[email protected]", | ||
"[email protected]" | ||
], | ||
"LabOwnerEmails": [ | ||
"[email protected]", | ||
"[email protected]" | ||
], | ||
"idleGracePeriod": "7", | ||
"idleOsGracePeriod": "8", | ||
"idleNoConnectGracePeriod": "9", | ||
"Invitation": "History of Magic", | ||
"Schedules": "", | ||
"GpuDriverEnabled": false | ||
}, | ||
{ | ||
"Id": "id002", | ||
"Tags": "[email protected];[email protected]", | ||
"ResourceGroupName": "hogwarts-rg2", | ||
"Location": "westeurope", | ||
"LabAccountName": "Wizardy", | ||
"LabName": "Transfiguration", | ||
"ImageName": "CentOS-Based*", | ||
"AadGroupId": "", | ||
"MaxUsers": "2", | ||
"UsageQuota": "20", | ||
"UsageMode": "Restricted", | ||
"SharedPassword": false, | ||
"Size": "Basic", | ||
"Title": "Transfiguration", | ||
"Descr": "Who are you?", | ||
"TemplateVmState": "", | ||
"UserName": "test0000", | ||
"Password": "Test00000000", | ||
"LinuxRdp": true, | ||
"Emails": [ | ||
"[email protected]", | ||
"[email protected]" | ||
], | ||
"LabOwnerEmails": "", | ||
"idleGracePeriod": "7", | ||
"idleOsGracePeriod": "8", | ||
"idleNoConnectGracePeriod": "9", | ||
"Invitation": "Transfiguration", | ||
"Schedules": "", | ||
"GpuDriverEnabled": false | ||
}, | ||
{ | ||
"Id": "id003", | ||
"Tags": "[email protected];[email protected]", | ||
"ResourceGroupName": "hogwarts-rg2", | ||
"Location": "westeurope", | ||
"LabAccountName": "Wizardy", | ||
"LabName": "Charms", | ||
"ImageName": "CentOS-Based*", | ||
"AadGroupId": "", | ||
"MaxUsers": "2", | ||
"UsageQuota": "20", | ||
"UsageMode": "Restricted", | ||
"SharedPassword": false, | ||
"Size": "Basic", | ||
"Title": "Charms", | ||
"Descr": "Encanted", | ||
"TemplateVmState": "Disabled", | ||
"UserName": "test0000", | ||
"Password": "Test00000000", | ||
"LinuxRdp": true, | ||
"Emails": "[email protected]", | ||
"LabOwnerEmails": "", | ||
"idleGracePeriod": "15", | ||
"idleOsGracePeriod": "0", | ||
"idleNoConnectGracePeriod": "10", | ||
"Invitation": "Charms", | ||
"Schedules": [ | ||
"@{Frequency=Weekly; FromDate=1/1/2021; ToDate=12/12/2021; StartTime=10:00; EndTime=12:00; WeekDays=System.Object[]; TimeZoneId=W. Europe Standard Time; Notes=A recurrent class}", | ||
"@{Frequency=Once; FromDate=1/1/2021; ToDate=12/12/2021; StartTime=10:00; EndTime=12:00; WeekDays=; TimeZoneId=W. Europe Standard Time; Notes=A workshop}" | ||
], | ||
"GpuDriverEnabled": false | ||
} | ||
] |
Oops, something went wrong.