Skip to content

Commit

Permalink
Merge pull request #3 from Azure/master
Browse files Browse the repository at this point in the history
Sync with Master
  • Loading branch information
bashahee authored Jun 11, 2019
2 parents 96fc69e + 520232f commit ee8ac49
Show file tree
Hide file tree
Showing 524 changed files with 331,398 additions and 290,324 deletions.
4 changes: 2 additions & 2 deletions .azure-pipelines/util/analyze-steps.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@ steps:
inputs:
command: custom
custom: msbuild
arguments: 'build.proj /t:GenerateHelp /p:Configuration=${{ parameters.configuration }}'
arguments: 'build.proj /t:GenerateHelp /p:Configuration=${{ parameters.configuration }};PullRequestNumber=$(System.PullRequest.PullRequestNumber)'

- task: DotNetCoreCLI@2
displayName: 'Static Analysis'
inputs:
command: custom
custom: msbuild
arguments: 'build.proj /t:StaticAnalysis /p:Configuration=${{ parameters.configuration }}'
arguments: 'build.proj /t:StaticAnalysis /p:Configuration=${{ parameters.configuration }};PullRequestNumber=$(System.PullRequest.PullRequestNumber)'

- template: publish-artifacts-steps.yml
parameters:
Expand Down
2 changes: 1 addition & 1 deletion .azure-pipelines/util/build-steps.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ steps:
inputs:
command: custom
custom: msbuild
arguments: 'build.proj /t:Build /p:Configuration=${{ parameters.configuration }};TestFramework=${{ parameters.testFramework }}'
arguments: 'build.proj /t:Build /p:Configuration=${{ parameters.configuration }};TestFramework=${{ parameters.testFramework }};PullRequestNumber=$(System.PullRequest.PullRequestNumber)'

- template: publish-artifacts-steps.yml
parameters:
Expand Down
2 changes: 1 addition & 1 deletion .azure-pipelines/util/test-steps.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ steps:
inputs:
command: custom
custom: msbuild
arguments: 'build.proj /t:${{ parameters.testTarget }} /p:Configuration=${{ parameters.configuration }};TestFramework=${{ parameters.testFramework }}'
arguments: 'build.proj /t:${{ parameters.testTarget }} /p:Configuration=${{ parameters.configuration }};TestFramework=${{ parameters.testFramework }};PullRequestNumber=$(System.PullRequest.PullRequestNumber)'

- template: publish-artifacts-steps.yml
parameters:
Expand Down
3 changes: 1 addition & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -222,9 +222,8 @@ Package
launchSettings.json
/src/StackAdmin/AzureRM/AzureRM.psm1
/src/StackAdmin/AzureStack/AzureStack.psm1
/CsprojMappings.json
/ModuleMappings.json
/SolutionMappings.json
/TestMappings.json
/tools/Modules/tmp
/tools/Az/Az.psm1
/Azure.PowerShell.sln
56 changes: 29 additions & 27 deletions build.proj
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,8 @@
<UsingTask Condition="$(OnPremiseBuild)" TaskName="CorporateValidation" AssemblyFile="$(CIToolsPath)/Microsoft.WindowsAzure.Tools.Build.Tasks.OnPremise.dll" />
<Import Condition="$(OnPremiseBuild)" Project="$(CIToolsPath)/Microsoft.WindowsAzure.Build.OnPremise.msbuild" />
<UsingTask TaskName="ESRPSignTask" AssemblyFile="$(CISignRepoPath)/tools/sdkbuildtools/tasks/MS.Az.Sdk.OnPremise.Build.Tasks.dll" />
<UsingTask TaskName="FilesChangedTask" AssemblyFile="$(RepoArtifacts)Microsoft.Azure.Build.Tasks/Microsoft.Azure.Build.Tasks.dll" />
<UsingTask TaskName="FilterTask" AssemblyFile="$(RepoArtifacts)Microsoft.Azure.Build.Tasks/Microsoft.Azure.Build.Tasks.dll" />

<Target Name="Clean">
<Message Importance="high" Text="Cleaning Cmdlets..." />
Expand All @@ -93,9 +95,13 @@
<Exec Command="$(PowerShellCoreCommandPrefix) &quot;Get-ChildItem -Path $(MSBuildThisFileDirectory) -Recurse -Include 'bin','obj','TestResults' | Remove-Item -Recurse -Force -ErrorAction Ignore&quot;" IgnoreExitCode="true" />
</Target>

