Skip to content

Azure Machine Learning WebServicesRP new API version (Re-submit) #3860

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 9 commits into from
May 2, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ CmdletsToExport = 'Move-AzureRmMlCommitmentAssociation',
'Get-AzureRmMlWebService', 'Update-AzureRmMlWebService',
'Export-AzureRmMlWebService', 'Get-AzureRmMlWebServiceKeys',
'Import-AzureRmMlWebService', 'New-AzureRmMlCommitmentPlan',
'New-AzureRmMlWebService'
'New-AzureRmMlWebService', 'Add-AzureRmMlWebServiceRegionalProperty'

# Variables to export from this module
# VariablesToExport = @()
Expand Down
3 changes: 3 additions & 0 deletions src/ResourceManager/MachineLearning/ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@
- Additional information about change #1
-->
## Current Release
* Consume new version of Azure Machine Learning .Net SDK and add a new cmdlet
- Add-AzureRmMlWebServiceRegionalProperty
* Minor wording fixes in help text.

## Version 0.13.0

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
<HintPath>..\..\..\packages\Microsoft.Azure.Management.Authorization.2.0.0\lib\net40\Microsoft.Azure.Management.Authorization.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="..\..\..\packages\Microsoft.Azure.Management.MachineLearning.0.9.6-preview\lib\net45\Microsoft.Azure.Management.MachineLearning.dll">
<Reference Include="..\..\..\packages\Microsoft.Azure.Management.MachineLearning.1.0.0\lib\net45\Microsoft.Azure.Management.MachineLearning.dll">
<Name>Microsoft.Azure.Management.MachineLearning</Name>
<Private>True</Private>
</Reference>
Expand Down Expand Up @@ -180,6 +180,9 @@
<None Include="SessionRecords\Microsoft.Azure.Commands.MachineLearning.Test.ScenarioTests.WebServiceTests\TestUpdateWebService.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="SessionRecords\Microsoft.Azure.Commands.MachineLearning.Test.ScenarioTests.WebServiceTests\TestCreateAndGetRegionalProperties.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="SessionRecords\Microsoft.Azure.Commands.MachineLearning.Test.ScenarioTests.CommitmentPlanTests\TestCreateGetRemoveCommitmentPlan.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,31 +78,22 @@ Gets the latest API Version for the resource type
#>
function Get-ProviderAPIVersion($providerNamespace, $resourceType)
{
if ([Microsoft.Azure.Test.HttpRecorder.HttpMockServer]::Mode -ne `
[Microsoft.Azure.Test.HttpRecorder.HttpRecorderMode]::Playback)
{
$provider = Get-AzureRmResourceProvider -ProviderNamespace $providerNamespace
$resourceType = $provider.ResourceTypes | where {$_.ResourceTypeName -eq $resourceType}
return $resourceType.ApiVersions[$resourceType.ApiVersions.Count -1]
} else
if ($providerNamespace -eq "Microsoft.MachineLearning")
{
if ($providerNamespace -eq "Microsoft.MachineLearning")
if ([System.String]::Equals($resourceType, "commitmentPlans", `
[System.StringComparison]::OrdinalIgnoreCase))
{
if ([System.String]::Equals($resourceType, "commitmentPlans", `
[System.StringComparison]::OrdinalIgnoreCase))
{
return "2016-05-01-preview"
}

if ([System.String]::Equals($resourceType, "webServices", `
[System.StringComparison]::OrdinalIgnoreCase))
{
return "2016-05-01-preview"
}
return "2016-05-01-preview"
}

