@@ -22,9 +22,13 @@ function get_vm_config_object
22
22
{
23
23
param ([string ] $rgname , [string ] $vmsize )
24
24
25
+ $st = Write-Verbose " Creating VM Config Object - Start" ;
26
+
25
27
$vmname = ' vm' + $rgname ;
26
28
$p = New-AzureVMConfig - VMName $vmname - VMSize $vmsize ;
27
29
30
+ $st = Write-Verbose " Creating VM Config Object - End" ;
31
+
28
32
return $p ;
29
33
}
30
34
@@ -33,11 +37,17 @@ function get_created_storage_account_name
33
37
{
34
38
param ([string ] $loc , [string ] $rgname )
35
39
40
+ $st = Write-Verbose " Creating and getting storage account for '${loc} ' and '${rgname} ' - Start" ;
41
+
36
42
$stoname = ' sto' + $rgname ;
37
43
$stotype = ' Standard_GRS' ;
38
44
45
+ $st = Write-Verbose " Creating and getting storage account for '${loc} ' and '${rgname} ' - '${stotype} ' & '${stoname} '" ;
46
+
39
47
$st = New-AzureStorageAccount - ResourceGroupName $rgname - Name $stoname - Location $loc - Type $stotype ;
40
48
$st = Get-AzureStorageAccount - ResourceGroupName $rgname - Name $stoname ;
49
+
50
+ $st = Write-Verbose " Creating and getting storage account for '${loc} ' and '${rgname} ' - End" ;
41
51
42
52
return $stoname ;
43
53
}
@@ -47,14 +57,17 @@ function create_and_setup_nic_ids
47
57
{
48
58
param ([string ] $loc , [string ] $rgname , $vmconfig )
49
59
60
+ $st = Write-Verbose " Creating and getting NICs for '${loc} ' and '${rgname} ' - Start" ;
61
+
50
62
$subnet = New-AzureVirtualNetworkSubnetConfig - Name (' subnet' + $rgname ) - AddressPrefix " 10.0.0.0/24" ;
51
63
$vnet = New-AzureVirtualNetwork - Force - Name (' vnet' + $rgname ) - ResourceGroupName $rgname - Location $loc - AddressPrefix " 10.0.0.0/16" - DnsServer " 10.1.1.1" - Subnet $subnet ;
52
64
$vnet = Get-AzureVirtualNetwork - Name (' vnet' + $rgname ) - ResourceGroupName $rgname ;
53
65
$subnetId = $vnet.Subnets [0 ].Id;
54
66
$nic_ids = @ ($null ) * 1 ;
55
67
$nic0 = New-AzureNetworkInterface - Force - Name (' nic0' + $rgname ) - ResourceGroupName $rgname - Location $loc - SubnetId $subnetId ;
56
68
$nic_ids [0 ] = $nic0.Id ;
57
- $vmconfig = Add-AzureVMNetworkInterface - VM $vmconfig - Id $nic0.Id - Primary;
69
+ $vmconfig = Add-AzureVMNetworkInterface - VM $vmconfig - Id $nic0.Id ;
70
+ $st = Write-Verbose " Creating and getting NICs for '${loc} ' and '${rgname} ' - End" ;
58
71
59
72
return $nic_ids ;
60
73
}
@@ -63,6 +76,8 @@ function create_and_setup_vm_config_object
63
76
{
64
77
param ([string ] $loc , [string ] $rgname , [string ] $vmsize )
65
78
79
+ $st = Write-Verbose " Creating and setting up the VM config object for '${loc} ', '${rgname} ' and '${vmsize} ' - Start" ;
80
+
66
81
$vmconfig = get_vm_config_object $rgname $vmsize
67
82
68
83
$user = " Foo12" ;
@@ -72,6 +87,8 @@ function create_and_setup_vm_config_object
72
87
$computerName = " cn" + $rgname ;
73
88
$vmconfig = Set-AzureVMOperatingSystem - VM $vmconfig - Windows - ComputerName $computerName - Credential $cred ;
74
89
90
+ $st = Write-Verbose " Creating and setting up the VM config object for '${loc} ', '${rgname} ' and '${vmsize} ' - End" ;
91
+
75
92
return $vmconfig ;
76
93
}
77
94
@@ -80,6 +97,8 @@ function setup_image_and_disks
80
97
{
81
98
param ([string ] $loc , [string ] $rgname , [string ] $stoname , $vmconfig )
82
99
100
+ $st = Write-Verbose " Setting up image and disks of VM config object jfor '${loc} ', '${rgname} ' and '${stoname} ' - Start" ;
101
+
83
102
$osDiskName = ' osDisk' ;
84
103
$osDiskVhdUri = " https://$stoname .blob.core.windows.net/test/os.vhd" ;
85
104
$osDiskCaching = ' ReadWrite' ;
@@ -88,26 +107,31 @@ function setup_image_and_disks
88
107
89
108
# Image Reference;
90
109
$vmconfig.StorageProfile.SourceImage = $null ;
91
- $imgRef = Get-DefaultCRPImage ;
110
+ $imgRef = Get-DefaultCRPImage - loc $loc ;
92
111
$vmconfig = ($imgRef | Set-AzureVMSourceImage - VM $vmconfig );
93
112
94
- # TODO: Remove Data Disks for now
113
+ # Do not add any data disks
95
114
$vmconfig.StorageProfile.DataDisks = $null ;
96
115
116
+ $st = Write-Verbose " Setting up image and disks of VM config object jfor '${loc} ', '${rgname} ' and '${stoname} ' - End" ;
117
+
97
118
return $vmconfig ;
98
119
}
99
120
100
121
101
- function ps_vm_dynamic_test_func_1_pstestrg1166
122
+ function ps_vm_dynamic_test_func_1_pstestrg1016
102
123
{
103
124
# Setup
104
- $rgname = ' pstestrg1166 ' ;
125
+ $rgname = ' pstestrg1016 ' ;
105
126
106
127
try
107
128
{
108
- $loc = ' westeurope ' ;
109
- $vmsize = ' Standard_A5 ' ;
129
+ $loc = ' West US ' ;
130
+ $vmsize = ' Standard_A3 ' ;
110
131
132
+ $st = Write-Verbose " Running Test ps_vm_dynamic_test_func_1_pstestrg1016 - Start ${rgname} , ${loc} & ${vmsize} " ;
133
+
134
+ $st = Write-Verbose ' Running Test ps_vm_dynamic_test_func_1_pstestrg1016 - Creating Resource Group' ;
111
135
$st = New-AzureResourceGroup - Location $loc - Name $rgname ;
112
136
113
137
$vmconfig = create_and_setup_vm_config_object $loc $rgname $vmsize ;
@@ -122,14 +146,20 @@ function ps_vm_dynamic_test_func_1_pstestrg1166
122
146
$st = setup_image_and_disks $loc $rgname $stoname $vmconfig ;
123
147
124
148
# Virtual Machine
149
+ $st = Write-Verbose ' Running Test ps_vm_dynamic_test_func_1_pstestrg1016 - Creating VM' ;
150
+
125
151
$vmname = ' vm' + $rgname ;
126
152
$st = New-AzureVM - ResourceGroupName $rgname - Location $loc - Name $vmname - VM $vmconfig ;
127
153
128
154
# Get VM
155
+ $st = Write-Verbose ' Running Test ps_vm_dynamic_test_func_1_pstestrg1016 - Getting VM' ;
129
156
$vm1 = Get-AzureVM - Name $vmname - ResourceGroupName $rgname ;
130
157
131
158
# Remove
159
+ $st = Write-Verbose ' Running Test ps_vm_dynamic_test_func_1_pstestrg1016 - Removing VM' ;
132
160
$st = Remove-AzureVM - Name $vmname - ResourceGroupName $rgname - Force;
161
+
162
+ $st = Write-Verbose ' Running Test ps_vm_dynamic_test_func_1_pstestrg1016 - End' ;
133
163
}
134
164
finally
135
165
{
0 commit comments