<Target Name="FilterBuild">
<Target Name="FilterBuild" Condition="$(PullRequestNumber) != ''">
<Message Importance="high" Text="Filtering projects and modules..." />
<Exec Command="$(PowerShellCoreCommandPrefix) &quot;. $(RepoTools)/CreateFilterMappings.ps1&quot;" />

<!-- Build the Microsoft.Azure.Build.Tasks project -->
<Exec Command="dotnet publish $(RepoTools)BuildPackagesTask/Microsoft.Azure.Build.Tasks/Microsoft.Azure.Build.Tasks.csproj -c $(Configuration) -f netstandard2.0" />

<!-- Get all of the files changed in the given pull request -->
<FilesChangedTask RepositoryOwner="Azure" RepositoryName="azure-powershell" PullRequestNumber="$(PullRequestNumber)">
<Output TaskParameter="FilesChanged" ItemName="FilesChanged" />
Expand All @@ -105,33 +111,23 @@
<FilterTask FilesChanged="@(FilesChanged)" MapFilePath="./ModuleMappings.json">
<Output TaskParameter="Output" ItemName="ModulesChanged" />
</FilterTask>
<Message Text="Filtering help generation and StaticAnalysis by the following modules:" />
<Message Text="%(ModulesChanged.Identity)" />
<Message Text="Total: @(ModulesChanged->Count())" />
<Message Text="" />

<!-- Get the list of solutions to build -->
<FilterTask FilesChanged="@(FilesChanged)" MapFilePath="./SolutionMappings.json">
<Output TaskParameter="Output" ItemName="CmdletSolutionsToBuild" />
</FilterTask>
<Message Text="Filtering solutions to build by the following:" />
<Message Text="%(CmdletSolutionsToBuild.Identity)" />
<Message Text="Total: @(CmdletSolutionsToBuild->Count())" />
<Message Text="" />

<!--Get the list of tests to be run based on files changed from a specified PullRequestNumber. Mapping between paths and test DLLs is used to produce the list.-->
<FilterTask FilesChanged="@(FilesChanged)" MapFilePath="./TestMappings.json">
<Output TaskParameter="Output" ItemName="XUnitTests" />
<Message Importance="high" Text="Filtering help generation and StaticAnalysis by the following modules:" />
<Message Importance="high" Text="%(ModulesChanged.Identity)" />
<Message Importance="high" Text="Total: @(ModulesChanged->Count())" />
<Message Importance="high" Text="" />

<!-- Get the list of projects to build -->
<FilterTask FilesChanged="@(FilesChanged)" MapFilePath="./CsprojMappings.json">
<Output TaskParameter="Output" ItemName="ProjectsToBuild" />
</FilterTask>
<Message Text="Using these test assemblies:" />
<Message Text="%(XUnitTests.Identity)" />
<Message Text="Total: @(XunitTests->Count())" />
<Message Text="" />
<Message Importance="high" Text="Filtering projects to build by the following:" />
<Message Importance="high" Text="%(ProjectsToBuild.Identity)" />
<Message Importance="high" Text="Total: @(ProjectsToBuild->Count())" />
<Message Importance="high" Text="" />
</Target>

<!-- Build all flavors of the Cmdlets -->
<!-- TODO: Reimplement the FilterBuild and update RepoTasks to NetStandard -->
<Target Name="Build">
<Target Name="Build" DependsOnTargets="FilterBuild">
<Message Importance="high" Text="Building Cmdlets..." />

