Skip to content

Commit 97e8416

Browse files
authored
Merge pull request Azure#3860 from NonStatic2014/ml_new_version
Azure Machine Learning WebServicesRP new API version (Re-submit)
2 parents c329ccd + 0c0b939 commit 97e8416

29 files changed

+4185
-2384
lines changed

src/ResourceManager/MachineLearning/AzureRM.MachineLearning.psd1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ CmdletsToExport = 'Move-AzureRmMlCommitmentAssociation',
8080
'Get-AzureRmMlWebService', 'Update-AzureRmMlWebService',
8181
'Export-AzureRmMlWebService', 'Get-AzureRmMlWebServiceKeys',
8282
'Import-AzureRmMlWebService', 'New-AzureRmMlCommitmentPlan',
83-
'New-AzureRmMlWebService'
83+
'New-AzureRmMlWebService', 'Add-AzureRmMlWebServiceRegionalProperty'
8484

8585
# Variables to export from this module
8686
# VariablesToExport = @()

src/ResourceManager/MachineLearning/ChangeLog.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@
1818
- Additional information about change #1
1919
-->
2020
## Current Release
21+
* Consume new version of Azure Machine Learning .Net SDK and add a new cmdlet
22+
- Add-AzureRmMlWebServiceRegionalProperty
23+
* Minor wording fixes in help text.
2124

2225
## Version 0.13.0
2326

src/ResourceManager/MachineLearning/Commands.MachineLearning.Test/Commands.MachineLearning.Test.csproj

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@
5959
<HintPath>..\..\..\packages\Microsoft.Azure.Management.Authorization.2.0.0\lib\net40\Microsoft.Azure.Management.Authorization.dll</HintPath>
6060
<Private>True</Private>
6161
</Reference>
62-
<Reference Include="..\..\..\packages\Microsoft.Azure.Management.MachineLearning.0.9.6-preview\lib\net45\Microsoft.Azure.Management.MachineLearning.dll">
62+
<Reference Include="..\..\..\packages\Microsoft.Azure.Management.MachineLearning.1.0.0\lib\net45\Microsoft.Azure.Management.MachineLearning.dll">
6363
<Name>Microsoft.Azure.Management.MachineLearning</Name>
6464
<Private>True</Private>
6565
</Reference>
@@ -180,6 +180,9 @@
180180
<None Include="SessionRecords\Microsoft.Azure.Commands.MachineLearning.Test.ScenarioTests.WebServiceTests\TestUpdateWebService.json">
181181
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
182182
</None>
183+
<None Include="SessionRecords\Microsoft.Azure.Commands.MachineLearning.Test.ScenarioTests.WebServiceTests\TestCreateAndGetRegionalProperties.json">
184+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
185+
</None>
183186
<None Include="SessionRecords\Microsoft.Azure.Commands.MachineLearning.Test.ScenarioTests.CommitmentPlanTests\TestCreateGetRemoveCommitmentPlan.json">
184187
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
185188
</None>

src/ResourceManager/MachineLearning/Commands.MachineLearning.Test/ScenarioTests/Common.ps1

Lines changed: 11 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -78,31 +78,22 @@ Gets the latest API Version for the resource type
7878
#>
7979
function Get-ProviderAPIVersion($providerNamespace, $resourceType)
8080
{
81-
if ([Microsoft.Azure.Test.HttpRecorder.HttpMockServer]::Mode -ne `
82-
[Microsoft.Azure.Test.HttpRecorder.HttpRecorderMode]::Playback)
83-
{
84-
$provider = Get-AzureRmResourceProvider -ProviderNamespace $providerNamespace
85-
$resourceType = $provider.ResourceTypes | where {$_.ResourceTypeName -eq $resourceType}
86-
return $resourceType.ApiVersions[$resourceType.ApiVersions.Count -1]
87-
} else
81+
if ($providerNamespace -eq "Microsoft.MachineLearning")
8882
{
89-
if ($providerNamespace -eq "Microsoft.MachineLearning")
83+
if ([System.String]::Equals($resourceType, "commitmentPlans", `
84+
[System.StringComparison]::OrdinalIgnoreCase))
9085
{
91-
if ([System.String]::Equals($resourceType, "commitmentPlans", `
92-
[System.StringComparison]::OrdinalIgnoreCase))
93-
{
94-
return "2016-05-01-preview"
95-
}
96-
97-
if ([System.String]::Equals($resourceType, "webServices", `
98-
[System.StringComparison]::OrdinalIgnoreCase))
99-
{
100-
return "2016-05-01-preview"
101-
}
86+
return "2016-05-01-preview"
10287
}
10388

