Skip to content
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

Restructure Analysis Services dataplane cmdlets to use Az module login. #8900

Merged
merged 45 commits into from
Apr 3, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
881741d
Use login credentials from new Az module.
gapreste Dec 19, 2018
81ddfd8
Merge branch 'master' into gapreste/use-new-az-module-credentials
gapreste Jan 4, 2019
401ac09
Change export log file endpoint.
gapreste Jan 8, 2019
50741a1
Merge with master pt1
gapreste Jan 9, 2019
7b00a57
Merge branch 'master' into gapreste/use-new-az-module-credentials
gapreste Jan 9, 2019
a82b902
Move Instance field to dataplane cmdlet base.
gapreste Jan 9, 2019
d9e25d5
Remove unnecessary implementation of IAsAzureHttpClient
gapreste Jan 9, 2019
817691c
Removed 'partial' keyword and related documentation because this is n…
gapreste Jan 10, 2019
5303dd4
Remove unneccessary constructors from cmdlet classes.
gapreste Jan 10, 2019
9709ffa
Move common code in cmdlet classes to base class.
gapreste Jan 10, 2019
2b61fbf
Rewrite IAsAzureHttpClient to be more relevant to new structure.
gapreste Jan 10, 2019
e68bea5
Change dataplane client property and field type to interface.
gapreste Jan 10, 2019
2dbc31b
Remove unused TokenCacheItemProvider.
gapreste Jan 10, 2019
b380946
Rewrite InMemoryTests to fit new code.
gapreste Jan 11, 2019
d2768ad
Move common authentication test code into its own method.
gapreste Jan 11, 2019
7845fc7
Add cmdlet markdown help files generated by platyPS.
gapreste Jan 11, 2019
4df833d
Move ClusterResolve() from base class to Sync-AzureASInstance, since …
gapreste Jan 14, 2019
5a1f515
Add documentation.
gapreste Jan 14, 2019
44e3dfa
Undo changes in ASCII art in generated help markdown files.
gapreste Jan 14, 2019
8af4d33
Change null context error to throw a more appropriate exception.
gapreste Jan 14, 2019
7cfaec1
Add documentation to dataplane InMemoryTests.
gapreste Jan 14, 2019
d90d9af
Update changelog
gapreste Jan 14, 2019
5f48938
Remove ClusterResolve method and ClusterResolveResult.
gapreste Jan 15, 2019
ffa1491
Rearrange fields, properties, constructors and methods, according to …
gapreste Jan 15, 2019
64acd4b
Merge branch 'master' into gapreste/use-new-az-module-credentials
gapreste Mar 27, 2019
ce946c4
Remove breaking change and fix documentation.
gapreste Mar 27, 2019
e518714
Update ChangeLog
gapreste Mar 27, 2019
501214b
Use ResourceId constant instead of Suffix constant for AnalysisServic…
gapreste Mar 29, 2019
818a6aa
Add argument AnalysisServicesEndpointResourceId to Add- Set-AzEnviron…
gapreste Mar 29, 2019
1f3c635
fix alias Add-AzAnalysisServicesAccount
Mar 30, 2019
803a69d
add position=0 back to parameter Instance
Apr 1, 2019
2e137d9
Make an alias Connect-AzAccount -> Add-AzASAccount by inheritance
Apr 1, 2019
93cb652
ConnectAzureRmAccount: parameter alias RolloutEnvironment
Apr 1, 2019
c011732
AddAzureASAccount: fix DefaultParameterSetName
Apr 1, 2019
f6e3b0f
AddAzureASAccount: wrapper
Apr 1, 2019
1a697e3
AddAzureASAccount: real wrapper
Apr 1, 2019
0e05bcc
trying to fix static analysis failures
Apr 2, 2019
25c4c5c
AnalysisServices.Dataplane.csproj: remove reference to Accounts
Apr 2, 2019
a883b87
bring several classes back to pass static analysis
Apr 2, 2019
5e0ca7e
update help
Apr 2, 2019
e3aa8c3
update help of Accounts module
Apr 2, 2019
5e99a59
simplify sync API return status check
gnair-ms Apr 2, 2019
8124c34
simplify sync response check
gnair-ms Apr 2, 2019
3f2fb30
update change logs
Apr 2, 2019
3363792
Merge branch 'release-2019-04-09' into gabriel-az-restructure
pychuang Apr 2, 2019
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
1 change: 1 addition & 0 deletions src/Accounts/Accounts/ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
- Additional information about change #1
-->
## Upcoming Release
* Updated Add-AzEnvironment and Set-AzEnvironment to accept parameter AzureAnalysisServicesEndpointResourceId
* Bug fix for azure automation update management dynamic group