return $null
if ([System.String]::Equals($resourceType, "webServices", `
[System.StringComparison]::OrdinalIgnoreCase))
{
return "2017-01-01"
}
}

return $null
}

<#
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,5 +57,12 @@ public void TestListWebServices()
{
WebServicesTestController.NewInstance.RunPsTest(this.interceptor, "Test-ListWebServices");
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestCreateAndGetRegionalProperties()
{
WebServicesTestController.NewInstance.RunPsTest(this.interceptor, "Test-CreateAndGetRegionalProperties");
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -221,19 +221,19 @@ function Test-ListWebServices
# Create a few web services in the same resource group
$svcDefinition = LoadWebServiceDefinitionForTest $TEST_WEBSERVICE_DEFINITION_FILE `
$commitmentPlanId $storageAccount
LogOutput "Creating web service: $webServiceName"
LogOutput "Creating web service 1: $webServiceName"
$svc1 = New-AzureRmMlWebService -ResourceGroupName $rgName -Location $location `
-Name $webServiceName -NewWebServiceDefinition $svcDefinition `
-Force
Assert-NotNull $svc1
LogOutput "Created web service: $($svc1.Id)"
LogOutput "Created web service 1: $($svc1.Id)"
ValidateWebServiceResult $rgName $webServiceName $location $svc1
LogOutput "Creating web service: $sameGroupWebServiceName"
LogOutput "Creating web service 2: $sameGroupWebServiceName"
$svc2 = New-AzureRmMlWebService -ResourceGroupName $rgName -Location $location `
-Name $sameGroupWebServiceName -NewWebServiceDefinition $svcDefinition `
-Force
Assert-NotNull $svc2
LogOutput "Created web service: $($svc2.Id)"
LogOutput "Created web service 2: $($svc2.Id)"
ValidateWebServiceResult $rgName $sameGroupWebServiceName $location $svc2

# Create a web service in a different resource group
Expand Down Expand Up @@ -291,6 +291,62 @@ function Test-ListWebServices
RunWebServicesTest $actualTest
}

<#
.SYNOPSIS
Tests creating a regional properties and get it
#>
function Test-CreateAndGetRegionalProperties
{
$actualTest = {
param([string] $rgName, [string] $location, [string] $webServiceName, `
[string] $commitmentPlanId, [object] $storageAccount)

$definitionFile = "";
try
{
# Create a valid service definition file
$svcDefinition = LoadWebServiceDefinitionForTest $TEST_WEBSERVICE_DEFINITION_FILE `
$commitmentPlanId $storageAccount
$definitionFile = "$webServiceName.json"
LogOutput "Exporting web service definition to file: $definitionFile"
Export-AzureRmMlWebService -WebService $svcDefinition -OutputFile $definitionFile
LogOutput "Checking that exported service definition exists at $definitionFile"
Assert-True { Test-Path $definitionFile }

# Create a new web service from the local file definition
LogOutput "Creating web service: $webServiceName"
$svc = New-AzureRmMlWebService -ResourceGroupName $rgName -Location $location `
-Name $webServiceName -DefinitionFile $definitionFile `
-Force
LogOutput "Created web service: $webServiceName"
ValidateWebServiceResult $rgName $webServiceName $location $svc

$newRegion = "westcentralus"

# Validate that service no longer exists
Assert-ThrowsContains { Get-AzureRmMlWebService -ResourceGroupName $rgName `
-Name $webServiceName -region $newRegion} "PerRegionPayloadNotFound"

LogOutput "Creating web service regional properties for $webServiceName in $newRegion"
$newSvc = Add-AzureRmMlWebServiceRegionalProperty -ResourceGroupName $rgName -Name $webServiceName -region $newRegion -Force
ValidateWebServiceResult $rgName $webServiceName $location $svc

Assert-AreEqual $newSvc.Properties.Package.Nodes["node1"].parameters["Account Key"].certificateThumbprint "ENCRYPTED_CERTIFICATETHUMBPRINT_2"
}
finally
{
if (Test-Path $definitionFile)
{
Remove-Item $definitionFile
}

Clean-WebService $rgName $webServiceName
}
};

RunWebServicesTest $actualTest
}

<#
.SYNOPSIS
Base function for running web services tests
Expand All @@ -312,13 +368,14 @@ function RunWebServicesTest([ScriptBlock] $testScript)
LogOutput "Creating resource group: $rgName"
$group = New-AzureRmResourceGroup -Name $rgName -Location $location
LogOutput("Created resource group: $($group.ResourceId)")
LogOutput("Created resource group: $($group.ResourceGroupName)")

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

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