104-
return $null
89+
if ([System.String]::Equals($resourceType, "webServices", `
90+
[System.StringComparison]::OrdinalIgnoreCase))
91+
{
92+
return "2017-01-01"
93+
}
10594
}
95+
96+
return $null
10697
}
10798

10899
<#

src/ResourceManager/MachineLearning/Commands.MachineLearning.Test/ScenarioTests/WebServiceTests.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,5 +57,12 @@ public void TestListWebServices()
5757
{
5858
WebServicesTestController.NewInstance.RunPsTest(this.interceptor, "Test-ListWebServices");
5959
}
60+
61+
[Fact]
62+
[Trait(Category.AcceptanceType, Category.CheckIn)]
63+
public void TestCreateAndGetRegionalProperties()
64+
{
65+
WebServicesTestController.NewInstance.RunPsTest(this.interceptor, "Test-CreateAndGetRegionalProperties");
66+
}
6067
}
6168
}

src/ResourceManager/MachineLearning/Commands.MachineLearning.Test/ScenarioTests/WebServiceTests.ps1

Lines changed: 62 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -221,19 +221,19 @@ function Test-ListWebServices
221221
# Create a few web services in the same resource group
222222
$svcDefinition = LoadWebServiceDefinitionForTest $TEST_WEBSERVICE_DEFINITION_FILE `
223223
$commitmentPlanId $storageAccount
224-
LogOutput "Creating web service: $webServiceName"
224+
LogOutput "Creating web service 1: $webServiceName"
225225
$svc1 = New-AzureRmMlWebService -ResourceGroupName $rgName -Location $location `
226226
-Name $webServiceName -NewWebServiceDefinition $svcDefinition `
227227
-Force
228228
Assert-NotNull $svc1
229-
LogOutput "Created web service: $($svc1.Id)"
229+
LogOutput "Created web service 1: $($svc1.Id)"
230230
ValidateWebServiceResult $rgName $webServiceName $location $svc1
231-
LogOutput "Creating web service: $sameGroupWebServiceName"
231+
LogOutput "Creating web service 2: $sameGroupWebServiceName"
232232
$svc2 = New-AzureRmMlWebService -ResourceGroupName $rgName -Location $location `
233233
-Name $sameGroupWebServiceName -NewWebServiceDefinition $svcDefinition `
234234
-Force
235235
Assert-NotNull $svc2
236-
LogOutput "Created web service: $($svc2.Id)"
236+
LogOutput "Created web service 2: $($svc2.Id)"
237237
ValidateWebServiceResult $rgName $sameGroupWebServiceName $location $svc2
238238

239239
# Create a web service in a different resource group
@@ -291,6 +291,62 @@ function Test-ListWebServices
291291
RunWebServicesTest $actualTest
292292
}
293293

294+
<#
295+
.SYNOPSIS
296+
Tests creating a regional properties and get it
297+
#>
298+
function Test-CreateAndGetRegionalProperties
299+
{
300+
$actualTest = {
301+
param([string] $rgName, [string] $location, [string] $webServiceName, `
302+
[string] $commitmentPlanId, [object] $storageAccount)
303+
304+
$definitionFile = "";
305+
try
306+
{
307+
# Create a valid service definition file
308+
$svcDefinition = LoadWebServiceDefinitionForTest $TEST_WEBSERVICE_DEFINITION_FILE `
309+
$commitmentPlanId $storageAccount
310+
$definitionFile = "$webServiceName.json"
311+
LogOutput "Exporting web service definition to file: $definitionFile"
312+
Export-AzureRmMlWebService -WebService $svcDefinition -OutputFile $definitionFile
313+
LogOutput "Checking that exported service definition exists at $definitionFile"
314+
Assert-True { Test-Path $definitionFile }
315+
316+
# Create a new web service from the local file definition
317+
LogOutput "Creating web service: $webServiceName"
318+
$svc = New-AzureRmMlWebService -ResourceGroupName $rgName -Location $location `
319+
-Name $webServiceName -DefinitionFile $definitionFile `
320+
-Force
321+
LogOutput "Created web service: $webServiceName"
322+
ValidateWebServiceResult $rgName $webServiceName $location $svc
323+
324+
$newRegion = "westcentralus"
325+
326+
# Validate that service no longer exists
327+
Assert-ThrowsContains { Get-AzureRmMlWebService -ResourceGroupName $rgName `
328+
-Name $webServiceName -region $newRegion} "PerRegionPayloadNotFound"
329+
330+
LogOutput "Creating web service regional properties for $webServiceName in $newRegion"
331+
$newSvc = Add-AzureRmMlWebServiceRegionalProperty -ResourceGroupName $rgName -Name $webServiceName -region $newRegion -Force
332+
ValidateWebServiceResult $rgName $webServiceName $location $svc
333+
334+
Assert-AreEqual $newSvc.Properties.Package.Nodes["node1"].parameters["Account Key"].certificateThumbprint "ENCRYPTED_CERTIFICATETHUMBPRINT_2"
335+
}
336+
finally
337+
{
338+
if (Test-Path $definitionFile)
339+
{
340+
Remove-Item $definitionFile
341+
}
342+
343+
Clean-WebService $rgName $webServiceName
344+
}
345+
};
346+
347+
RunWebServicesTest $actualTest
348+
}
349+
294350
<#
295351
.SYNOPSIS
296352
Base function for running web services tests
@@ -312,13 +368,14 @@ function RunWebServicesTest([ScriptBlock] $testScript)
312368
LogOutput "Creating resource group: $rgName"
313369
$group = New-AzureRmResourceGroup -Name $rgName -Location $location
314370
LogOutput("Created resource group: $($group.ResourceId)")
371+
LogOutput("Created resource group: $($group.ResourceGroupName)")
315372

316373
LogOutput "Creating storage account: $storageAccountName"
317374
$storageAccount = Create-TestStorageAccount $rgName $location $storageAccountName
318375
LogOutput("Created storage account: $storageAccountName")
319376

320377
LogOutput "Creating commitment plan resource: $commitmentPlanName"
321-
$cpSku = @{Name = 'PLAN_SKU_NAME'; Tier='PLAN_SKU_TIER'; Capacity=1}
378+
$cpSku = @{Name = 'S1'; Tier='Standard'; Capacity=1}
322379
$cpPlan = New-AzureRmResource -Location $location -ResourceType `
323380
"Microsoft.MachineLearning/CommitmentPlans" -ResourceName $commitmentPlanName `
324381
-ResourceGroupName $rgName -SkuObject $cpSku -Properties @{} `

0 commit comments

Comments
 (0)