Skip to content

Commit 35a0d39

Browse files
authored
Merge branch 'release-2018-02-09' into release-2018-02-09
2 parents 812daa7 + 44f20d8 commit 35a0d39

File tree

15 files changed

+105
-24
lines changed

15 files changed

+105
-24
lines changed

src/ResourceManager/Compute/ChangeLog.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@
2222
## Version 4.3.0
2323
* Added 'AvailabilitySetName' parameter to the simplified parameterset of 'New-AzureRmVm'.
2424
* Corrected usage of 'Login-AzureRmAccount' to use 'Connect-AzureRmAccount'
25+
* Added `FullyQualifiedDomainName` to `PSVirtualMachinScaleSet`.
26+
* Added `AvailabilitySetName` parameter to the simplified parameterset of `New-AzureRmVm`.
27+
* Corrected usage of `Login-AzureRmAccount` to use `Connect-AzureRmAccount`
2528
* User assigned identity support for VM and VM scale set
2629
- IdentityType and IdentityId parameters are added to New-AzureRmVMConfig, New-AzureRmVmssConfig, Update-AzureRmVM and Update-AzureRmVmss
2730
* Added EnableIPForwarding parameter to Add-AzureRmVmssNetworkInterfaceConfig

src/ResourceManager/Compute/Commands.Compute.Test/ScenarioTests/NewVhdVMTests.ps1

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@ function Test-NewAzureRmVhdVMWithValidDiskFile
3333
# Create a new VM using the tiny VHD file
3434
[string]$file = ".\VhdFiles\tiny.vhd";
3535
$vmname = $rgname + 'vm';
36-
$vm = New-AzureRmVM -ResourceGroupName $rgname -Name $vmname -Location $loc -DiskFile $file -OpenPorts 1234;
36+
[string]$domainNameLabel = "$vmname-$rgname".tolower();
37+
$vm = New-AzureRmVM -ResourceGroupName $rgname -Name $vmname -Location $loc -DiskFile $file -OpenPorts 1234 -DomainNameLabel $domainNameLabel;
3738
Assert-AreEqual $vm.Name $vmname;
3839
Assert-AreEqual $vm.Location $loc;
3940
Assert-Null $vm.OSProfile $null;
@@ -80,7 +81,8 @@ function Test-NewAzureRmVhdVMWithInvalidDiskFile
8081
$expectedErrorMessage = "*unsupported format*";
8182
try
8283
{
83-
$st = New-AzureRmVM -ResourceGroupName $rgname -Name $rgname -Location $loc -Linux -DiskFile $file1 -OpenPorts 1234;
84+
[string]$domainNameLabel = "$rgname-$rgname".tolower();
85+
$st = New-AzureRmVM -ResourceGroupName $rgname -Name $rgname -Location $loc -Linux -DiskFile $file1 -OpenPorts 1234 -DomainNameLabel $domainNameLabel;
8486
}
8587
catch
8688
{

src/ResourceManager/Compute/Commands.Compute.Test/ScenarioTests/StrategiesVirtualMachineTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public StrategiesVirtualMachineTests(Xunit.Abstractions.ITestOutputHelper output
2626
}
2727

2828
[Fact]
29-
[Trait(Category.RunType, Category.CheckIn)]
29+
[Trait(Category.AcceptanceType, Category.CheckIn)]
3030
public void TestSimpleNewVm()
3131
{
3232
ComputeTestController.NewInstance.RunPsTest("Test-SimpleNewVm");

src/ResourceManager/Compute/Commands.Compute.Test/ScenarioTests/StrategiesVirtualMachineTests.ps1

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,10 @@ function Test-SimpleNewVm
2626
$username = "admin01"
2727
$password = "werWER345#%^" | ConvertTo-SecureString -AsPlainText -Force
2828
$cred = new-object -typename System.Management.Automation.PSCredential -argumentlist $username, $password
29+
[string]$domainNameLabel = "$vmname-$vmname".tolower();
2930

3031
# Common
31-
$x = New-AzureRmVM -Name $vmname -Credential $cred
32+
$x = New-AzureRmVM -Name $vmname -Credential $cred -DomainNameLabel $domainNameLabel
3233

3334
Assert-AreEqual $vmname $x.Name;
3435
}

src/ResourceManager/Compute/Commands.Compute.Test/ScenarioTests/StrategiesVmssTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public StrategiesVmssTests(Xunit.Abstractions.ITestOutputHelper output)
2626
}
2727

