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

Tagging #if statements for Az #7712

Merged
merged 26 commits into from
Nov 28, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
034499e
Updated Aks #if statement.
MiYanni Oct 24, 2018
4d54d6f
Updated AnalysisServices.Dataplane #if statements.
MiYanni Oct 24, 2018
1ac3790
Updated Batch and ContainerInstance #if statements.
MiYanni Oct 24, 2018
049e9a3
Updated DataFactories and DataLakeAnalytics #if statements.
MiYanni Oct 24, 2018
f707802
Updated KeyVault #if statements.
MiYanni Oct 26, 2018
0c0196e
Updated Network, Profile, and RecoveryServices #if statements.
MiYanni Oct 27, 2018
4b009e2
Updated Resources and Sql #if statements.
MiYanni Oct 29, 2018
9ff3032
Updated Websites #if statements.
MiYanni Oct 30, 2018
d090e28
Copied the necessary ServiceManagement Compute files to ResourceManag…
MiYanni Oct 30, 2018
58ea9bb
Updated Stack #if statements.
MiYanni Oct 30, 2018
e43ceb4
Updated Storage #if statements.
MiYanni Oct 31, 2018
12c3504
Updated StaticAnalysis and Tools.Common #if statements.
MiYanni Oct 31, 2018
a53c620
Merge branch 'preview' into ifdef-tagging
MiYanni Oct 31, 2018
7c3bbb3
Fixed net452 build issue with minor variable renames.
MiYanni Oct 31, 2018
abe7123
Updated appropriate changelogs.
MiYanni Oct 31, 2018
017b0cd
Merge branch 'preview' into ifdef-tagging
MiYanni Nov 5, 2018
f8dab80
Merge branch 'preview' into ifdef-tagging
MiYanni Nov 6, 2018
ffcfa9b
Merge branch 'preview' into ifdef-tagging
MiYanni Nov 6, 2018
5ee5b96
Merge branch 'preview' into ifdef-tagging
MiYanni Nov 8, 2018
ce62142
Merge branch 'preview' into ifdef-tagging
MiYanni Nov 12, 2018
8311a66
Merge branch 'preview' into ifdef-tagging
MiYanni Nov 27, 2018
d93028d
Merge branch 'ifdef-tagging' of https://github.com/MiYanni/azure-powe…
MiYanni Nov 27, 2018
0644e1f
Merge branch 'preview' into ifdef-tagging
MiYanni Nov 27, 2018
83ebf6b
Addressing PR review comments.
MiYanni Nov 27, 2018
b0f1c49
Merge branch 'ifdef-tagging' of https://github.com/MiYanni/azure-powe…
MiYanni Nov 27, 2018
55900e5
Merge branch 'preview' into ifdef-tagging
MiYanni Nov 27, 2018
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/ResourceManager/Aks/Commands.Aks/ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
- Additional information about change #1
-->
## Current Release
* Minor changes for upcoming AzureRM to Az transition

## Version 0.0.7
* Update dependencies for type mapping issue
Expand Down
1 change: 1 addition & 0 deletions src/ResourceManager/Aks/Commands.Aks/Commands.Aks.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@
<EmbeddedResource Include="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
<SubType>Designer</SubType>
</EmbeddedResource>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -178,34 +178,27 @@ public override void ExecuteCmdlet()