## Version 1.4.0
Expand Down
6 changes: 6 additions & 0 deletions src/Accounts/Accounts/Environment/AddAzureRMEnvironment.cs
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,10 @@ public string DataLakeAudience
HelpMessage = "The endpoint to use when communicating with the Azure Log Analytics API.")]
pychuang marked this conversation as resolved.
Show resolved Hide resolved
public string AzureAnalysisServicesEndpointSuffix { get; set; }

[Parameter(Mandatory = false,
HelpMessage = "The resource identifier of the Azure Analysis Services resource.")]
public string AzureAnalysisServicesEndpointResourceId { get; set; }

protected override void BeginProcessing()
{
// do not call begin processing there is no context needed for this cmdlet
Expand Down Expand Up @@ -310,6 +314,8 @@ public override void ExecuteCmdlet()
nameof(AzureOperationalInsightsEndpoint));
SetEndpointIfBound(newEnvironment, AzureEnvironment.ExtendedEndpoint.AnalysisServicesEndpointSuffix,
nameof(AzureAnalysisServicesEndpointSuffix));
SetEndpointIfBound(newEnvironment, AzureEnvironment.ExtendedEndpoint.AnalysisServicesEndpointResourceId,
nameof(AzureAnalysisServicesEndpointResourceId));
WriteObject(new PSAzureEnvironment(profileClient.AddOrSetEnvironment(newEnvironment)));
}
});
Expand Down
6 changes: 6 additions & 0 deletions src/Accounts/Accounts/Environment/SetAzureRMEnvironment.cs
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,10 @@ public string DataLakeAudience
HelpMessage = "The endpoint to use when communicating with the Azure Log Analytics API.")]
public string AzureAnalysisServicesEndpointSuffix { get; set; }

[Parameter(Mandatory = false,
HelpMessage = "The resource identifier of the Azure Analysis Services resource.")]
public string AzureAnalysisServicesEndpointResourceId { get; set; }