2828
[Fact]
29-
[Trait(Category.RunType, Category.CheckIn)]
29+
[Trait(Category.AcceptanceType, Category.CheckIn)]
3030
public void TestSimpleNewVmss()
3131
{
3232
ComputeTestController.NewInstance.RunPsTest("Test-SimpleNewVmss");

src/ResourceManager/Compute/Commands.Compute.Test/ScenarioTests/StrategiesVmssTests.ps1

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,10 @@ function Test-SimpleNewVmss
2626
$username = "admin01"
2727
$password = "werWER345#%^" | ConvertTo-SecureString -AsPlainText -Force
2828
$cred = new-object -typename System.Management.Automation.PSCredential -argumentlist $username, $password
29+
[string]$domainNameLabel = "$vmssname$vmssname".tolower();
2930

3031
# Common
31-
$x = New-AzureRmVmss -Name $vmssname -Credential $cred
32+
$x = New-AzureRmVmss -Name $vmssname -Credential $cred -DomainNameLabel $domainNameLabel
3233

3334
Assert-AreEqual $vmssname $x.Name;
3435
Assert-AreEqual $vmssname $x.ResourceGroupName;

src/ResourceManager/Compute/Commands.Compute/Generated/Models/PSVirtualMachineScaleSet.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,5 +37,8 @@ public string ResourceGroupName
3737
return m.Success ? m.Groups["rgname"].Value : null;
3838
}
3939
}
40+
41+
// Gets or sets the FQDN.
42+
public string FullyQualifiedDomainName { get; set; }
4043
}
4144
}

src/ResourceManager/Compute/Commands.Compute/Generated/VirtualMachineScaleSet/VirtualMachineScaleSetCreateOrUpdateMethod.cs

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,6 @@ async Task SimpleParameterSetExecuteCmdlet(IAsyncCmdlet asyncCmdlet)
159159
VirtualNetworkName = VirtualNetworkName ?? VMScaleSetName;
160160
SubnetName = SubnetName ?? VMScaleSetName;
161161
PublicIpAddressName = PublicIpAddressName ?? VMScaleSetName;
162-
DomainNameLabel = DomainNameLabel ?? (VMScaleSetName + ResourceGroupName).ToLower();
163162
SecurityGroupName = SecurityGroupName ?? VMScaleSetName;
164163
LoadBalancerName = LoadBalancerName ?? VMScaleSetName;
165164
FrontendPoolName = FrontendPoolName ?? VMScaleSetName;
@@ -203,12 +202,12 @@ async Task SimpleParameterSetExecuteCmdlet(IAsyncCmdlet asyncCmdlet)
203202
}
204203

205204
BackendPort = BackendPort ?? (isWindows ? new[] { 3389, 5985 } : new[] { 22 });
206-
205+
207206
var resourceGroup = ResourceGroupStrategy.CreateResourceGroupConfig(ResourceGroupName);
208207

209208
var publicIpAddress = resourceGroup.CreatePublicIPAddressConfig(
210209
name: PublicIpAddressName,
211-
domainNameLabel: DomainNameLabel,
210+
getDomainNameLabel: () => DomainNameLabel,
212211
allocationMethod: AllocationMethod);
213212

