Skip to content

Commit

Permalink
Merge branch 'release-2018-04-06' of github.com:/azure/azure-powershe…
Browse files Browse the repository at this point in the history
…ll into netcore-011a
  • Loading branch information
markcowl committed Apr 5, 2018
2 parents bd1c6a1 + 221534c commit 6e761f2
Show file tree
Hide file tree
Showing 133 changed files with 14,105 additions and 6,965 deletions.
2 changes: 1 addition & 1 deletion build.proj
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@

<Message Importance="high" Text="Running Static Analyser" />
<CallTarget targets="DependencyAnalysis" ContinueOnError="ErrorAndContinue" />
<Exec Command="&quot;$(PowerShellCommand)&quot; -NonInteractive -NoLogo -NoProfile -Command &quot;. $(LibraryToolsFolder)\CheckAssemblies.ps1 &quot;" />
<Exec Command="&quot;$(PowerShellCommand)&quot; -NonInteractive -NoLogo -NoProfile -Command &quot;. $(LibraryToolsFolder)\CheckAssemblies.ps1 -BuildConfig $(Configuration) &quot;" />
<Exec Command="&quot;$(PowerShellCommand)&quot; -NonInteractive -NoLogo -NoProfile -Command &quot;. $(LibraryToolsFolder)\CleanupBuild.ps1 -BuildConfig $(Configuration) &quot;" />
</Target>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,9 +128,13 @@ public static class Property
/// <summary>
/// Backup login Uri for MSI
/// </summary>
MSILoginUriBackup = "MSILoginBackup";
MSILoginUriBackup = "MSILoginBackup",


/// <summary>
/// Secret that may be used with MSI login
/// </summary>
MSILoginSecret = "MSILoginSecret";
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
using Microsoft.Rest.Azure;
using System;
using System.Collections.Generic;
using System.Net.Http;
using System.Text;
using System.Threading;

Expand Down Expand Up @@ -72,6 +73,10 @@ public ManagedServiceAccessToken(IAzureAccount account, IAzureEnvironment enviro
}

_tokenGetter = factory.GetHttpOperations<ManagedServiceTokenInfo>(true).WithHeader("Metadata", new[] { "true" });
if (account.IsPropertySet(AzureAccount.Property.MSILoginSecret))
{
_tokenGetter = _tokenGetter.WithHeader("Secret", new[] { account.GetProperty(AzureAccount.Property.MSILoginSecret) });
}
}

public string AccessToken
Expand Down Expand Up @@ -119,11 +124,12 @@ void GetOrRenewAuthentication()
RequestUris.Clear();
RequestUris.Enqueue(currentRequestUri);
}
catch (CloudException) when (RequestUris.Count > 0)
catch (Exception e) when ( (e is CloudException || e is HttpRequestException) && RequestUris.Count > 0)
{
// do nothing
// skip to the next uri
}
}

SetToken(info);
}
}
Expand Down
12 changes: 12 additions & 0 deletions src/Common/Commands.Common/Extensions/CmdletExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,18 @@ public static void SafeCopyParameterSet<T>(this T source, T target) where T : Az
}
}

/// <summary>
/// Return the value of a paramater, or null if not set
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="cmdlet">the executing cmdlet</param>
/// <param name="parameterName">The name of the parameter to return</param>
/// <returns>true if the parameter was provided by the user, otherwise false</returns>
public static bool IsBound(this PSCmdlet cmdlet, string parameterName)
{
return cmdlet.MyInvocation.BoundParameters.ContainsKey(parameterName);
}

public static string AsAbsoluteLocation(this string realtivePath)
{
return Path.GetFullPath(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, realtivePath));
Expand Down
2 changes: 1 addition & 1 deletion src/ResourceManager/Aks/AzureRM.Aks.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ CLRVersion = '4.0'
# ProcessorArchitecture = ''

# Modules that must be imported into the global environment prior to importing this module
RequiredModules = @(@{ModuleName = 'AzureRM.Profile'; ModuleVersion = '4.1.1'; })
RequiredModules = @(@{ModuleName = 'AzureRM.Profile'; ModuleVersion = '4.5.0'; })