protected override void BeginProcessing()
{
// do not call begin processing there is no context needed for this cmdlet
Expand Down Expand Up @@ -311,6 +315,8 @@ public override void ExecuteCmdlet()
nameof(AzureOperationalInsightsEndpoint));
SetEndpointIfBound(newEnvironment, AzureEnvironment.ExtendedEndpoint.AnalysisServicesEndpointSuffix,
nameof(AzureAnalysisServicesEndpointSuffix));
SetEndpointIfBound(newEnvironment, AzureEnvironment.ExtendedEndpoint.AnalysisServicesEndpointResourceId,
nameof(AzureAnalysisServicesEndpointResourceId));
WriteObject(new PSAzureEnvironment(profileClient.AddOrSetEnvironment(newEnvironment)));
}
});
Expand Down
24 changes: 20 additions & 4 deletions src/Accounts/Accounts/help/Add-AzEnvironment.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ Add-AzEnvironment [-Name] <String> [[-PublishSettingsFileUrl] <String>] [[-Servi
[[-AdTenant] <String>] [[-GraphAudience] <String>] [[-DataLakeAudience] <String>]
[[-BatchEndpointResourceId] <String>] [[-AzureOperationalInsightsEndpointResourceId] <String>]
[[-AzureOperationalInsightsEndpoint] <String>] [-AzureAnalysisServicesEndpointSuffix <String>]
[-Scope <ContextModificationScope>] [-DefaultProfile <IAzureContextContainer>] [-WhatIf] [-Confirm]
[<CommonParameters>]
[-AzureAnalysisServicesEndpointResourceId <String>] [-Scope <ContextModificationScope>]
[-DefaultProfile <IAzureContextContainer>] [-WhatIf] [-Confirm] [<CommonParameters>]
```

### ARMEndpoint
Expand All @@ -35,8 +35,9 @@ Add-AzEnvironment [-Name] <String> [[-StorageEndpoint] <String>] [-ARMEndpoint]
[[-AzureKeyVaultDnsSuffix] <String>] [[-AzureKeyVaultServiceEndpointResourceId] <String>]
[[-DataLakeAudience] <String>] [[-BatchEndpointResourceId] <String>]
[[-AzureOperationalInsightsEndpointResourceId] <String>] [[-AzureOperationalInsightsEndpoint] <String>]
[-AzureAnalysisServicesEndpointSuffix <String>] [-Scope <ContextModificationScope>]
[-DefaultProfile <IAzureContextContainer>] [-WhatIf] [-Confirm] [<CommonParameters>]
[-AzureAnalysisServicesEndpointSuffix <String>] [-AzureAnalysisServicesEndpointResourceId <String>]
[-Scope <ContextModificationScope>] [-DefaultProfile <IAzureContextContainer>] [-WhatIf] [-Confirm]
[<CommonParameters>]
```

## DESCRIPTION
Expand Down Expand Up @@ -155,6 +156,21 @@ Accept pipeline input: True (ByPropertyName)
Accept wildcard characters: False
```

### -AzureAnalysisServicesEndpointResourceId
The resource identifier of the Azure Analysis Services resource.

```yaml
Type: System.String
Parameter Sets: (All)
Aliases:

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```

### -AzureAnalysisServicesEndpointSuffix
The endpoint to use when communicating with the Azure Log Analytics API.

Expand Down
24 changes: 20 additions & 4 deletions src/Accounts/Accounts/help/Set-AzEnvironment.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ Set-AzEnvironment [-Name] <String> [[-PublishSettingsFileUrl] <String>] [[-Servi
[[-AdTenant] <String>] [[-GraphAudience] <String>] [[-DataLakeAudience] <String>]
[[-BatchEndpointResourceId] <String>] [[-AzureOperationalInsightsEndpointResourceId] <String>]
[[-AzureOperationalInsightsEndpoint] <String>] [-AzureAnalysisServicesEndpointSuffix <String>]
[-Scope <ContextModificationScope>] [-DefaultProfile <IAzureContextContainer>] [-WhatIf] [-Confirm]
[<CommonParameters>]
[-AzureAnalysisServicesEndpointResourceId <String>] [-Scope <ContextModificationScope>]
[-DefaultProfile <IAzureContextContainer>] [-WhatIf] [-Confirm] [<CommonParameters>]
```

### ARMEndpoint
Expand All @@ -35,8 +35,9 @@ Set-AzEnvironment [-Name] <String> [[-StorageEndpoint] <String>] [-ARMEndpoint]
[[-AzureKeyVaultDnsSuffix] <String>] [[-AzureKeyVaultServiceEndpointResourceId] <String>]
[[-DataLakeAudience] <String>] [[-BatchEndpointResourceId] <String>]
[[-AzureOperationalInsightsEndpointResourceId] <String>] [[-AzureOperationalInsightsEndpoint] <String>]
[-AzureAnalysisServicesEndpointSuffix <String>] [-Scope <ContextModificationScope>]
[-DefaultProfile <IAzureContextContainer>] [-WhatIf] [-Confirm] [<CommonParameters>]
[-AzureAnalysisServicesEndpointSuffix <String>] [-AzureAnalysisServicesEndpointResourceId <String>]
[-Scope <ContextModificationScope>] [-DefaultProfile <IAzureContextContainer>] [-WhatIf] [-Confirm]
[<CommonParameters>]
```

## DESCRIPTION
Expand Down Expand Up @@ -149,6 +150,21 @@ Accept pipeline input: True (ByPropertyName)
Accept wildcard characters: False
```

### -AzureAnalysisServicesEndpointResourceId
The resource identifier of the Azure Analysis Services resource.

```yaml
Type: System.String
Parameter Sets: (All)
Aliases:

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```

### -AzureAnalysisServicesEndpointSuffix
The endpoint to use when communicating with the Azure Log Analytics API.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,11 @@
// limitations under the License.
// ----------------------------------------------------------------------------------

using Microsoft.Azure.Commands.Common.Authentication;
using Microsoft.Azure.Commands.Common.Authentication.Models;
using System.IO;
using System.Management.Automation;
using System.Reflection;
using System.Security;
using Microsoft.Azure.Commands.AnalysisServices.Dataplane.Properties;
using Microsoft.WindowsAzure.Commands.Utilities.Common;
using Microsoft.Azure.Commands.Common.Authentication.Abstractions;
using Microsoft.WindowsAzure.Commands.Common;
using System;
using Microsoft.WindowsAzure.Commands.Common.CustomAttributes;
using Microsoft.WindowsAzure.Commands.Utilities.Common;

namespace Microsoft.Azure.Commands.AnalysisServices.Dataplane
{
Expand All @@ -40,6 +33,7 @@ public class AddAzureASAccountCommand : AzurePSCmdlet
private const string ServicePrincipalWithPasswordParameterSet = "ServicePrincipalWithPasswordParameterSetName";
private const string ServicePrincipalWithCertificateParameterSet = "ServicePrincipalWithCertificateParameterSetName";

// This is ignored since we only support public cloud
[Parameter(ParameterSetName = UserParameterSet,
Mandatory = false, HelpMessage = "Name of the Azure Analysis Services environment to which to logon to", Position = 0)]
[Parameter(ParameterSetName = ServicePrincipalWithPasswordParameterSet,
Expand Down Expand Up @@ -77,8 +71,6 @@ public class AddAzureASAccountCommand : AzurePSCmdlet
[ValidateNotNullOrEmpty]
public string CertificateThumbprint { get; set; }

protected AsAzureEnvironment AsEnvironment;

protected override IAzureContext DefaultContext
{
get
Expand All @@ -96,106 +88,42 @@ protected override string DataCollectionWarning
}
}

protected override void BeginProcessing()
public override void ExecuteCmdlet()
{
this._dataCollectionProfile = new AzurePSDataCollectionProfile(false);
System.Management.Automation.PowerShell ps = System.Management.Automation.PowerShell.Create();
ps.AddCommand("Connect-AzAccount");

if (string.IsNullOrEmpty(RolloutEnvironment))
if (MyInvocation.BoundParameters.ContainsKey(nameof(Credential)))
{
RolloutEnvironment = AsAzureClientSession.GetDefaultEnvironmentName();
ps.AddParameter("Credential", Credential);
}

if (AsAzureClientSession.Instance.Profile.Environments.ContainsKey(RolloutEnvironment))
if (MyInvocation.BoundParameters.ContainsKey(nameof(ServicePrincipal)))
{
AsEnvironment = (AsAzureEnvironment)AsAzureClientSession.Instance.Profile.Environments[RolloutEnvironment];
ps.AddParameter("ServicePrincipal", ServicePrincipal);
}
else
{
AsEnvironment = AsAzureClientSession.Instance.Profile.CreateEnvironment(RolloutEnvironment);
}
base.BeginProcessing();
}

protected override void InitializeQosEvent()
{
// nothing to do here.
}

protected override void SetupDebuggingTraces()
{
// nothing to do here.
}

protected override void TearDownDebuggingTraces()
{
// nothing to do here.
}

protected override void SetupHttpClientPipeline()
{
// nothing to do here.
}

protected override void TearDownHttpClientPipeline()
{
// nothing to do here.
}

public override void ExecuteCmdlet()
{
var azureAccount = new AsAzureAccount
{
Type = ServicePrincipal ? AsAzureAccount.AccountType.ServicePrincipal : AsAzureAccount.AccountType.User
};

SecureString password = null;
if (Credential != null)
if (MyInvocation.BoundParameters.ContainsKey(nameof(TenantId)))
{
azureAccount.Id = Credential.UserName;
password = Credential.Password;
ps.AddParameter("Tenant", TenantId);
}

if (ServicePrincipal)
if (MyInvocation.BoundParameters.ContainsKey(nameof(ApplicationId)))
{
azureAccount.Tenant = TenantId;

if (!string.IsNullOrEmpty(ApplicationId))
{
azureAccount.Id = ApplicationId;
}
if (!string.IsNullOrEmpty(CertificateThumbprint))
{
azureAccount.CertificateThumbprint = CertificateThumbprint;
}
ps.AddParameter("ApplicationId", ApplicationId);
}

if (ShouldProcess(string.Format(Resources.LoginTarget, AsEnvironment.Name), "log in"))
if (MyInvocation.BoundParameters.ContainsKey(nameof(CertificateThumbprint)))
{
var currentProfile = AsAzureClientSession.Instance.Profile;
var currentContext = currentProfile.Context;

// If there is no current context create one. If there is one already then
// if the current credentials (userid) match the one that is already in context then use it.
// if either the userid that is logging in or the environment to which login is happening is
// different than the one in the context then clear the current context and proceed to login.
// At any given point in time, we should only have one context i.e. one user logged in to one
// environment.
if (currentContext == null || Credential == null ||
string.IsNullOrEmpty(currentContext.Account.Id) ||
!currentContext.Account.Id.Equals(Credential.UserName) ||
!RolloutEnvironment.Equals(currentContext.Environment.Name))
{
AsAzureClientSession.Instance.SetCurrentContext(azureAccount, AsEnvironment);
}
// TODO: Remove IfDef
#if NETSTANDARD
var asAzureProfile = AsAzureClientSession.Instance.Login(currentProfile.Context, password, WriteWarning);
#else
var asAzureProfile = AsAzureClientSession.Instance.Login(currentProfile.Context, password);
#endif

WriteObject(asAzureProfile);
ps.AddParameter("CertificateThumbprint", CertificateThumbprint);
}

ps.Invoke();
}

protected override void InitializeQosEvent()
{
// No data collection for this cmdlet
}
}
}
Loading