214213
var virtualNetwork = resourceGroup.CreateVirtualNetworkConfig(
@@ -244,7 +243,9 @@ async Task SimpleParameterSetExecuteCmdlet(IAsyncCmdlet asyncCmdlet)
244243
image: image,
245244
vmSize: VmSize,
246245
instanceCount: InstanceCount,
247-
upgradeMode: (MyInvocation.BoundParameters.ContainsKey("UpgradePolicyMode") == true ) ? UpgradePolicyMode : (UpgradeMode?) null);
246+
upgradeMode: (MyInvocation.BoundParameters.ContainsKey("UpgradePolicyMode") == true )
247+
? UpgradePolicyMode
248+
: (UpgradeMode?) null);
248249

249250
var client = new Client(DefaultProfile.DefaultContext);
250251

@@ -260,6 +261,15 @@ async Task SimpleParameterSetExecuteCmdlet(IAsyncCmdlet asyncCmdlet)
260261
}
261262
}
262263

264+
// generate a domain name label if it's not specified.
265+
DomainNameLabel = await PublicIPAddressStrategy.UpdateDomainNameLabelAsync(
266+
domainNameLabel: DomainNameLabel,
267+
name: VMScaleSetName,
268+
location: Location,
269+
client: client);
270+
271+
var fqdn = PublicIPAddressStrategy.Fqdn(DomainNameLabel, Location);
272+
263273
var target = virtualMachineScaleSet.GetTargetState(current, client.SubscriptionId, Location);
264274

265275
var newState = await virtualMachineScaleSet
@@ -268,7 +278,7 @@ async Task SimpleParameterSetExecuteCmdlet(IAsyncCmdlet asyncCmdlet)
268278
target,
269279
new CancellationToken(),
270280
new ShouldProcess(asyncCmdlet),
271-
asyncCmdlet.ReportTaskProgress);
281+
asyncCmdlet.ReportTaskProgress);
272282

273283
var result = newState.Get(virtualMachineScaleSet);
274284
if(result == null)
@@ -279,7 +289,8 @@ async Task SimpleParameterSetExecuteCmdlet(IAsyncCmdlet asyncCmdlet)
279289
if (result != null)
280290
{
281291
var psObject = new PSVirtualMachineScaleSet();
282-
ComputeAutomationAutoMapperProfile.Mapper.Map<VirtualMachineScaleSet, PSVirtualMachineScaleSet>(result, psObject);
292+
ComputeAutomationAutoMapperProfile.Mapper.Map(result, psObject);
293+
psObject.FullyQualifiedDomainName = fqdn;
283294
asyncCmdlet.WriteObject(psObject);
284295
}
285296
}

src/ResourceManager/Compute/Commands.Compute/Strategies/Network/PublicIPAddressStrategy.cs

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
using Microsoft.Azure.Management.Internal.Network.Version2017_10_01;
1717
using Microsoft.Azure.Management.Internal.Network.Version2017_10_01.Models;
1818
using Microsoft.Azure.Management.Internal.Resources.Models;
19+
using System;
20+
using System.Threading.Tasks;
1921

2022
namespace Microsoft.Azure.Commands.Common.Strategies.Network
2123
{
@@ -35,7 +37,7 @@ static class PublicIPAddressStrategy
3537
public static ResourceConfig<PublicIPAddress> CreatePublicIPAddressConfig(
3638
this ResourceConfig<ResourceGroup> resourceGroup,
3739
string name,
38-
string domainNameLabel,
40+
Func<string> getDomainNameLabel,
3941
string allocationMethod)
4042
=> Strategy.CreateResourceConfig(
4143
resourceGroup: resourceGroup,
@@ -45,8 +47,33 @@ public static ResourceConfig<PublicIPAddress> CreatePublicIPAddressConfig(
4547
PublicIPAllocationMethod = allocationMethod,
4648
DnsSettings = new PublicIPAddressDnsSettings
4749
{
48-
DomainNameLabel = domainNameLabel,
50+
DomainNameLabel = getDomainNameLabel(),
4951
}
5052
});
53+
54+
public static async Task<string> UpdateDomainNameLabelAsync(
55+
string domainNameLabel,
56+
string name,
57+
string location,
58+
IClient client)
59+
{
60+
if (domainNameLabel == null)
61+
{
62+
var networkClient = client.GetClient<NetworkManagementClient>();
63+
do
64+
{
65+
domainNameLabel = (name + '-' + Guid.NewGuid().ToString().Substring(0, 6))
66+
.ToLower();
67+
} while ((await networkClient.CheckDnsNameAvailabilityAsync(
68+
location,
69+
domainNameLabel))
70+
.Available
71+
!= true);
72+
}
73+
return domainNameLabel;
74+
}
75+
76+
public static string Fqdn(string domainNameLabel, string location)
77+
=> domainNameLabel + "." + location + ".cloudapp.azure.com";
5178
}
5279
}

