Skip to content

. #306

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 21 commits into from
Jan 7, 2016
Merged

. #306

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
3f4e726
update to latest c# client
x10shun Dec 16, 2015
fe79207
Pull changes
x10shun Dec 16, 2015
7d629f9
Merge branch 'dev' of github.com:Azure/azure-powershell into dev
Dec 29, 2015
154b478
Merge remote-tracking branch 'upstream/dev' into dev
x10shun Dec 29, 2015
1d2873a
Merge branch 'dev' of github.com:Azure/azure-powershell into dev
Dec 30, 2015
2d1813d
Merge branch 'dev' of github.com:Azure/azure-powershell into dev
Dec 31, 2015
c42d3fb
Add support for creating/cloning sites on Application Service Environ…
x10shun Jan 5, 2016
6d4846a
Merge remote-tracking branch 'upstream/dev' into dev
x10shun Jan 5, 2016
d89fa33
Fix AseName in NewWebApp cmdlet
x10shun Jan 5, 2016
118a720
Fixing hostingEnvironments Uri, adding aseRGN to new-azureRmwebapp an…
x10shun Jan 5, 2016
a472d4b
Merge branch 'dev' of github.com:Azure/azure-powershell into dev
Jan 5, 2016
dd01fcd
Merge branch 'dev' of github.com:Azure/azure-powershell into dev
Jan 6, 2016
d256c48
Add test cases for new AseName Parameter
x10shun Jan 6, 2016
c4824fa
Merge remote-tracking branch 'upstream/dev' into dev
x10shun Jan 6, 2016
f083440
Update changelog
x10shun Jan 6, 2016
13dc0e2
Merge pull request #1582 from naveedaz/dev
stankovski Jan 7, 2016
6f79281
Fixed [#110120350] Subscriptions and tenants can be listed correctly …
Jan 7, 2016
fcb9cf9
Merge branch 'dev' of github.com:Azure/azure-powershell into dev
Jan 7, 2016
285c386
fixed issue #1484
Jan 7, 2016
9497268
Addressed review feedbacks
Jan 7, 2016
12bfe67
Merge pull request #1594 from hovsepm/dev
stankovski Jan 7, 2016
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
* New-AzureRmWebAppSSLBinding
* Get-AzureRmWebAppSSLBinding
* Remove-AzureRmWebAppSSLBinding
* Azure Websites: Added AseName and AseResourceGroupName parameters in New-AzureRmAppServicePlan cmdlet
* Azure Websites: Added AseName and AseResourceGroupName parameters in New-AzureRmWebApp and New-AzureRmAppServicePlan cmdlet

## 2015.12.14 version 1.0.2
* Azure Compute (ARM):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public AzureRMProfile Login(
var token = AcquireAccessToken(account, environment, tenantId, password, promptBehavior);
if(TryGetTenantSubscription(token, account, environment, tenantId, subscriptionId, subscriptionName, out newSubscription, out newTenant))
{
account.SetProperty(AzureAccount.Property.Tenants, new[] { newTenant.Id.ToString() });
account.SetOrAppendProperty(AzureAccount.Property.Tenants, new[] { newTenant.Id.ToString() });
}
}
// (tenant is not provided and subscription is present) OR
Expand Down Expand Up @@ -240,7 +240,7 @@ private void SwitchSubscription(AzureSubscription subscription)

public List<AzureTenant> ListTenants(string tenant)
{
return ListAccountTenants(_profile.Context.Account, _profile.Context.Environment, null, ShowDialog.Auto)
return ListAccountTenants(_profile.Context.Account, _profile.Context.Environment, null, ShowDialog.Never)
.Where(t => tenant == null ||
tenant.Equals(t.Id.ToString(), StringComparison.OrdinalIgnoreCase) ||
tenant.Equals(t.Domain, StringComparison.OrdinalIgnoreCase))
Expand Down Expand Up @@ -380,7 +380,9 @@ public IEnumerable<AzureSubscription> ListSubscriptions()
{
try
{
subscriptions.AddRange(ListSubscriptions(tenant.Id.ToString()));
subscriptions.AddRange(
ListSubscriptions(
(tenant.Id == Guid.Empty) ? tenant.Domain:tenant.Id.ToString()));
}
catch (AadAuthenticationException)
{
Expand Down Expand Up @@ -481,19 +483,24 @@ private bool TryGetTenantSubscription(IAccessToken accessToken,
}
else
{
var subscriptions = subscriptionClient.Subscriptions.List().Subscriptions;
if (subscriptions != null && subscriptions.Any())
var subscriptions = (subscriptionClient.Subscriptions.List().Subscriptions ??
new List<Microsoft.Azure.Subscriptions.Models.Subscription>())
.Where(s => "enabled".Equals(s.State, StringComparison.OrdinalIgnoreCase) ||
"warned".Equals(s.State, StringComparison.OrdinalIgnoreCase));

if (subscriptions.Any())
{
if (subscriptionName != null)
{
subscriptionFromServer = subscriptions.FirstOrDefault(s => s.DisplayName.Equals(subscriptionName, StringComparison.OrdinalIgnoreCase));
subscriptionFromServer = subscriptions.FirstOrDefault(
s => s.DisplayName.Equals(subscriptionName, StringComparison.OrdinalIgnoreCase));
}
else
{
if (subscriptions.Count > 1)
if (subscriptions.Count() > 1)
{
WriteWarningMessage(string.Format(
"TenantId '{0}' contains more than one subscription. First one will be selected for further use. " +
"TenantId '{0}' contains more than one active subscription. First one will be selected for further use. " +
"To select another subscription, use Set-AzureRmContext.",
tenantId));
}
Expand Down Expand Up @@ -569,10 +576,21 @@ private List<AzureTenant> ListAccountTenants(AzureAccount account, AzureEnvironm
{
result =
account.GetPropertyAsArray(AzureAccount.Property.Tenants)
.Select( ti => new AzureTenant()
{
Id = new Guid(ti),
Domain = AccessTokenExtensions.GetDomain(account.Id)
.Select( ti => {
var tenant = new AzureTenant();

Guid guid;
if(Guid.TryParse(ti, out guid))
{
tenant.Id = guid;
tenant.Domain = AccessTokenExtensions.GetDomain(account.Id);
}
else
{
tenant.Domain = ti;
}

return tenant;
}).ToList();
}

Expand Down Expand Up @@ -608,7 +626,7 @@ private IEnumerable<AzureSubscription> ListSubscriptionsForTenant(AzureAccount a
subscriptions.Subscriptions.Select(
(s) =>
s.ToAzureSubscription(new AzureContext(_profile.Context.Subscription, account,
environment, CreateTenantFromString(tenantId))));
environment, CreateTenantFromString(tenantId, accessToken.TenantId))));
}

return new List<AzureSubscription>();
Expand All @@ -623,7 +641,7 @@ private void WriteWarningMessage(string message)
}
}

private static AzureTenant CreateTenantFromString(string tenantOrDomain)
private static AzureTenant CreateTenantFromString(string tenantOrDomain, string accessTokenTenantId)
{
AzureTenant result = new AzureTenant();
Guid id;
Expand All @@ -633,6 +651,7 @@ private static AzureTenant CreateTenantFromString(string tenantOrDomain)
}
else
{
result.Id = Guid.Parse(accessTokenTenantId);
result.Domain = tenantOrDomain;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@
<Private>True</Private>
</Reference>
<Reference Include="Microsoft.Azure.Management.Websites, Version=1.0.0.2, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\packages\Microsoft.Azure.Management.Websites.1.0.2-preview\lib\net45\Microsoft.Azure.Management.Websites.dll</HintPath>
<Private>True</Private>
</Reference>
Expand Down Expand Up @@ -129,6 +130,7 @@
</Reference>
<Reference Include="System.Net.Http.WebRequest" />
<Reference Include="System.Runtime.Serialization" />
<Reference Include="System.Xml" />
<Reference Include="xunit, Version=1.9.2.1705, Culture=neutral, PublicKeyToken=8d05b1bb7a6fdb6c, processorArchitecture=MSIL">
<HintPath>..\..\..\packages\xunit.1.9.2\lib\net20\xunit.dll</HintPath>
<Private>True</Private>
Expand All @@ -139,13 +141,11 @@
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="NewAzureWebsitesCommandTests.cs" />
<Compile Include="ScenarioTests\AppServicePlanTests.cs" />
<Compile Include="ScenarioTests\SSLBindingTests.cs" />
<Compile Include="ScenarioTests\WebAppSlotTests.cs" />
<Compile Include="ScenarioTests\WebsitesController.cs" />
<Compile Include="ScenarioTests\WebAppTests.cs" />
<Compile Include="WebsitesTestHelpers.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
Expand Down Expand Up @@ -210,6 +210,9 @@
<None Include="SessionRecords\Microsoft.Azure.Commands.Websites.Test.ScenarioTests.WebAppSlotTests\TestCreateNewWebAppSlot.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="SessionRecords\Microsoft.Azure.Commands.Websites.Test.ScenarioTests.WebAppSlotTests\TestCreateNewWebAppSlotOnAse.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="SessionRecords\Microsoft.Azure.Commands.Websites.Test.ScenarioTests.WebAppSlotTests\TestGetWebAppSlot.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
Expand All @@ -231,6 +234,9 @@
<None Include="SessionRecords\Microsoft.Azure.Commands.Websites.Test.ScenarioTests.WebAppTests\TestCloneNewWebAppWithNewTrafficManager.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="SessionRecords\Microsoft.Azure.Commands.Websites.Test.ScenarioTests.WebAppTests\TestCreateNewAppOnAse.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="SessionRecords\Microsoft.Azure.Commands.Websites.Test.ScenarioTests.WebAppTests\TestCreateNewWebApp.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,15 @@ function Get-ResourceGroupName
return getAssetName
}

<#
.SYNOPSIS
Gets an aseName for testing.
#>
function Get-AseName
{
return getAssetName
}

<#
.SYNOPSIS
Gets the location for the Website. Default to West US if none found.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,13 @@ public void TestCreateNewWebAppSlot()
WebsitesController.NewInstance.RunPsTest("Test-CreateNewWebAppSlot");
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestCreateNewWebAppSlotOnAse()
{
WebsitesController.NewInstance.RunPsTest("Test-CreateNewWebAppSlotOnAse");
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestGetWebAppSlot()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -430,6 +430,65 @@ function Test-CreateNewWebAppSlot
}
}

<#
.SYNOPSIS
Tests creating a new web app slot on ASE.
#>
function Test-CreateNewWebAppSlotOnAse
{
# Setup
$rgname = "appdemorg"
$appname = Get-WebsiteName
$slotname = "staging"
$location = "West US"
$planName = "travel_production_plan"
$aseName = "asedemo"

$apiversion = "2015-08-01"
$resourceType = "Microsoft.Web/sites"
try
{
#Setup
$serverFarm = Get-AzureRmAppServicePlan -ResourceGroupName $rgname -Name $planName

# Create new web app
$actual = New-AzureRmWebApp -ResourceGroupName $rgname -Name $appname -Location $location -AppServicePlan $planName -AseName $aseName

# Assert
Assert-AreEqual $appname $actual.Name
Assert-AreEqual $serverFarm.Id $actual.ServerFarmId

# Get new web app
$result = Get-AzureRmWebApp -ResourceGroupName $rgname -Name $appname

# Assert
Assert-AreEqual $appname $result.Name
Assert-AreEqual $serverFarm.Id $result.ServerFarmId

# Create deployment slot
$slot1 = New-AzureRmWebAppSlot -ResourceGroupName $rgname -Name $appname -Slot $slotname -AppServicePlan $planName -AseName $aseName
$appWithSlotName = "$appname/$slotname"

# Assert
Assert-AreEqual $appWithSlotName $slot1.Name
Assert-AreEqual $serverFarm.Id $slot1.ServerFarmId

# Get new web app slot
$slot1 = Get-AzureRmWebAppSlot -ResourceGroupName $rgname -Name $appname -Slot $slotname

# Assert
Assert-AreEqual $appWithSlotName $slot1.Name
Assert-AreEqual $serverFarm.Id $slot1.ServerFarmId

}
finally
{
# Cleanup
Remove-AzureRmWebAppSlot -ResourceGroupName $rgname -Name $appname -Slot $slotname -Force
Remove-AzureRmWebApp -ResourceGroupName $rgname -Name $appname -Force
}
}

<#
.SYNOPSIS
Tests retrieving web app slots
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,13 @@ public void TestCreateNewWebApp()
WebsitesController.NewInstance.RunPsTest("Test-CreateNewWebApp");
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestCreateNewAppOnAse()
{
WebsitesController.NewInstance.RunPsTest("Test-CreateNewWebAppOnAse");
}

[Fact(Skip = "Needs investigation. Fails running playback")]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestGetWebApp()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -408,6 +408,46 @@ function Test-CreateNewWebApp
}
}

<#
.SYNOPSIS
Tests creating a new website on an ase
#>
function Test-CreateNewWebAppOnAse
{
# Setup
$rgname = "appdemorg"
$wname = Get-WebsiteName
$location = "West US"
$whpName = "travel_production_plan"
$aseName = "asedemo"
$apiversion = "2015-08-01"
$resourceType = "Microsoft.Web/sites"
try
{
#Setup
$serverFarm = Get-AzureRmAppServicePlan -ResourceGroupName $rgname -Name $whpName

# Create new web app
$actual = New-AzureRmWebApp -ResourceGroupName $rgname -Name $wname -Location $location -AppServicePlan $whpName -AseName $aseName

# Assert
Assert-AreEqual $wname $actual.Name
Assert-AreEqual $serverFarm.Id $actual.ServerFarmId

# Get new web app
$result = Get-AzureRmWebApp -ResourceGroupName $rgname -Name $wname

# Assert
Assert-AreEqual $wname $result.Name
Assert-AreEqual $serverFarm.Id $result.ServerFarmId
}
finally
{
# Cleanup
Remove-AzureRmWebApp -ResourceGroupName $rgname -Name $wname -Force
}
}

<#
.SYNOPSIS
Tests retrieving websites
Expand Down
Loading