# Assemblies that must be loaded prior to importing this module
RequiredAssemblies = '.\YamlDotNet.dll',
Expand Down
6 changes: 6 additions & 0 deletions src/ResourceManager/Aks/NuGet.Config
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<config>
<add key="repositorypath" value="..\..\packages" />
</config>
</configuration>
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,8 @@ FunctionsToExport = @()
# Cmdlets to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no cmdlets to export.
CmdletsToExport = 'Get-AzureRmCognitiveServicesAccount',
'Get-AzureRmCognitiveServicesAccountKey',
'Get-AzureRmCognitiveServicesAccountSkus',
'Get-AzureRmCognitiveServicesAccountSkus',
'Get-AzureRmCognitiveServicesAccountUsage',
'New-AzureRmCognitiveServicesAccount',
'New-AzureRmCognitiveServicesAccountKey',
'Remove-AzureRmCognitiveServicesAccount',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,11 @@ FunctionsToExport = @()
CmdletsToExport = 'Get-AzureRmCognitiveServicesAccount',
'Get-AzureRmCognitiveServicesAccountKey',
'Get-AzureRmCognitiveServicesAccountSkus',
'Get-AzureRmCognitiveServicesAccountUsage',
'New-AzureRmCognitiveServicesAccount',
'New-AzureRmCognitiveServicesAccountKey',
'Remove-AzureRmCognitiveServicesAccount',
'Set-AzureRmCognitiveServicesAccount'
'Set-AzureRmCognitiveServicesAccount'

# Variables to export from this module
# VariablesToExport = @()
Expand Down
2 changes: 2 additions & 0 deletions src/ResourceManager/CognitiveServices/ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
-->
## Current Release
* Updated to the latest version of the Azure ClientRuntime
* Integrate with Cognitive Services Management SDK version 4.0.0.
* Add Get-AzureRmCognitiveServicesAccountUsage operation.

