Skip to content

Commit 3db30d8

Browse files
committed
Merge pull request #7 from Azure/build
update
2 parents f0c2f75 + 475ebc2 commit 3db30d8

File tree

11 files changed

+527
-14
lines changed

11 files changed

+527
-14
lines changed

README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,6 @@ For detail descriptions and examples of the cmdlets, type
122122
* ```help azure``` to get all the cmdlets.
123123
* ```help node-dev``` to get all Node.js development related cmdlets.
124124
* ```help php-dev``` to get all PHP development related cmdlets.
125-
* ```help python-dev``` to get all Python development related cmdlets.
126125
* ```help <cmdlet name>``` to get the details of a specific cmdlet.
127126

128127
## Supported Environments

src/ResourceManager/TrafficManager/Commands.TrafficManager2.Test/Commands.TrafficManager2.Test.csproj

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,9 @@
107107
<None Include="SessionRecords\Microsoft.Azure.Commands.TrafficManager.Test.ScenarioTests.ProfileTests\TestCreateDeleteUsingProfile.json">
108108
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
109109
</None>
110+
<None Include="SessionRecords\Microsoft.Azure.Commands.TrafficManager.Test.ScenarioTests.ProfileTests\TestCrudWithEndpoint.json">
111+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
112+
</None>
110113
<None Include="SessionRecords\Microsoft.Azure.Commands.TrafficManager.Test.ScenarioTests.ProfileTests\TestProfileCrud.json">
111114
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
112115
</None>

src/ResourceManager/TrafficManager/Commands.TrafficManager2.Test/ScenarioTests/Common.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ Creates a resource group to use in tests
7575
#>
7676
function TestSetup-AddEndpoint($endpointName, $profile)
7777
{
78-
$profile = Add-AzureTrafficManagerEndpointConfig -EndpointName $endpointName -TrafficManagerProfile $profile -Type "ExternalEndpoint" -Target "www.contoso.com" -EndpointStatus "Enabled" -EndpointLocation "North Europe"
78+
$profile = Add-AzureTrafficManagerEndpointConfig -EndpointName $endpointName -TrafficManagerProfile $profile -Type "ExternalEndpoints" -Target "www.contoso.com" -EndpointStatus "Enabled" -EndpointLocation "North Europe"
7979

8080
return $profile
8181
}

src/ResourceManager/TrafficManager/Commands.TrafficManager2.Test/ScenarioTests/ProfileTests.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,13 @@ public void TestCreateDeleteUsingProfile()
4040
WatmV2TestsBase.NewInstance.RunPowerShellTest("Test-CreateDeleteUsingProfile");
4141
}
4242

43+
[Fact]
44+
[Trait(Category.AcceptanceType, Category.CheckIn)]
45+
public void TestCrudWithEndpoint()
46+
{
47+
WatmV2TestsBase.NewInstance.RunPowerShellTest("Test-CrudWithEndpoint");
48+
}
49+
4350
[Fact]
4451
[Trait(Category.AcceptanceType, Category.CheckIn)]
4552
public void TestProfileNewAlreadyExists()

src/ResourceManager/TrafficManager/Commands.TrafficManager2.Test/ScenarioTests/ProfileTests.ps1

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ Full Profile CRUD cycle
1919
function Test-ProfileCrud
2020
{
2121
$profileName = getAssetName
22-
$resourceGroup = TestSetup-CreateResourceGroup
22+
$resourceGroup = TestSetup-CreateResourceGroup
2323
$relativeName = getAssetName
2424
$createdProfile = New-AzureTrafficManagerProfile -Name $profileName -ResourceGroupName $resourceGroup.ResourceGroupName -RelativeDnsName $relativeName -Ttl 50 -TrafficRoutingMethod "Performance" -MonitorProtocol "HTTP" -MonitorPort 80 -MonitorPath "/testpath.asp"
2525

@@ -91,6 +91,24 @@ function Test-CreateDeleteUsingProfile
9191
Assert-Throws { Get-AzureTrafficManagerProfile -Name $profileName -ResourceGroupName $resourceGroup.ResourceGroupName } "ResourceNotFound: Resource not found."
9292
}
9393