src/ResourceManager/Compute/Commands.Compute/VirtualMachine/Operation/NewAzureVMCommand.cs

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
using Microsoft.Azure.Commands.ResourceManager.Common.ArgumentCompleters;
2828
using Microsoft.Azure.Management.Compute;
2929
using Microsoft.Azure.Management.Compute.Models;
30+
using Microsoft.Azure.Management.Internal.Network.Version2017_10_01;
3031
using Microsoft.Azure.Management.Internal.Resources;
3132
using Microsoft.Azure.Management.Internal.Resources.Models;
3233
using Microsoft.Azure.Management.Storage;
@@ -234,7 +235,6 @@ async Task StrategyExecuteCmdletAsync(IAsyncCmdlet asyncCmdlet)
234235
VirtualNetworkName = VirtualNetworkName ?? Name;
235236
SubnetName = SubnetName ?? Name;
236237
PublicIpAddressName = PublicIpAddressName ?? Name;
237-
DomainNameLabel = DomainNameLabel ?? (Name + '-' + ResourceGroupName).ToLower();
238238
SecurityGroupName = SecurityGroupName ?? Name;
239239

240240
bool isWindows;
@@ -286,7 +286,7 @@ async Task StrategyExecuteCmdletAsync(IAsyncCmdlet asyncCmdlet)
286286
var subnet = virtualNetwork.CreateSubnet(SubnetName, SubnetAddressPrefix);
287287
var publicIpAddress = resourceGroup.CreatePublicIPAddressConfig(
288288
name: PublicIpAddressName,
289-
domainNameLabel: DomainNameLabel,
289+
getDomainNameLabel: () => DomainNameLabel,
290290
allocationMethod: AllocationMethod);
291291
var networkSecurityGroup = resourceGroup.CreateNetworkSecurityGroupConfig(
292292
name: SecurityGroupName,
@@ -408,7 +408,14 @@ async Task StrategyExecuteCmdletAsync(IAsyncCmdlet asyncCmdlet)
408408
}
409409
}
410410

411-
var fqdn = DomainNameLabel + "." + Location + ".cloudapp.azure.com";
411+
// generate a domain name label if it's not specified.
412+
DomainNameLabel = await PublicIPAddressStrategy.UpdateDomainNameLabelAsync(
413+
domainNameLabel: DomainNameLabel,
414+
name: Name,
415+
location: Location,
416+
client: client);
417+
418+
var fqdn = PublicIPAddressStrategy.Fqdn(DomainNameLabel, Location);
412419

413420
// create target state
414421
var target = virtualMachine.GetTargetState(current, client.SubscriptionId, Location);

src/ResourceManager/Compute/Compute.sln

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,11 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Commands.Common.Graph.RBAC"
4646
EndProject
4747
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Commands.Common.Strategies.UnitTest", "..\Common\Commands.Common.Strategies.UnitTest\Commands.Common.Strategies.UnitTest.csproj", "{6756A7F2-1141-4065-BA23-0C555D2A2BC3}"
4848
EndProject
49+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{B395D5F1-BB9A-481C-A395-9EA5B8F68E1B}"
50+
ProjectSection(SolutionItems) = preProject
51+
ChangeLog.md = ChangeLog.md
52+
EndProjectSection
53+
EndProject
4954
Global
5055
GlobalSection(SolutionConfigurationPlatforms) = preSolution
5156
Debug|Any CPU = Debug|Any CPU