<MakeDir Directories="$(RepoArtifacts)" />
Expand All @@ -142,13 +138,19 @@
<!-- Build and create package content -->
<Exec Command="dotnet --version" />
<Exec Command="dotnet new sln -n Azure.PowerShell -o $(RepoArtifacts) --force" />
<ItemGroup>
<ItemGroup Condition="$(PullRequestNumber) == ''">
<CsprojFiles Include="$(RepoRoot)src/**/*.csproj" Exclude="$(RepoRoot)src/**/*.Test.csproj;$(RepoRoot)src/**/Authenticators.csproj" />
<CsprojFiles Include="$(RepoRoot)src/**/*.Test.csproj" Exclude="$(Net472TestExclude)" Condition="'$(Configuration)' != 'Release' and '$(TestsToRun)' == 'All'" />
<CsprojFiles Include="$(RepoRoot)src/**/*.Test.csproj" Exclude="$(CoreTests)$(Net472TestExclude)" Condition="'$(Configuration)' != 'Release' and '$(TestsToRun)' == 'NonCore'" />
<CsprojFiles Include="$(CoreTests)" Exclude="$(Net472TestExclude)" Condition="'$(Configuration)' != 'Release' and '$(TestsToRun)' == 'Core'" />
<CsprojFiles Include="$(RepoRoot)src/**/Authenticators.csproj" Condition="'$([MSBuild]::IsOsPlatform(&quot;Windows&quot;))' == 'true' and '$(TestFramework)' != 'net472'" />
</ItemGroup>
<ItemGroup Condition="$(PullRequestNumber) != ''">
<!-- Always build and test common code -->
<CsprojFiles Include="$(LibraryRoot)src/Accounts/**/*.csproj;$(LibraryRoot)tools/TestFx/TestFx.csproj" Exclude="$(LibraryRoot)src/**/Authenticators.csproj" />
<CsprojFiles Include="%(ProjectsToBuild.Identity)" />
<CsprojFiles Include="$(LibraryRoot)src/**/Authenticators.csproj" Condition="'$([MSBuild]::IsOsPlatform(&quot;Windows&quot;))' == 'true'" />
</ItemGroup>
<!-- https://github.com/dotnet/cli/issues/6295#issuecomment-346973582 -->
<Exec Command="dotnet sln $(RepoArtifacts)Azure.PowerShell.sln add &quot;%(CsprojFiles.FullPath)&quot;" />
<PropertyGroup>
Expand Down Expand Up @@ -297,7 +299,7 @@ $(RepoArtifacts)/$(Configuration)/**/Microsoft.Azure.PowerShell.Authenticators.d
<!-- RemoveCodeSignArtifacts.ps1 -->
<Message Text="variables.Remove artifacts section" Importance="high" />
<Exec Command="$(PowerShellCoreCommandPrefix) &quot;Get-ChildItem -Path $(RepoArtifacts) -Recurse -Include 'Signed','Unsigned' | Remove-Item -Recurse -Force -Confirm:$false -ErrorAction Ignore&quot;" IgnoreExitCode="true" />

<!-- CheckSignature.ps1 -->
<Message Text="variables.CheckSignature section" Importance="high" />
<Exec Command="$(PowerShellCoreCommandPrefix) &quot;. $(RepoTools)/CheckSignature.ps1 -CustomPath $(RepoArtifacts)/$(Configuration)&quot;" Condition="'$(Scope)' != 'Stack'" />
Expand Down Expand Up @@ -326,4 +328,4 @@ $(RepoArtifacts)/$(Configuration)/**/Microsoft.Azure.PowerShell.Authenticators.d
<SetEnvVar EnvName="SignedMsiDir" EnvValue="$(SignedOutputRootDir)" />
</Target>

</Project>
</Project>
5 changes: 2 additions & 3 deletions src/Accounts/Accounts/AzureRmAlias/Mappings.json
Original file line number Diff line number Diff line change
Expand Up @@ -478,7 +478,7 @@
"Remove-AzVMSecret": "Remove-AzureRmVMSecret",
"Remove-AzVMNetworkInterface": "Remove-AzureRmVMNetworkInterface",
"Remove-AzVMDataDisk": "Remove-AzureRmVMDataDisk",
"Set-AzVMBootDiagnostics": "Set-AzureRmVMBootDiagnostics",
"Set-AzVMBootDiagnostic": "Set-AzureRmVMBootDiagnostics",
"Set-AzVMDataDisk": "Set-AzureRmVMDataDisk",
"Set-AzVMPlan": "Set-AzureRmVMPlan",
"Set-AzVMSourceImage": "Set-AzureRmVMSourceImage",
Expand Down Expand Up @@ -594,7 +594,7 @@
"Get-AzVmssDiskEncryption": "Get-AzureRmVmssDiskEncryption",
"Get-AzVmssVMDiskEncryption": "Get-AzureRmVmssVMDiskEncryption",
"Export-AzLogAnalyticRequestRateByInterval": "Export-AzureRmLogAnalyticRequestRateByInterval",
"Export-AzLogAnalyticThrottledRequests": "Export-AzureRmLogAnalyticThrottledRequests",
"Export-AzLogAnalyticThrottledRequest": "Export-AzureRmLogAnalyticThrottledRequests",
"Repair-AzVmssServiceFabricUpdateDomain": "Repair-AzureRmVmssServiceFabricUpdateDomain",
"New-AzVMDataDisk": "New-AzureRmVMDataDisk",
"Update-AzVmssVM": "Update-AzureRmVmssVM",
Expand Down Expand Up @@ -1633,7 +1633,6 @@
"New-AzFirewallNetworkRuleCollection": "New-AzureRmFirewallNetworkRuleCollection",
"New-AzFirewallNetworkRule": "New-AzureRmFirewallNetworkRule",
"Get-AzFirewallFqdnTag": "Get-AzureRmFirewallFqdnTag",
"Get-AzInterfaceEndpoint": "Get-AzureRmInterfaceEndpoint",
"Add-AzNetworkInterfaceTapConfig": "Add-AzureRmNetworkInterfaceTapConfig",
"Get-AzNetworkInterfaceTapConfig": "Get-AzureRmNetworkInterfaceTapConfig",
"Set-AzNetworkInterfaceTapConfig": "Set-AzureRmNetworkInterfaceTapConfig",
Expand Down
5 changes: 5 additions & 0 deletions src/Accounts/Accounts/ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@
- Additional information about change #1
-->
## Upcoming Release
* Fix bug with incorrect URL being used in some cases for Functions calls
- More information here: https://github.com/Azure/azure-powershell/issues/8983
* Fix Issue with aliases from AzureRM to Az cmdlets
- Set-AzureRmVMBootDiagnostics -> Set-AzVMBootDiagnostic
- Export-AzureRMLogAnalyticThrottledRequests -> Export-AzLogAnalyticThrottledRequest