private void PopBrowser(string uri)
{
#if NETSTANDARD

var browserProcess = new Process
{
StartInfo = new ProcessStartInfo
{
UseShellExecute = true,
Arguments = uri
}
StartInfo = new ProcessStartInfo { Arguments = uri }
};

var verboseMessage = Resources.StartingOnDefault;
// TODO: Remove IfDef
#if NETSTANDARD
if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
{
WriteVerbose("Starting on OSX with open");
verboseMessage = "Starting on OSX with open";
browserProcess.StartInfo.FileName = "open";
browserProcess.Start();
return;
}
else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
{
WriteVerbose("Starting on Unix with xdg-open");
verboseMessage = "Starting on Unix with xdg-open";
browserProcess.StartInfo.FileName = "xdg-open";
browserProcess.Start();
return;
}
#endif
WriteVerbose(Resources.StartingOnDefault);
Process.Start(uri);

WriteVerbose(verboseMessage);
browserProcess.Start();
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ protected override IAzureContext DefaultContext
{
get
{
// Nothing to do with Azure Resource Managment context
// Nothing to do with Azure Resource Management context
return null;
}
}
Expand Down Expand Up @@ -141,8 +141,10 @@ protected override void TearDownHttpClientPipeline()

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

SecureString password = null;
if (Credential != null)
Expand Down Expand Up @@ -183,6 +185,7 @@ public override void ExecuteCmdlet()
{
AsAzureClientSession.Instance.SetCurrentContext(azureAccount, AsEnvironment);
}
// TODO: Remove IfDef
#if NETSTANDARD
var asAzureProfile = AsAzureClientSession.Instance.Login(currentProfile.Context, password, WriteWarning);
#else
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@

namespace Microsoft.Azure.Commands.AnalysisServices.Dataplane
{

/// <summary>
/// Cmdlet to export an Analysis Services server log to file
/// </summary>
Expand All @@ -35,7 +34,7 @@ namespace Microsoft.Azure.Commands.AnalysisServices.Dataplane
[OutputType(typeof(void))]
public class ExportAzureAnalysisServerLog : AzurePSCmdlet
{
private string serverName;
private string _serverName;

[Parameter(Mandatory = true, HelpMessage = "Name of the Azure Analysis Services which log will be fetched")]
[ValidateNotNullOrEmpty]
Expand All @@ -55,21 +54,21 @@ public class ExportAzureAnalysisServerLog : AzurePSCmdlet

public ExportAzureAnalysisServerLog()
{
this.AsAzureHttpClient = new AsAzureHttpClient(() => new HttpClient());
this.TokenCacheItemProvider = new TokenCacheItemProvider();
AsAzureHttpClient = new AsAzureHttpClient(() => new HttpClient());
TokenCacheItemProvider = new TokenCacheItemProvider();
}

public ExportAzureAnalysisServerLog(IAsAzureHttpClient AsAzureHttpClient, ITokenCacheItemProvider TokenCacheItemProvider)
public ExportAzureAnalysisServerLog(IAsAzureHttpClient asAzureHttpClient, ITokenCacheItemProvider tokenCacheItemProvider)
{
this.AsAzureHttpClient = AsAzureHttpClient;
this.TokenCacheItemProvider = TokenCacheItemProvider;
AsAzureHttpClient = asAzureHttpClient;
TokenCacheItemProvider = tokenCacheItemProvider;
}

protected override IAzureContext DefaultContext
{
get
{
// Nothing to do with Azure Resource Managment context
// Nothing to do with Azure Resource Management context
return null;
}
}
Expand All @@ -91,14 +90,14 @@ protected override void BeginProcessing()
throw new PSInvalidOperationException(string.Format(Resources.NotLoggedInMessage, ""));
}

serverName = Instance;
_serverName = Instance;
Uri uriResult;

// if the user specifies the FQN of the server, then extract the servername out of that.
// if the user specifies the FQN of the server, then extract the server name out of that.
// and set the current context
if (Uri.TryCreate(Instance, UriKind.Absolute, out uriResult) && uriResult.Scheme == "asazure")
{
serverName = uriResult.PathAndQuery.Trim('/');
_serverName = uriResult.PathAndQuery.Trim('/');
if (string.Compare(AsAzureClientSession.Instance.Profile.Context.Environment.Name, uriResult.DnsSafeHost, StringComparison.InvariantCultureIgnoreCase) != 0)
{
AsAzureClientSession.Instance.SetCurrentContext(
Expand All @@ -112,21 +111,18 @@ protected override void BeginProcessing()
if (currentContext != null
&& AsAzureClientSession.AsAzureRolloutEnvironmentMapping.ContainsKey(currentContext.Environment.Name))
{
throw new PSInvalidOperationException(string.Format(Resources.InvalidServerName, serverName));
throw new PSInvalidOperationException(string.Format(Resources.InvalidServerName, _serverName));
}
}

if (this.AsAzureHttpClient == null)
if (AsAzureHttpClient == null)
{
this.AsAzureHttpClient = new AsAzureHttpClient(() =>
{
return new HttpClient();
});
AsAzureHttpClient = new AsAzureHttpClient(() => new HttpClient());
}

if (this.TokenCacheItemProvider == null)
if (TokenCacheItemProvider == null)
{
this.TokenCacheItemProvider = new TokenCacheItemProvider();
TokenCacheItemProvider = new TokenCacheItemProvider();
}
}

Expand All @@ -140,48 +136,46 @@ public override void ExecuteCmdlet()
if (ShouldProcess(Instance, Resources.ExportingLogFromAnalysisServicesServer))
{
var context = AsAzureClientSession.Instance.Profile.Context;
#if NETSTANDARD
AsAzureClientSession.Instance.Login(context, null, null);
#else
AsAzureClientSession.Instance.Login(context, null);
#endif
string accessToken = this.TokenCacheItemProvider.GetTokenFromTokenCache(

var accessToken = TokenCacheItemProvider.GetTokenFromTokenCache(
AsAzureClientSession.TokenCache, context.Account.UniqueId);

Uri logfileBaseUri =
new Uri(string.Format("{0}{1}{2}", Uri.UriSchemeHttps, Uri.SchemeDelimiter, context.Environment.Name));
var logfileBaseUri = new Uri($"{Uri.UriSchemeHttps}{Uri.SchemeDelimiter}{context.Environment.Name}");

UriBuilder resolvedUriBuilder = new UriBuilder(logfileBaseUri);
resolvedUriBuilder.Host = ClusterResolve(logfileBaseUri, accessToken, serverName);
var resolvedUriBuilder = new UriBuilder(logfileBaseUri)
{
Host = ClusterResolve(logfileBaseUri, accessToken, _serverName)
};

var logfileEndpoint = string.Format(
(string) context.Environment.Endpoints[AsAzureEnvironment.AsRolloutEndpoints.LogfileEndpointFormat],
serverName);
_serverName);

this.AsAzureHttpClient.resetHttpClient();
using (HttpResponseMessage message = AsAzureHttpClient.CallGetAsync(
AsAzureHttpClient.resetHttpClient();
using (var message = AsAzureHttpClient.CallGetAsync(
resolvedUriBuilder.Uri,
logfileEndpoint,
accessToken).ConfigureAwait(false).GetAwaiter().GetResult())
{
message.EnsureSuccessStatusCode();
string actionWarning = string.Format(CultureInfo.CurrentCulture, Resources.ExportingLogOverwriteWarning, this.OutputPath);
if (AzureSession.Instance.DataStore.FileExists(this.OutputPath) && !this.Force.IsPresent && !ShouldContinue(actionWarning, Resources.Confirm))
var actionWarning = string.Format(CultureInfo.CurrentCulture, Resources.ExportingLogOverwriteWarning, OutputPath);
if (AzureSession.Instance.DataStore.FileExists(OutputPath) && !Force.IsPresent && !ShouldContinue(actionWarning, Resources.Confirm))
{
return;
}
AzureSession.Instance.DataStore.WriteFile(this.OutputPath, message.Content.ReadAsStringAsync().Result);
AzureSession.Instance.DataStore.WriteFile(OutputPath, message.Content.ReadAsStringAsync().Result);
}
}
}

private string ClusterResolve(Uri clusterUri, string accessToken, string serverName)
{
var resolveEndpoint = "/webapi/clusterResolve";
const string resolveEndpoint = "/webapi/clusterResolve";
var content = new StringContent($"ServerName={serverName}");
content.Headers.ContentType = MediaTypeHeaderValue.Parse("application/x-www-form-urlencoded");

using (HttpResponseMessage message = AsAzureHttpClient.CallPostAsync(
using (var message = AsAzureHttpClient.CallPostAsync(
clusterUri,
resolveEndpoint,
accessToken,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ namespace Microsoft.Azure.Commands.AnalysisServices.Dataplane
[OutputType(typeof(bool))]
public class RestartAzureAnalysisServer : AzurePSCmdlet
{
private string serverName;
private string _serverName;

[Parameter(Mandatory = true, HelpMessage = "Name of the Azure Analysis Services server to restart")]
[ValidateNotNullOrEmpty]
Expand All @@ -45,22 +45,22 @@ public class RestartAzureAnalysisServer : AzurePSCmdlet

public RestartAzureAnalysisServer()
{
this.AsAzureHttpClient = new AsAzureHttpClient(() => new HttpClient());
this.TokenCacheItemProvider = new TokenCacheItemProvider();
AsAzureHttpClient = new AsAzureHttpClient(() => new HttpClient());
TokenCacheItemProvider = new TokenCacheItemProvider();

}

public RestartAzureAnalysisServer(IAsAzureHttpClient AsAzureHttpClient, ITokenCacheItemProvider TokenCacheItemProvider)
public RestartAzureAnalysisServer(IAsAzureHttpClient asAzureHttpClient, ITokenCacheItemProvider tokenCacheItemProvider)
{
this.AsAzureHttpClient = AsAzureHttpClient;
this.TokenCacheItemProvider = TokenCacheItemProvider;
AsAzureHttpClient = asAzureHttpClient;
TokenCacheItemProvider = tokenCacheItemProvider;
}

protected override IAzureContext DefaultContext
{
get
{
// Nothing to do with Azure Resource Managment context
// Nothing to do with Azure Resource Management context
return null;
}
}
Expand All @@ -82,14 +82,14 @@ protected override void BeginProcessing()
throw new PSInvalidOperationException(string.Format(Resources.NotLoggedInMessage, ""));
}

serverName = Instance;
_serverName = Instance;
Uri uriResult;

// if the user specifies the FQN of the server, then extract the servername out of that.
// if the user specifies the FQN of the server, then extract the server name out of that.
// and set the current context
if (Uri.TryCreate(Instance, UriKind.Absolute, out uriResult) && uriResult.Scheme == "asazure")
{
serverName = uriResult.PathAndQuery.Trim('/');
_serverName = uriResult.PathAndQuery.Trim('/');
if (string.Compare(AsAzureClientSession.Instance.Profile.Context.Environment.Name, uriResult.DnsSafeHost, StringComparison.InvariantCultureIgnoreCase) != 0)
{
AsAzureClientSession.Instance.SetCurrentContext(
Expand All @@ -103,21 +103,18 @@ protected override void BeginProcessing()
if (currentContext != null
&& AsAzureClientSession.AsAzureRolloutEnvironmentMapping.ContainsKey(currentContext.Environment.Name))
{
throw new PSInvalidOperationException(string.Format(Resources.InvalidServerName, serverName));
throw new PSInvalidOperationException(string.Format(Resources.InvalidServerName, _serverName));
}
}

if (this.AsAzureHttpClient == null)
if (AsAzureHttpClient == null)
{
this.AsAzureHttpClient = new AsAzureHttpClient(() =>
{
return new HttpClient();
});
AsAzureHttpClient = new AsAzureHttpClient(() => new HttpClient());
}

if (this.TokenCacheItemProvider == null)
if (TokenCacheItemProvider == null)
{
this.TokenCacheItemProvider = new TokenCacheItemProvider();
TokenCacheItemProvider = new TokenCacheItemProvider();
}
}

Expand All @@ -131,18 +128,15 @@ public override void ExecuteCmdlet()
if (ShouldProcess(Instance, Resources.RestartingAnalysisServicesServer))
{
var context = AsAzureClientSession.Instance.Profile.Context;
#if NETSTANDARD
AsAzureClientSession.Instance.Login(context, null, null);
#else
AsAzureClientSession.Instance.Login(context, null);
#endif
string accessToken = this.TokenCacheItemProvider.GetTokenFromTokenCache(AsAzureClientSession.TokenCache, context.Account.UniqueId);

Uri restartBaseUri = new Uri(string.Format("{0}{1}{2}", Uri.UriSchemeHttps, Uri.SchemeDelimiter, context.Environment.Name));
var accessToken = TokenCacheItemProvider.GetTokenFromTokenCache(AsAzureClientSession.TokenCache, context.Account.UniqueId);

var restartBaseUri = new Uri($"{Uri.UriSchemeHttps}{Uri.SchemeDelimiter}{context.Environment.Name}");

var restartEndpoint = string.Format((string)context.Environment.Endpoints[AsAzureEnvironment.AsRolloutEndpoints.RestartEndpointFormat], serverName);
var restartEndpoint = string.Format((string)context.Environment.Endpoints[AsAzureEnvironment.AsRolloutEndpoints.RestartEndpointFormat], _serverName);

using (HttpResponseMessage message = AsAzureHttpClient.CallPostAsync(
using (var message = AsAzureHttpClient.CallPostAsync(
restartBaseUri,
restartEndpoint,
accessToken).Result)
Expand Down
Loading