Skip to content

Commit c59fb5f

Browse files
committed
Fix VHD Link Creation in Update-AzureVM
1 parent 7d4cfda commit c59fb5f

File tree

1 file changed

+8
-16
lines changed
  • src/ServiceManagement/Compute/Commands.ServiceManagement/IaaS/PersistentVMs

1 file changed

+8
-16
lines changed

src/ServiceManagement/Compute/Commands.ServiceManagement/IaaS/PersistentVMs/UpdateAzureVM.cs

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -12,19 +12,20 @@
1212
// limitations under the License.
1313
// ----------------------------------------------------------------------------------
1414

15-
using System;
16-
using System.Collections.Generic;
17-
using System.Linq;
18-
using System.Management.Automation;
1915
using AutoMapper;
16+
using Hyak.Common;
2017
using Microsoft.Azure.Common.Authentication.Models;
2118
using Microsoft.WindowsAzure.Commands.ServiceManagement.Helpers;
19+
using Microsoft.WindowsAzure.Commands.ServiceManagement.IaaS.PersistentVMs;
2220
using Microsoft.WindowsAzure.Commands.ServiceManagement.Properties;
2321
using Microsoft.WindowsAzure.Commands.Utilities.Common;
2422
using Microsoft.WindowsAzure.Management.Compute;
2523
using Microsoft.WindowsAzure.Management.Compute.Models;
2624
using Microsoft.WindowsAzure.Storage;
27-
using Hyak.Common;
25+
using System;
26+
using System.Collections.Generic;
27+
using System.Linq;
28+
using System.Management.Automation;
2829

2930
namespace Microsoft.WindowsAzure.Commands.ServiceManagement.IaaS
3031
{
@@ -71,23 +72,14 @@ internal void ExecuteCommandNewSM()
7172
throw new ArgumentException(Resources.CurrentStorageAccountIsNotAccessible);
7273
}
7374

74-
DateTime dateTimeCreated = DateTime.Now;
7575
string diskPartName = VM.RoleName;
76-
7776
if (datadisk.DiskLabel != null)
7877
{
7978
diskPartName += "-" + datadisk.DiskLabel;
8079
}
8180

82-
string vhdname = string.Format("{0}-{1}-{2}-{3}-{4}-{5}.vhd", ServiceName, diskPartName, dateTimeCreated.Year, dateTimeCreated.Month, dateTimeCreated.Day, dateTimeCreated.Millisecond);
83-
string blobEndpoint = currentStorage.BlobEndpoint.AbsoluteUri;
84-
85-
if (blobEndpoint.EndsWith("/") == false)
86-
{
87-
blobEndpoint += "/";
88-
}
89-
90-
datadisk.MediaLink = new Uri(blobEndpoint + "vhds/" + vhdname);
81+
var mediaLinkFactory = new MediaLinkFactory(currentStorage, this.ServiceName, diskPartName);
82+
datadisk.MediaLink = mediaLinkFactory.Create();
9183
}
9284

9385
if (VM.DataVirtualHardDisks.Count > 1)

0 commit comments

Comments
 (0)