|
29 | 29 | using Microsoft.Azure.Management.Compute.Models;
|
30 | 30 | using Microsoft.Azure.Management.Storage;
|
31 | 31 | using Microsoft.Azure.Management.Storage.Models;
|
| 32 | +using Microsoft.Rest.Azure; |
32 | 33 | using Microsoft.WindowsAzure.Commands.Sync.Download;
|
33 | 34 | using Microsoft.WindowsAzure.Commands.Tools.Vhd;
|
34 | 35 | using Microsoft.WindowsAzure.Commands.Tools.Vhd.Model;
|
@@ -335,24 +336,35 @@ async Task StrategyExecuteCmdletAsync(IAsyncCmdlet asyncCmdlet)
|
335 | 336 | Math.DivRem(filePath.Length, divisor, out rem);
|
336 | 337 | if (rem != 0)
|
337 | 338 | {
|
338 |
| - throw new ArgumentOutOfRangeException("filePath", string.Format("Given vhd file '{0}' is a corrupted fixed vhd", filePath)); |
| 339 | + throw new ArgumentOutOfRangeException( |
| 340 | + "filePath", |
| 341 | + string.Format("Given vhd file '{0}' is a corrupted fixed vhd", filePath)); |
339 | 342 | }
|
340 | 343 | }
|
341 | 344 | }
|
342 | 345 | var storageAccount = storageClient.StorageAccounts.GetProperties(ResourceGroupName, Name);
|
343 | 346 | BlobUri destinationUri = null;
|
344 |
| - BlobUri.TryParseUri(new Uri(string.Format("{0}{1}/{2}{3}", storageAccount.PrimaryEndpoints.Blob, Name.ToLower(), Name.ToLower(), ".vhd")), out destinationUri); |
| 347 | + BlobUri.TryParseUri( |
| 348 | + new Uri(string.Format( |
| 349 | + "{0}{1}/{2}{3}", |
| 350 | + storageAccount.PrimaryEndpoints.Blob, |
| 351 | + Name.ToLower(), |
| 352 | + Name.ToLower(), |
| 353 | + ".vhd")), |
| 354 | + out destinationUri); |
345 | 355 | if (destinationUri == null || destinationUri.Uri == null)
|
346 | 356 | {
|
347 | 357 | throw new ArgumentNullException("destinationUri");
|
348 | 358 | }
|
349 |
| - var storageCredentialsFactory = new StorageCredentialsFactory(this.ResourceGroupName, storageClient, DefaultContext.Subscription); |
| 359 | + var storageCredentialsFactory = new StorageCredentialsFactory( |
| 360 | + this.ResourceGroupName, storageClient, DefaultContext.Subscription); |
350 | 361 | var parameters = new UploadParameters(destinationUri, null, filePath, true, 2)
|
351 | 362 | {
|
352 | 363 | Cmdlet = this,
|
353 | 364 | BlobObjectFactory = new CloudPageBlobObjectFactory(storageCredentialsFactory, TimeSpan.FromMinutes(1))
|
354 | 365 | };
|
355 |
| - if (!string.Equals(Environment.GetEnvironmentVariable("AZURE_TEST_MODE"), "Playback", StringComparison.OrdinalIgnoreCase)) |
| 366 | + if (!string.Equals( |
| 367 | + Environment.GetEnvironmentVariable("AZURE_TEST_MODE"), "Playback", StringComparison.OrdinalIgnoreCase)) |
356 | 368 | {
|
357 | 369 | var st2 = VhdUploaderModel.Upload(parameters);
|
358 | 370 | }
|
@@ -386,7 +398,12 @@ async Task StrategyExecuteCmdletAsync(IAsyncCmdlet asyncCmdlet)
|
386 | 398 | var fqdn = DomainNameLabel + "." + Location + ".cloudapp.azure.com";
|
387 | 399 |
|
388 | 400 | // create target state
|
389 |
| - var target = virtualMachine.GetTargetState(current, client.SubscriptionId, Location); |
| 401 | + var target = virtualMachine.GetTargetState(current, client.SubscriptionId, Location); |
| 402 | + |
| 403 | + if (target.Get(availabilitySet) != null) |
| 404 | + { |
| 405 | + throw new CloudException("Availability set doesn't exsist."); |
| 406 | + } |
390 | 407 |
|
391 | 408 | // apply target state
|
392 | 409 | var newState = await virtualMachine
|
|
0 commit comments