94+
<#
95+
.SYNOPSIS
96+
Full cycle to create an Endpoint in a Profile
97+
#>
98+
function Test-CrudWithEndpoint
99+
{
100+
$profileName = getAssetName
101+
$resourceGroup = TestSetup-CreateResourceGroup
102+
$relativeName = getAssetName
103+
$createdProfile = New-AzureTrafficManagerProfile -Name $profileName -ResourceGroupName $resourceGroup.ResourceGroupName -RelativeDnsName $relativeName -Ttl 50 -TrafficRoutingMethod "Performance" -MonitorProtocol "HTTP" -MonitorPort 80 -MonitorPath "/testpath.asp"
104+
105+
$profileWithEndpoint = Add-AzureTrafficManagerEndpointConfig -EndpointName "MyExternalEndpoint" -TrafficManagerProfile $createdProfile -Type "ExternalEndpoints" -Target "www.contoso.com" -EndpointStatus "Enabled" -EndpointLocation "North Europe"
106+
107+
$updatedProfile = Set-AzureTrafficManagerProfile -TrafficManagerProfile $profileWithEndpoint
108+
109+
Assert-AreEqual 1 $updatedProfile.Endpoints.Count
110+
}
111+
94112
<#
95113
.SYNOPSIS
96114
Create a Profile that already exists

src/ResourceManager/TrafficManager/Commands.TrafficManager2.Test/SessionRecords/Microsoft.Azure.Commands.TrafficManager.Test.ScenarioTests.ProfileTests/TestCrudWithEndpoint.json

Lines changed: 434 additions & 0 deletions
Large diffs are not rendered by default.

src/ResourceManager/TrafficManager/Commands.TrafficManager2.Test/packages.config

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
<package id="Microsoft.Azure.Common.Authentication" version="1.0.17-preview" targetFramework="net45" />
66
<package id="Microsoft.Azure.Common.Dependencies" version="1.0.0" targetFramework="net45" />
77
<package id="Microsoft.Azure.Management.Authorization" version="0.17.0-preview" targetFramework="net45" />
8+
<package id="Microsoft.Azure.Gallery" version="2.6.2-preview" targetFramework="net45" />
89
<package id="Microsoft.Azure.Management.Resources" version="2.14.1-preview" targetFramework="net45" />
910
<package id="Microsoft.Azure.Test.Framework" version="1.0.5513.27084-prerelease" targetFramework="net45" />
1011
<package id="Microsoft.Azure.Test.HttpRecorder" version="1.0.5513.27084-prerelease" targetFramework="net45" />

src/ResourceManager/TrafficManager/Commands.TrafficManager2/Models/Endpoint.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
namespace Microsoft.Azure.Commands.TrafficManager.Models
1616
{
17+
using System;
1718
using Microsoft.Azure.Commands.TrafficManager.Utilities;
1819

1920
public class Endpoint
@@ -28,7 +29,7 @@ public string Type
2829

2930
set
3031
{
31-
if (!value.StartsWith(Constants.ProfileType))
32+
if (!value.StartsWith(Constants.ProfileType, StringComparison.OrdinalIgnoreCase))
3233
{
3334
this.type = string.Format("{0}/{1}", Constants.ProfileType, value);
3435
}

src/ResourceManager/TrafficManager/Commands.TrafficManager2/Models/TrafficManagerProfile.cs

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,10 @@ public class TrafficManagerProfile
4040

4141
public Profile ToSDKProfile()
4242
{
43-
return new Profile
43+
var profile = new Profile
4444
{
4545
Name = this.Name,
46+
Type = Constants.ProfileType,
4647
Location = TrafficManagerClient.ProfileResourceLocation,
4748
Properties = new ProfileProperties
4849
{
@@ -60,6 +61,30 @@ public Profile ToSDKProfile()
6061
}
6162
}
6263
};
64+
65+
if (this.Endpoints.Count > 0)
66+
{
67+
profile.Properties.Endpoints = new List<Management.TrafficManager.Models.Endpoint>();
68+
69+
foreach (Endpoint endpoint in this.Endpoints)
70+
{
71+
profile.Properties.Endpoints.Add(new Management.TrafficManager.Models.Endpoint
72+
{
73+
Name = endpoint.Name,
74+
Type = endpoint.Type,
75+
Properties = new EndpointProperties
76+
{
77+
Target = endpoint.Target,
78+
EndpointStatus = endpoint.EndpointStatus,
79+
Weight = endpoint.Weight,
80+
Priority = endpoint.Priority,
81+
EndpointLocation = endpoint.Location
82+
}
83+
});
84+
}
85+
}
86+
87+
return profile;
6388
}
6489
}
6590
}

