@@ -40,22 +40,29 @@ public class LinuxVirtualMachineClient : ILinuxVirtualMachineClient
40
40
/// </summary>
41
41
/// <param name="subscriptionId">the subscription id </param>
42
42
/// <param name="certificate">A management certificate for the subscription</param>
43
- public LinuxVirtualMachineClient ( string subscriptionId , X509Certificate2 certificate )
43
+ /// <param name="defaultLocation">The location to which service management request is sent to</param>
44
+ public LinuxVirtualMachineClient ( string subscriptionId , X509Certificate2 certificate , string defaultLocation = LocationConstants . NorthEurope )
44
45
{
45
46
SubscriptionId = subscriptionId ;
46
47
ManagementCertificate = certificate ;
48
+ Location = defaultLocation ;
47
49
}
50
+ /// <summary>
51
+ /// The default location that the service management api is being called from
52
+ /// </summary>
53
+ public string Location { get ; set ; }
48
54
49
55
/// <summary>
50
56
/// Constructs a VirtualMachinenClient
51
57
/// </summary>
52
58
/// <param name="properties">A valid VirtualMachineProperties object</param>
53
59
/// <param name="subscriptionId">The susbcription id for the subscription</param>
54
60
/// <param name="certificate">The susbcription id for the subscription</param>
55
- public LinuxVirtualMachineClient ( List < LinuxVirtualMachineProperties > properties , string subscriptionId , X509Certificate2 certificate )
61
+ public LinuxVirtualMachineClient ( List < LinuxVirtualMachineProperties > properties , string subscriptionId , X509Certificate2 certificate , string defaultLocation = LocationConstants . NorthEurope )
56
62
: this ( subscriptionId , certificate )
57
63
{
58
64
Properties = properties ;
65
+ Location = defaultLocation ;
59
66
}
60
67
61
68
/// <summary>
@@ -81,7 +88,8 @@ public List<PersistentVMRole> VirtualMachine
81
88
var command = new GetVirtualMachineContextCommand ( Properties . First ( ) )
82
89
{
83
90
SubscriptionId = SubscriptionId ,
84
- Certificate = ManagementCertificate
91
+ Certificate = ManagementCertificate ,
92
+ Location = Location
85
93
} ;
86
94
command . Execute ( ) ;
87
95
return ( _vmRoles = command . PersistentVm . ToList ( ) ) ;
@@ -102,7 +110,8 @@ private void CheckVmDeploymentIsRunning(List<LinuxVirtualMachineProperties> prop
102
110
var command = new GetVirtualMachineContextCommand ( vmProperties )
103
111
{
104
112
SubscriptionId = SubscriptionId ,
105
- Certificate = ManagementCertificate
113
+ Certificate = ManagementCertificate ,
114
+ Location = Location
106
115
} ;
107
116
command . Execute ( ) ;
108
117
command . PersistentVm . ForEach ( vm =>
@@ -148,7 +157,8 @@ public IVirtualMachineClient CreateNewVirtualMachineDeploymentFromTemplateGaller
148
157
var checkCloudServiceAvailabilityCommand = new CheckCloudServiceNameAvailableCommand ( cloudServiceName )
149
158
{
150
159
SubscriptionId = SubscriptionId ,
151
- Certificate = ManagementCertificate
160
+ Certificate = ManagementCertificate ,
161
+ Location = Location
152
162
} ;
153
163
checkCloudServiceAvailabilityCommand . Execute ( ) ;
154
164
Trace . WriteLine ( String . Format ( "Checked cloud service availability - is available: {0}" , checkCloudServiceAvailabilityCommand . CloudServiceAvailable ) ) ;
@@ -158,7 +168,8 @@ public IVirtualMachineClient CreateNewVirtualMachineDeploymentFromTemplateGaller
158
168
var cloudServiceCommand = new CreateCloudServiceCommand ( cloudServiceName , "Created by Fluent Management" , location , affinityGroup )
159
169
{
160
170
SubscriptionId = SubscriptionId ,
161
- Certificate = ManagementCertificate
171
+ Certificate = ManagementCertificate ,
172
+ Location = Location
162
173
} ;
163
174
cloudServiceCommand . Execute ( ) ;
164
175
Trace . WriteLine ( String . Format ( "Cloud service named {0} has been created" , cloudServiceName ) ) ;
@@ -173,10 +184,11 @@ public IVirtualMachineClient CreateNewVirtualMachineDeploymentFromTemplateGaller
173
184
174
185
// This is really unfortunate and not documented anywhere - unable to add multiple roles to a rolelist!!!
175
186
// continue to the create the virtual machine in the cloud service
176
- var command = new CreateLinuxVirtualMachineDeploymentCommand ( new List < LinuxVirtualMachineProperties > ( new [ ] { properties [ 0 ] } ) , cloudServiceName )
187
+ var command = new CreateLinuxVirtualMachineDeploymentCommand ( new List < LinuxVirtualMachineProperties > ( new [ ] { properties [ 0 ] } ) , cloudServiceName , Location )
177
188
{
178
189
SubscriptionId = SubscriptionId ,
179
- Certificate = ManagementCertificate
190
+ Certificate = ManagementCertificate ,
191
+ Location = Location
180
192
} ;
181
193
command . Execute ( ) ;
182
194
// raise this event every time we create a VM
@@ -196,7 +208,8 @@ public IVirtualMachineClient CreateNewVirtualMachineDeploymentFromTemplateGaller
196
208
var startCommand = new AddLinuxVirtualMachineToDeploymentCommand ( theProperty , cloudServiceName )
197
209
{
198
210
SubscriptionId = SubscriptionId ,
199
- Certificate = ManagementCertificate
211
+ Certificate = ManagementCertificate ,
212
+ Location = Location
200
213
} ;
201
214
startCommand . Execute ( ) ;
202
215
// raise this event every time we create a VM
0 commit comments