## Version 0.9.3
* Fix issue with Default Resource Group in CloudShell
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@
<Reference Include="Microsoft.Azure.Management.Authorization">
<HintPath>..\..\..\packages\Microsoft.Azure.Management.Authorization.1.0.0\lib\net40\Microsoft.Azure.Management.Authorization.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Azure.Management.CognitiveServices, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\..\..\packages\Microsoft.Azure.Management.CognitiveServices.3.0.0\lib\net452\Microsoft.Azure.Management.CognitiveServices.dll</HintPath>
<Reference Include="Microsoft.Azure.Management.CognitiveServices, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\..\..\packages\Microsoft.Azure.Management.CognitiveServices.4.0.0\lib\net452\Microsoft.Azure.Management.CognitiveServices.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Azure.ResourceManager, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
Expand Down Expand Up @@ -169,6 +169,9 @@
<None Include="SessionRecords\CognitiveServices.Test.ScenarioTests.CognitiveServicesAccountTests\TestGetAccounts.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="SessionRecords\CognitiveServices.Test.ScenarioTests.CognitiveServicesAccountTests\TestGetUsages.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="SessionRecords\CognitiveServices.Test.ScenarioTests.CognitiveServicesAccountTests\TestGetWithPaging.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,5 +125,12 @@ public void TestGetWithPaging()
{
TestController.NewInstance.RunPsTest("Test-GetWithPaging");
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestGetUsages()
{
TestController.NewInstance.RunPsTest("Test-GetUsages");
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ function Test-NewAzureRmCognitiveServicesAccount
$accountname = 'csa' + $rgname;
$skuname = 'S2';
$accounttype = 'TextAnalytics';
$loc = 'West US';
$loc = Get-Location -providerNamespace "Microsoft.CognitiveServices" -resourceType "accounts" -preferredLocation "West US";

New-AzureRmResourceGroup -Name $rgname -Location $loc;

Expand Down Expand Up @@ -57,28 +57,31 @@ function Test-NewAzureRmAllKindsOfCognitiveServicesAccounts
# Setup
$rgname = Get-CognitiveServicesManagementTestResourceName;

$locWU = Get-Location -providerNamespace "Microsoft.CognitiveServices" -resourceType "accounts" -preferredLocation "West US";
$locGBL = Get-Location -providerNamespace "Microsoft.CognitiveServices" -resourceType "accounts" -preferredLocation "Global";

try
{
New-AzureRmResourceGroup -Name $rgname -Location 'West US';

# Create all known kinds of Cognitive Services accounts.
Test-CreateCognitiveServicesAccount $rgname 'AcademicTest' 'Academic' 'S0' 'West US'
Test-CreateCognitiveServicesAccount $rgname 'BingAutosuggestTest' 'Bing.Autosuggest' 'S1' 'Global'
Test-CreateCognitiveServicesAccount $rgname 'BingSearchTest' 'Bing.Search' 'S1' 'Global'
Test-CreateCognitiveServicesAccount $rgname 'BingSpeechTest' 'Bing.Speech' 'S0' 'Global'
Test-CreateCognitiveServicesAccount $rgname 'BingSpellCheckTest' 'Bing.SpellCheck' 'S1' 'Global'
Test-CreateCognitiveServicesAccount $rgname 'ComputerVisionTest' 'ComputerVision' 'S0' 'West US'
Test-CreateCognitiveServicesAccount $rgname 'ContentModeratorTest' 'ContentModerator' 'S0' 'West US'
Test-CreateCognitiveServicesAccount $rgname 'EmotionTest' 'Emotion' 'S0' 'West US'
Test-CreateCognitiveServicesAccount $rgname 'FaceTest' 'Face' 'S0' 'West US'
Test-CreateCognitiveServicesAccount $rgname 'LUISTest' 'LUIS' 'S0' 'West US'
Test-CreateCognitiveServicesAccount $rgname 'RecommendationsTest' 'Recommendations' 'S1' 'West US'
Test-CreateCognitiveServicesAccount $rgname 'SpeakerRecognitionTest' 'SpeakerRecognition' 'S0' 'West US'
Test-CreateCognitiveServicesAccount $rgname 'SpeechTest' 'Speech' 'S0' 'West US'
Test-CreateCognitiveServicesAccount $rgname 'SpeechTranslationTest' 'SpeechTranslation' 'S1' 'Global'
Test-CreateCognitiveServicesAccount $rgname 'TextAnalyticsTest' 'TextAnalytics' 'S1' 'West US'
Test-CreateCognitiveServicesAccount $rgname 'TextTranslationTest' 'TextTranslation' 'S1' 'Global'
Test-CreateCognitiveServicesAccount $rgname 'WebLMTest' 'WebLM' 'S0' 'West US'
Test-CreateCognitiveServicesAccount $rgname 'AcademicTest' 'Academic' 'S0' $locWU
Test-CreateCognitiveServicesAccount $rgname 'BingAutosuggestTest' 'Bing.Autosuggest' 'S1' $locGBL
Test-CreateCognitiveServicesAccount $rgname 'BingSearchTest' 'Bing.Search' 'S1' $locGBL
Test-CreateCognitiveServicesAccount $rgname 'BingSpeechTest' 'Bing.Speech' 'S0' $locGBL
Test-CreateCognitiveServicesAccount $rgname 'BingSpellCheckTest' 'Bing.SpellCheck' 'S1' $locGBL
Test-CreateCognitiveServicesAccount $rgname 'ComputerVisionTest' 'ComputerVision' 'S0' $locWU
Test-CreateCognitiveServicesAccount $rgname 'ContentModeratorTest' 'ContentModerator' 'S0' $locWU
Test-CreateCognitiveServicesAccount $rgname 'EmotionTest' 'Emotion' 'S0' $locWU
Test-CreateCognitiveServicesAccount $rgname 'FaceTest' 'Face' 'S0' $locWU
Test-CreateCognitiveServicesAccount $rgname 'LUISTest' 'LUIS' 'S0' $locWU
Test-CreateCognitiveServicesAccount $rgname 'RecommendationsTest' 'Recommendations' 'S1' $locWU
Test-CreateCognitiveServicesAccount $rgname 'SpeakerRecognitionTest' 'SpeakerRecognition' 'S0' $locWU
Test-CreateCognitiveServicesAccount $rgname 'SpeechTest' 'Speech' 'S0' $locWU
Test-CreateCognitiveServicesAccount $rgname 'SpeechTranslationTest' 'SpeechTranslation' 'S1' $locGBL
Test-CreateCognitiveServicesAccount $rgname 'TextAnalyticsTest' 'TextAnalytics' 'S1' $locWU
Test-CreateCognitiveServicesAccount $rgname 'TextTranslationTest' 'TextTranslation' 'S1' $locGBL
Test-CreateCognitiveServicesAccount $rgname 'WebLMTest' 'WebLM' 'S0' $locWU
}
finally
{
Expand All @@ -102,7 +105,7 @@ function Test-RemoveAzureRmCognitiveServicesAccount
$accountname = 'csa' + $rgname;
$skuname = 'S1';
$accounttype = 'TextAnalytics';
$loc = 'West US';
$loc = Get-Location -providerNamespace "Microsoft.CognitiveServices" -resourceType "accounts" -preferredLocation "West US";

New-AzureRmResourceGroup -Name $rgname -Location $loc;

Expand Down Expand Up @@ -134,7 +137,7 @@ function Test-GetAzureCognitiveServiceAccount
$accountname = 'csa' + $rgname;
$skuname = 'S2';
$accounttype = 'TextAnalytics';
$loc = 'West US';
$loc = Get-Location -providerNamespace "Microsoft.CognitiveServices" -resourceType "accounts" -preferredLocation "West US";

New-AzureRmResourceGroup -Name $rgname -Location $loc;

Expand Down Expand Up @@ -183,7 +186,7 @@ function Test-SetAzureRmCognitiveServicesAccount
$accountname = 'csa' + $rgname;
$skuname = 'S2';
$accounttype = 'TextAnalytics';
$loc = 'West US';
$loc = Get-Location -providerNamespace "Microsoft.CognitiveServices" -resourceType "accounts" -preferredLocation "West US";

New-AzureRmResourceGroup -Name $rgname -Location $loc;
New-AzureRmCognitiveServicesAccount -ResourceGroupName $rgname -Name $accountname -Type $accounttype -SkuName $skuname -Location $loc -Force;
Expand Down Expand Up @@ -229,7 +232,7 @@ function Test-GetAzureRmCognitiveServicesAccountKey
$accountname = 'csa' + $rgname;
$skuname = 'S2';
$accounttype = 'TextAnalytics';
$loc = 'West US';
$loc = Get-Location -providerNamespace "Microsoft.CognitiveServices" -resourceType "accounts" -preferredLocation "West US";

New-AzureRmResourceGroup -Name $rgname -Location $loc;
New-AzureRmCognitiveServicesAccount -ResourceGroupName $rgname -Name $accountname -Type $accounttype -SkuName $skuname -Location $loc -Force;
Expand Down Expand Up @@ -262,7 +265,7 @@ function Test-NewAzureRmCognitiveServicesAccountKey
$accountname = 'csa' + $rgname;
$skuname = 'S2';
$accounttype = 'TextAnalytics';
$loc = 'West US';
$loc = Get-Location -providerNamespace "Microsoft.CognitiveServices" -resourceType "accounts" -preferredLocation "West US";

New-AzureRmResourceGroup -Name $rgname -Location $loc;
New-AzureRmCognitiveServicesAccount -ResourceGroupName $rgname -Name $accountname -Type $accounttype -SkuName $skuname -Location $loc -Force;
Expand Down Expand Up @@ -305,7 +308,7 @@ function Test-GetAzureRmCognitiveServicesAccountSkus
$accountname = 'csa' + $rgname;
$skuname = 'S2';
$accounttype = 'TextAnalytics';
$loc = 'West US';
$loc = Get-Location -providerNamespace "Microsoft.CognitiveServices" -resourceType "accounts" -preferredLocation "West US";

New-AzureRmResourceGroup -Name $rgname -Location $loc;
New-AzureRmCognitiveServicesAccount -ResourceGroupName $rgname -Name $accountname -Type $accounttype -SkuName $skuname -Location $loc -Force;
Expand Down Expand Up @@ -340,7 +343,7 @@ function Test-PipingGetAccountToGetKey
$accountname = 'csa' + $rgname;
$skuname = 'S2';
$accounttype = 'TextAnalytics';
$loc = 'West US';
$loc = Get-Location -providerNamespace "Microsoft.CognitiveServices" -resourceType "accounts" -preferredLocation "West US";

New-AzureRmResourceGroup -Name $rgname -Location $loc;
New-AzureRmCognitiveServicesAccount -ResourceGroupName $rgname -Name $accountname -Type $accounttype -SkuName $skuname -Location $loc -Force;
Expand Down Expand Up @@ -372,7 +375,7 @@ function Test-PipingToSetAzureAccount
$accountname = 'csa' + $rgname;
$skuname = 'S2';
$accounttype = 'TextAnalytics';
$loc = 'West US';
$loc = Get-Location -providerNamespace "Microsoft.CognitiveServices" -resourceType "accounts" -preferredLocation "West US";

New-AzureRmResourceGroup -Name $rgname -Location $loc;
New-AzureRmCognitiveServicesAccount -ResourceGroupName $rgname -Name $accountname -Type $accounttype -SkuName $skuname -Location $loc -Force;
Expand Down Expand Up @@ -407,7 +410,7 @@ function Test-PipingToGetAccountSkus
$accountname = 'csa' + $rgname;
$skuname = 'S2';
$accounttype = 'TextAnalytics';
$loc = 'West US';
$loc = Get-Location -providerNamespace "Microsoft.CognitiveServices" -resourceType "accounts" -preferredLocation "West US";

New-AzureRmResourceGroup -Name $rgname -Location $loc;
New-AzureRmCognitiveServicesAccount -ResourceGroupName $rgname -Name $accountname -Type $accounttype -SkuName $skuname -Location $loc -Force;
Expand Down Expand Up @@ -444,7 +447,7 @@ function Test-MinMaxAccountName
$longname = 'testtesttesttesttesttesttesttesttesttesttesttesttesttesttesttest';
$skuname = 'S2';
$accounttype = 'TextAnalytics';
$loc = 'West US';
$loc = Get-Location -providerNamespace "Microsoft.CognitiveServices" -resourceType "accounts" -preferredLocation "West US";

New-AzureRmResourceGroup -Name $rgname -Location $loc;
$shortaccount = New-AzureRmCognitiveServicesAccount -ResourceGroupName $rgname -Name $shortname -Type $accounttype -SkuName $skuname -Location $loc -Force;
Expand All @@ -470,7 +473,7 @@ function Test-GetWithPaging
{
# Setup
$rgname = Get-CognitiveServicesManagementTestResourceName
$loc = 'West US'
$loc = Get-Location -providerNamespace "Microsoft.CognitiveServices" -resourceType "accounts" -preferredLocation "West US"

try
{
Expand Down Expand Up @@ -502,3 +505,47 @@ function Test-GetWithPaging
Clean-ResourceGroup $rgname
}
}

<#
.SYNOPSIS
Test Test-GetUsages
#>
function Test-GetUsages
{
# Setup
$rgname = Get-CognitiveServicesManagementTestResourceName;

try
{
# Test
$accountname = 'csa' + $rgname;
$skuname = 'S1';
$accounttype = 'TextAnalytics';
$loc = Get-Location -providerNamespace "Microsoft.CognitiveServices" -resourceType "accounts" -preferredLocation "West US"

New-AzureRmResourceGroup -Name $rgname -Location $loc;

$createdAccount = New-AzureRmCognitiveServicesAccount -ResourceGroupName $rgname -Name $accountname -Type $accounttype -SkuName $skuname -Location $loc -Force;
$usages1 = Get-AzureRmCognitiveServicesAccountUsage -ResourceGroupName $rgname -Name $accountname
$usages2 = Get-AzureRmCognitiveServicesAccountUsage -InputObject $createdAccount
$usages3 = Get-AzureRmCognitiveServicesAccountUsage -ResourceId $createdAccount.Id

Assert-True {$usages1.Count -gt 0}
Assert-AreEqual 0.0 $usages1[0].CurrentValue
Assert-True {$usages1[0].Limit -gt 0}

Assert-AreEqual $usages1.Count $usages2.Count
Assert-AreEqual $usages2.Count $usages3.Count

Assert-AreEqual $usages1[0].CurrentValue $usages2[0].CurrentValue
Assert-AreEqual $usages2[0].CurrentValue $usages3[0].CurrentValue

Assert-AreEqual $usages1[0].Limit $usages2[0].Limit
Assert-AreEqual $usages2[0].Limit $usages3[0].Limit
}
finally
{
# Cleanup
Clean-ResourceGroup $rgname
}
}
Loading

0 comments on commit 6e761f2

Please sign in to comment.