src/ResourceManager/TrafficManager/Commands.TrafficManager2/Utilities/Constants.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@ namespace Microsoft.Azure.Commands.TrafficManager.Utilities
1616
{
1717
public class Constants
1818
{
19-
public const string AzureEndpoint = "AzureEndpoint";
20-
public const string ExternalEndpoint = "ExternalEndpoint";
21-
public const string NestedEndpoint = "NestedEndpoint";
19+
public const string AzureEndpoint = "AzureEndpoints";
20+
public const string ExternalEndpoint = "ExternalEndpoints";
21+
public const string NestedEndpoint = "NestedEndpoints";
2222

2323
public const string StatusEnabled = "Enabled";
2424
public const string StatusDisabled = "Disabled";
@@ -30,6 +30,6 @@ public class Constants
3030
public const string HTTP = "HTTP";
3131
public const string HTTPS = "HTTPS";
3232

33-
public const string ProfileType = "Microsoft.Network/TrafficManagerProfiles";
33+
public const string ProfileType = "Microsoft.Network/trafficManagerProfiles";
3434
}
3535
}

src/ResourceManager/TrafficManager/Commands.TrafficManager2/Utilities/TrafficManagerClient.cs

Lines changed: 30 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
namespace Microsoft.Azure.Commands.TrafficManager.Utilities
1616
{
17+
using System.Collections.Generic;
1718
using System.Net;
1819
using Microsoft.Azure.Commands.TrafficManager.Models;
1920
using Microsoft.Azure.Common.Authentication;
@@ -79,13 +80,16 @@ public TrafficManagerProfile GetTrafficManagerProfile(string resourceGroupName,
7980

8081
public TrafficManagerProfile SetTrafficManagerProfile(TrafficManagerProfile profile)
8182
{
83+
var parameteres = new ProfileCreateOrUpdateParameters
84+
{
85+
Profile = profile.ToSDKProfile()
86+
};
87+
8288
ProfileCreateOrUpdateResponse response = this.TrafficManagerManagementClient.Profiles.CreateOrUpdate(
8389
profile.ResourceGroupName,
8490
profile.Name,
85-
new ProfileCreateOrUpdateParameters
86-
{
87-
Profile = profile.ToSDKProfile()
88-
});
91+
parameteres
92+
);
8993

9094
return TrafficManagerClient.GetPowershellTrafficManagerProfile(profile.ResourceGroupName, profile.Name, response.Profile.Properties);
9195
}
@@ -99,7 +103,7 @@ public bool DeleteTrafficManagerProfile(TrafficManagerProfile profile)
99103

100104
private static TrafficManagerProfile GetPowershellTrafficManagerProfile(string resourceGroupName, string profileName, ProfileProperties mamlProfileProperties)
101105
{
102-
return new TrafficManagerProfile
106+
var profile = new TrafficManagerProfile
103107
{
104108
Name = profileName,
105109
ResourceGroupName = resourceGroupName,
@@ -110,6 +114,27 @@ private static TrafficManagerProfile GetPowershellTrafficManagerProfile(string r
110114
MonitorPort = mamlProfileProperties.MonitorConfig.Port,
111115
MonitorPath = mamlProfileProperties.MonitorConfig.Path
112116
};
117+
118+
if (mamlProfileProperties.Endpoints != null)
119+
{
120+
profile.Endpoints = new List<Models.Endpoint>();
121+
122+
foreach (Endpoint endpoint in mamlProfileProperties.Endpoints)
123+
{
124+
profile.Endpoints.Add(new Models.Endpoint
125+
{
126+
Name = endpoint.Name,
127+
Type = endpoint.Type,
128+
Target = endpoint.Properties.Target,
129+
EndpointStatus = endpoint.Properties.EndpointStatus,
130+
Location = endpoint.Properties.EndpointLocation,
131+
Priority = endpoint.Properties.Priority,
132+
Weight = endpoint.Properties.Weight
133+
});
134+
}
135+
}
136+
137+
return profile;
113138
}
114139
}
115140
}

0 commit comments

Comments
 (0)