## Version 1.5.2
* Update Authentication Library to fix ADFS issues with username/password auth
Expand Down
95 changes: 95 additions & 0 deletions src/Accounts/Authentication.Test/AuthenticationFactoryTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -399,5 +399,100 @@ public void AppServiceManagedIdentity()
Assert.Equal(expectedAccessToken, accessToken);
Assert.Equal(expectedExpiresOn, msat.ExpiresOn);
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void AppServiceManagedIdentityWithDataPlane()
{
AzureSessionInitializer.InitializeAzureSession();
var tenant = Guid.NewGuid().ToString();
var userId = Guid.NewGuid().ToString();
var environment = AzureEnvironment.PublicEnvironments["AzureCloud"];
var account = new AzureAccount
{
Id = userId,
Type = AzureAccount.AccountType.ManagedService
};
const string resource = @"https://vault.azure.com/";
const string endpoint = @"http://127.0.0.1:41217/MSI/token/";
var expectedUri = $"{endpoint}?resource={resource}&api-version=2017-09-01";
account.SetProperty(AzureAccount.Property.MSILoginUri, endpoint);
account.SetProperty(AzureAccount.Property.MSILoginSecret, @"bar");
const string expectedAccessToken = "foo";
var expectedExpiresOn = DateTimeOffset.Parse("1/23/2019 7:15:42 AM +00:00");
var responses = new Dictionary<string, ManagedServiceAppServiceTokenInfo>(StringComparer.OrdinalIgnoreCase)
{
{
expectedUri,
new ManagedServiceAppServiceTokenInfo()
{
AccessToken = expectedAccessToken,
ExpiresOn = expectedExpiresOn,
Resource = resource,
TokenType = "Bearer",
}
}
};
AzureSession.Instance.RegisterComponent(HttpClientOperationsFactory.Name, () => TestHttpOperationsFactory.Create(responses, _output), true);
var msat = new ManagedServiceAppServiceAccessToken(account, environment, environment.GetEndpoint(resource) ?? resource, tenant);
Assert.Equal(expectedUri, msat.RequestUris.Peek());
var accessToken = msat.AccessToken;
Assert.Equal(expectedAccessToken, accessToken);
Assert.Equal(expectedExpiresOn, msat.ExpiresOn);
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void AppServiceManagedIdentityWithServiceManagement()
{
AzureSessionInitializer.InitializeAzureSession();
var tenant = Guid.NewGuid().ToString();
var userId = Guid.NewGuid().ToString();
var environment = AzureEnvironment.PublicEnvironments["AzureCloud"];
var account = new AzureAccount
{
Id = userId,
Type = AzureAccount.AccountType.ManagedService
};
const string resource = @"https://management.azure.com/";
const string serviceManagementResource = @"https://management.core.windows.net/";
const string endpoint = @"http://127.0.0.1:41217/MSI/token/";
var expectedUri = $"{endpoint}?resource={resource}&api-version=2017-09-01";
account.SetProperty(AzureAccount.Property.MSILoginUri, endpoint);
account.SetProperty(AzureAccount.Property.MSILoginSecret, @"bar");
const string expectedAccessToken = "foo";
var expectedExpiresOn = DateTimeOffset.Parse("1/23/2019 7:15:42 AM +00:00");
var responses = new Dictionary<string, ManagedServiceAppServiceTokenInfo>(StringComparer.OrdinalIgnoreCase)
{
{
expectedUri,
new ManagedServiceAppServiceTokenInfo()
{
AccessToken = expectedAccessToken,
ExpiresOn = expectedExpiresOn,
Resource = resource,
TokenType = "Bearer",
}
}
};
AzureSession.Instance.RegisterComponent(HttpClientOperationsFactory.Name, () => TestHttpOperationsFactory.Create(responses, _output), true);
var msat = new ManagedServiceAppServiceAccessToken(account, environment, GetFunctionsResourceId(serviceManagementResource, environment), tenant);
Assert.Equal(expectedUri, msat.RequestUris.Peek());
var accessToken = msat.AccessToken;
Assert.Equal(expectedAccessToken, accessToken);
Assert.Equal(expectedExpiresOn, msat.ExpiresOn);
}
private string GetFunctionsResourceId(string resourceIdOrEndpointName, IAzureEnvironment environment)
{
var resourceId = environment.GetEndpoint(resourceIdOrEndpointName) ?? resourceIdOrEndpointName;
if (string.Equals(
environment.GetEndpoint(AzureEnvironment.Endpoint.ActiveDirectoryServiceEndpointResourceId),
resourceId, StringComparison.OrdinalIgnoreCase))
{
resourceId = environment.GetEndpoint(AzureEnvironment.Endpoint.ResourceManager);
}

return resourceId;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@ public ManagedServiceAppServiceAccessToken(IAzureAccount account, IAzureEnvironm
{
}

public ManagedServiceAppServiceAccessToken(IAzureAccount account, IAzureEnvironment environment, string resourceId, string tenant = "Common")
: base(account, environment, resourceId, tenant)
{
}

protected override IEnumerable<string> BuildTokenUri(string baseUri, IAzureAccount account, IdentityType identityType,
string resourceId)
{
Expand Down
15 changes: 14 additions & 1 deletion src/Accounts/Authentication/Factories/AuthenticationFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -427,7 +427,7 @@ private IAccessToken GetManagedServiceToken(IAzureAccount account, IAzureEnviron

if (account.IsPropertySet(AuthenticationFactory.AppServiceManagedIdentityFlag))
{
return new ManagedServiceAppServiceAccessToken(account, environment, tenant);
return new ManagedServiceAppServiceAccessToken(account, environment, GetFunctionsResourceId(resourceId, environment), tenant);
}

return new ManagedServiceAccessToken(account, environment, GetResourceId(resourceId, environment), tenant);
Expand All @@ -438,6 +438,19 @@ private string GetResourceId(string resourceIdorEndpointName, IAzureEnvironment
return environment.GetEndpoint(resourceIdorEndpointName) ?? resourceIdorEndpointName;
}

private string GetFunctionsResourceId(string resourceIdOrEndpointName, IAzureEnvironment environment)
{
var resourceId = environment.GetEndpoint(resourceIdOrEndpointName) ?? resourceIdOrEndpointName;
if (string.Equals(
environment.GetEndpoint(AzureEnvironment.Endpoint.ActiveDirectoryServiceEndpointResourceId),
resourceId, StringComparison.OrdinalIgnoreCase))
{
resourceId = environment.GetEndpoint(AzureEnvironment.Endpoint.ResourceManager);
}

return resourceId;
}

private AdalConfiguration GetAdalConfiguration(IAzureEnvironment environment, string tenantId,
string resourceId, TokenCache tokenCache)
{
Expand Down
2 changes: 1 addition & 1 deletion src/Blueprint/Blueprint.Test/Blueprint.Test.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<None Remove="UnitTests\**" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Azure.Management.Blueprint" Version="0.12.0-preview" />
<PackageReference Include="Microsoft.Azure.Management.Blueprint" Version="0.13.0-preview" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Blueprint\Blueprint.csproj" />
Expand Down
2 changes: 0 additions & 2 deletions src/Blueprint/Blueprint.Test/ScenarioTests/BlueprintTests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ function Test-GetBlueprintWithDefinitionLocationNameAndVersion
Assert-NotNull $blueprintByMG
Assert-NotNull $blueprintByMG.Id
Assert-NotNull $blueprintByMG.Scope
Assert-NotNull $blueprintByMG.DefinitionLocationId
Assert-NotNull $blueprintByMG.TargetScope
}

Expand All @@ -38,6 +37,5 @@ function Test-GetBlueprintWithDefinitionLocationNameAndLatestPublished
Assert-NotNull $blueprintByMG
Assert-NotNull $blueprintByMG.Id
Assert-NotNull $blueprintByMG.Scope
Assert-NotNull $blueprintByMG.DefinitionLocationId
Assert-NotNull $blueprintByMG.TargetScope
}
Loading

0 comments on commit ee8ac49

Please sign in to comment.