src/Storage/ChangeLog.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,9 @@
1818
- Additional information about change #1
1919
-->
2020
## Current Release
21-
21+
* Fix Get Blob Container cmdlet execute fail with Accout SAS credential issue
22+
- Get-AzureStorageContainer
23+
2224
## Version 4.1.0
2325
* Add cmdlets to get and set Storage service properties
2426
- Get-AzureStorageServiceProperty

src/Storage/Commands.Storage/Blob/Cmdlet/GetAzureStorageContainer.cs

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,17 @@ internal void PackCloudBlobContainerWithAcl(IEnumerable<Tuple<CloudBlobContainer
206206
return;
207207
}
208208

209+
// Only write warning for SAS when use cmdlet alias Get-AzureStorageContainerAcl, since the cmdlets alias specified get container ACL
210+
if (this.MyInvocation.Line.ToLower().Contains("get-azurestoragecontaineracl"))
211+
{
212+
// Write warning when user SAS credential since get container ACL will fail
213+
AzureStorageContext storageContext = this.GetCmdletStorageContext();
214+
if (storageContext != null && storageContext.StorageAccount != null && storageContext.StorageAccount.Credentials != null && storageContext.StorageAccount.Credentials.IsSAS)
215+
{
216+
WriteWarning("Get container permission will fail with SAS token credentials, it needs storage Account key credentials.");
217+
}
218+
}
219+
209220
IStorageBlobManagement localChannel = Channel;
210221
foreach (Tuple<CloudBlobContainer, BlobContinuationToken> containerInfo in containerList)
211222
{
@@ -231,13 +242,10 @@ internal async Task GetContainerPermission(long taskId, IStorageBlobManagement l
231242
permissions = await localChannel.GetContainerPermissionsAsync(container, accessCondition,
232243
requestOptions, OperationContext, CmdletCancellationToken).ConfigureAwait(false);
233244
}
234-
catch (StorageException e)
245+
catch (StorageException e) when (e.IsNotFoundException() || e.IsForbiddenException())
235246
{
236-
if (!e.IsNotFoundException())
237-
{
238-
throw;
239-
}
240-
//404 Not found means we don't have permission to query the Permission of the specified container.
247+
// 404 Not found, or 403 Forbidden means we don't have permission to query the Permission of the specified container.
248+
// Just skip return container permission in this case.
241249
}
242250
WriteCloudContainerObject(taskId, localChannel, container, permissions, continuationToken);
243251
}

src/Storage/Commands.Storage/Common/StorageExceptionUtil.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,16 @@ public static bool IsNotFoundException(this StorageException e)
3232
return e.RequestInformation != null && e.RequestInformation.HttpStatusCode == 404;
3333
}
3434

35+
/// <summary>
36+
/// Whether the storage exception is Fordidden exception or not.
37+
/// </summary>
38+
/// <param name="e">StorageException from storage client</param>
39+
/// <returns>Whether the storageexception is caused by Fordidden</returns>
40+
public static bool IsForbiddenException(this StorageException e)
41+
{
42+
return e.RequestInformation != null && e.RequestInformation.HttpStatusCode == 403;
43+
}
44+
3545
/// <summary>
3646
/// Whether the storage exception is 409 conflict exception
3747
/// </summary>

src/Storage/Commands.Storage/Microsoft.WindowsAzure.Commands.Storage.format.ps1xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -326,6 +326,7 @@
326326
<TableColumnHeader>
327327
<Label>Name</Label>
328328
<Alignment>Left</Alignment>
329+
<Width>20</Width>
329330
</TableColumnHeader>
330331
<TableColumnHeader>
331332
<Label>PublicAccess</Label>

0 commit comments

Comments
 (0)