Skip to content

Commit 4fa263c

Browse files
[Experiment][Compute] Tab completion for New-AzVm (#4655)
* some bug fixes * subnet bug fix * Output * FQDN * output * progress using Write-Host * progress * progress * version update * 1.0.21 * Progress. * 1.0.22 * 1.0.23 * ResourceGroup has to be a direct dependency * clean output * 1.0.26 * ports * messages * minor * 1.0.27 * First Pester Tests. * first validation * bug fix * 1.0.28 * minor * Disable Boot Diagnostics #4735 * -DisableBootDiagnostics * Set-AzureRmVMBootDiagnostics * 1.0.30
1 parent 91c7ac0 commit 4fa263c

File tree

6 files changed

+543
-242
lines changed

6 files changed

+543
-242
lines changed

comments.md

Lines changed: 171 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,171 @@
1+
# Comments
2+
3+
- Local objects.
4+
- Smart cmdlets for
5+
- P2. Resource Group.
6+
- P2. Virtual Network.
7+
- P2. Security Group.
8+
- P2. Resource Ids, a tree structure
9+
- P1. Output for smart commands. In particular, information about (PS information stream ?)
10+
- Resource Group!!!
11+
- Virtual Network!
12+
- Security Group!
13+
- ...!
14+
- Security Rules:
15+
- DefaultSecurityRulesText - can/should we use it?
16+
- P2. information stream
17+
- P3. show progress
18+
- P1. return PowerShell Job (async)
19+
20+
## Tasks
21+
22+
P0 is 09/05/2017
23+
24+
- [ ] P0 output
25+
- [X] P0 create a package (PSM1, PSD1...)
26+
- [X] P0 Manifest with dependencies
27+
- image list
28+
- [X] P0: json file or PSObject
29+
- [ ] P1: json
30+
- [ ] P2: source of image names. CDN, Azure... ???
31+
- names:
32+
- P0: based on VM name specified by user (see also CLI, Portal).
33+
- [X] P0: always fail if exist
34+
- P1: can we reuse it? ???
35+
- P1: fallback: throw (suggests...) or reuse?
36+
- P1: default shared name for Network (something else?!). CLI?? Portal??
37+
- P2 optional VM name.
38+
- P1 Create Or Update scenario.
39+
- P2 Rollback
40+
41+
## Tasks
42+
43+
- [X] P0: required modules
44+
- [ ] replace Write-Host
45+
- [X]: P0: remove Write-Host
46+
- [ ]: P1: add progress
47+
- [X] P0: parameter attributes
48+
- [ ] P0: Linux image
49+
- [ ] P0: more default parameters
50+
- [X] P0: having a package.
51+
- [ ] P1: Project build.
52+
53+
## Graph
54+
55+
1. `Location`
56+
1. `ResourceGroup`
57+
- depends on `Location`
58+
- children
59+
1. `VirtualNetwork`
60+
- depends on `Location`
61+
- children
62+
1. `Subnet`
63+
1. `PublicIpAddress`
64+
- depends on `Location`
65+
1. `SecurityGroup`
66+
- depends on `Location`
67+
- children
68+
1. `SecurityRule`
69+
1. `NetworkInterface`
70+
- depends on `PublicIpAddress`, `Subnet`, `SecurityGroup`, `Location`
71+
1. `Vm`
72+
- depends on `NetworkInterface`, `Location`
73+
74+
## Levels
75+
76+
1. Resources:
77+
- `Location` (shared),
78+
- `ResourceGroup` (shared) <- `Location`
79+
1. Resources:
80+
- `SecurityGroup` -> `SecurityRule`
81+
- `Subnet` <- `VirtualNetwork` (shared?)
82+
- `PublicIpAddress`
83+
1. Resources:
84+
- `NetworkInterface` (unique) ?
85+
1. Resources:
86+
- `VM`
87+
88+
## Behavior
89+
90+
a parameter value:
91+
- undefined
92+
- user's value
93+
94+
if a resource exists
95+
- then
96+
- else
97+
98+
resource name:
99+
1. undefined
100+
1. resource exists - reuse|with validation (fail? or workaround or interactive)
101+
1. resource doesn't exist - create
102+
1. user's value
103+
1. resource exist - reuse
104+
1. resource doesn't exist - fail (create?)
105+
106+
smart location. Should it depends on a resource group location?
107+
108+
default parameters - work backward
109+
110+
## Resource Acquisition Matrix
111+
112+
1. A resource name is
113+
- undefined
114+
- user's specified name
115+
- user's specified id
116+
1. A resource
117+
- exists
118+
- doesn't exist
119+
1. A resource is
120+
- shared
121+
- unique
122+
123+
## C# vs PowerShell
124+
125+
### Proposal 1
126+
127+
- use C# to implement logic and type descriptions (no PowerShell dependencies, only .Net Standard and Azure SDK dependencies).
128+
- use PowerShell to make a facade.
129+
130+
### Proposal 2
131+
132+
- use C# to implement logic and type descriptions (with PowerShell dependencies)
133+
- probably, no need for PSM1 files.
134+
135+
### C# advantages
136+
137+
- type/contract validations at compile time.
138+
- much more feature to express logic, relations etc.
139+
- testing is easier and, probably, faster.
140+
- performance ?.
141+
- customers may use the C# library for .Net programs (C#/VB/F#/...).
142+
- C# type system is much more mature and well documented compare to PowerShell v5 classes.
143+
144+
## Tasks
145+
146+
- changelog
147+
- remove warnings (-WarningAction=SilentContinue)
148+
- help
149+
- linux
150+
- e2e manual test (Windows, Linux).
151+
- feedback
152+
- (-Auto)
153+
- tab-completion
154+
- VMSS
155+
- rolling back
156+
- output object
157+
158+
## 9/15
159+
160+
- [X] [P-1] help (in doc, example)
161+
- - signing (9/14)
162+
- output format (Get-AzureRmVm)
163+
- talk to Aaron
164+
- how to use (connect to VM etc).
165+
- output
166+
- information stream (Write-Information)
167+
- proper cmdlet + parameter attributes + struct
168+
- [X] positional parameters (PR) (position 0 for name)
169+
- [X] [P-1] shouldprocess (example)
170+
171+
- [P0.5] validation (PSScript analyser)

experiments/Compute.Experiments/AzureRM.Compute.Experiments.Tests.ps1

Lines changed: 32 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -16,25 +16,35 @@ $vmComputerUser = $credentials.vmUser;
1616
$password = ConvertTo-SecureString $vmComputerPassword -AsPlainText -Force;
1717
$vmCredential = New-Object System.Management.Automation.PSCredential ($vmComputerUser, $password);
1818

19-
New-AzVm -Name MyVM -Credential $vmCredential -WhatIf
20-
21-
# $job = New-AzVm -Name MyVMA -Credential $vmCredential -AsJob
22-
# Receive-Job $job
23-
24-
# exit
25-
26-
# $vm = New-AzVm
27-
# $vm = New-AzVm -Credential $vmCredential
28-
$vm = New-AzVm -Name MyVMA1 -Credential $vmCredential -ResourceGroupName Crocodile
29-
# $vm = New-AzVm -Name MyVMA
30-
31-
$vm
32-
33-
# Write-Host "<async>"
34-
# $job = New-AzVm -Name MyVMA3 -Credential $vmCredential -AsJob
35-
# $vm = Receive-Job $job -Wait
36-
# $vm
37-
# Write-Host "</async>"
38-
39-
# clean-up
40-
Remove-AzureRmResourceGroup -ResourceId $vm.ResourceGroupId
19+
Describe 'New-AzVm' {
20+
It 'WhatIf' {
21+
$result = New-AzVm -Name MyVM -Credential $vmCredential -WhatIf
22+
}
23+
It 'Create Windows VM' {
24+
Remove-AzureRmResourceGroup -Name Something1 -Force
25+
26+
$result = New-AzVm -Name MyVMA1 -Credential $vmCredential -ResourceGroupName Something1 -Verbose
27+
28+
$result.Name | Should Be MyVMA1
29+
}
30+
It 'Create Linux VM' {
31+
$context = Get-AzureRmContext
32+
$result = New-AzVm `
33+
-Name X2 `
34+
-Credential $vmCredential `
35+
-Location westus2 `
36+
-ResourceGroupName Something1 `
37+
-AzureRmContext $context `
38+
-ImageName UbuntuLTS `
39+
-Verbose
40+
$result.Name | Should Be X2
41+
}
42+
It 'Create Linux VM AsJob' {
43+
Remove-AzureRmResourceGroup -Name MyVMA3 -Force
44+
45+
$job = New-AzVm -Name MyVMA3 -Credential $vmCredential -AsJob -ImageName UbuntuLTS -Verbose
46+
$result = Receive-Job $job -Wait -Verbose
47+
48+
$result.Name | Should Be MyVMA3
49+
}
50+
}

0 commit comments

Comments
 (0)