Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
65 commits
Select commit Hold shift + click to select a range
9dec2a4
PowerShell for copy and GeoDR
dominiqa Aug 7, 2015
72424de
Review Changes for Replication Cmdlets
dominiqa Aug 7, 2015
6bd2621
Fixing Build Issue
dominiqa Aug 7, 2015
b1d8d9b
Updating Database Replication Test JSONs and streamlining test script…
dominiqa Aug 20, 2015
230e840
Fixing Build Issues from merge and cherry pick changes
dominiqa Aug 20, 2015
6d34a0d
Fixing GetLink Bug for CreateLink
dominiqa Aug 20, 2015
53354d8
Merge branch 'dev' of https://github.com/Azure/azure-powershell into dev
dominiqa Aug 20, 2015
4703a0c
Updated Wix
dominiqa Aug 20, 2015
b90217e
Adding cmdlet help for GeoDR and DB Copy cmdlets
dominiqa Aug 20, 2015
cfa8f77
Merge branch 'dev' of https://github.com/Azure/azure-powershell into dev
dominiqa Aug 20, 2015
0a7d629
Merge branch 'dev' of https://github.com/Azure/azure-powershell into dev
dominiqa Aug 20, 2015
02715f5
Merge branch 'dev' of https://github.com/Azure/azure-powershell into dev
dominiqa Aug 22, 2015
3399089
Merge branch 'dev' of https://github.com/Azure/azure-powershell into dev
dominiqa Aug 24, 2015
7b359a1
GeoDR Failover Cmdlets
dominiqa Aug 25, 2015
f527230
Revert "Revert "FI from dev1 into release""
AditTulasi Aug 25, 2015
a3a87ce
Merge branch 'dev1' of https://github.com/MabOneSdk/azure-powershell …
AditTulasi Aug 25, 2015
091e34b
Revert "GeoDR Failover Cmdlets"
dominiqa Aug 25, 2015
2888fb2
Merge branch 'dev' of https://github.com/Azure/azure-powershell into dev
dominiqa Aug 25, 2015
ace3561
reverting wix to base
dominiqa Aug 25, 2015
35799cb
Fixes based on feedback comments
dominiqa Aug 25, 2015
5505ab9
updating references to hdi nuget
Aug 25, 2015
85ef6b5
updating test refs
Aug 25, 2015
c8aff29
remove app.config
Aug 25, 2015
74dfe5d
Updated Wix file
dominiqa Aug 25, 2015
727028d
Merge branch 'dev' of https://github.com/Azure/azure-powershell into dev
dominiqa Aug 25, 2015
9ba9f01
Merge branch 'dev' of https://github.com/Azure/azure-powershell into dev
dominiqa Aug 25, 2015
cb732fe
Merge branch 'dev' of https://github.com/Azure/azure-powershell into dev
dominiqa Aug 26, 2015
0bdb51d
Reverting Bad Merge
dominiqa Aug 26, 2015
aba8a75
recommiting merge
dominiqa Aug 26, 2015
8129ebd
Fixed Merge error
dominiqa Aug 26, 2015
bd0101f
Merge pull request #142 from Azure/dev
Aug 26, 2015
4e0e3d0
Merge pull request #143 from MabOneSdk/release
Aug 26, 2015
fabe186
Merge pull request #144 from MabOneSdk/dev1
Aug 26, 2015
8f5306b
Scrubbing help text
Aug 26, 2015
02dcf16
Merge pull request #146 from MabOneSdk/dev1-anudeeb
Aug 26, 2015
f171b44
Updating help doc
Aug 26, 2015
3b47381
Merge pull request #147 from MabOneSdk/dev1-anudeeb
Aug 26, 2015
3a6f6a8
Merge pull request #148 from MabOneSdk/dev1
Aug 26, 2015
9acf88f
Merge branch 'dev' of https://github.com/Azure/azure-powershell into dev
Aug 26, 2015
cc4f7b0
Merge branch 'dev' of https://github.com/Azure/azure-powershell into dev
dominiqa Aug 26, 2015
b0954a2
Clean project from ResourceManager.sln
Aug 26, 2015
52ab44b
Fixed SQL Cmdlets installer fix
dominiqa Aug 26, 2015
ea96a7f
Merge pull request #799 from shefaliv/dev
markcowl Aug 26, 2015
116a3ab
Merge branch 'dev' of https://github.com/Azure/azure-powershell into dev
dominiqa Aug 26, 2015
a94d38c
Add Launch option to Get-RDP command
deepakswifty Aug 26, 2015
75b542c
update release file
deepakswifty Aug 27, 2015
90804f3
Bug fix in SQL data masking when updating rule
yoavrubin Aug 27, 2015
19f772c
Updating tests
yoavrubin Aug 27, 2015
d7af629
Merge pull request #804 from MabOneSdk/release
ogail Aug 27, 2015
7da0852
Merge pull request #806 from DeepakRajendranMsft/AddLaunchOptionOnRDP
ogail Aug 27, 2015
84aaec6
Adding Azure Backup changes
Aug 28, 2015
64df045
Convert Resources project to use AzureRMCmdlet
Aug 28, 2015
cf86e9c
Fix compilation errors
Aug 28, 2015
fa41872
Migrate ApiManagement
Aug 28, 2015
dc1ffcc
Merge pull request #780 from dominiqa/dev
markcowl Aug 28, 2015
31c94c1
Merge pull request #811 from dragonfly91/patch-2
ogail Aug 28, 2015
668a52c
Migrate AzureBackup and Batch
Aug 28, 2015
7fcf824
Merge branch 'dev' of github.com:Azure/azure-powershell into AutoRest
Aug 28, 2015
dd15563
Merge pull request #807 from yoavrubin/dev
ogail Aug 28, 2015
734ea73
Merge branch 'dev' of github.com:Azure/azure-powershell into AutoRest
Aug 28, 2015
227d3ea
Migrate DataFactories
Aug 28, 2015
fa4dad4
Migrate Dns project
Aug 28, 2015
150ff60
Migrate HDInsights
Aug 28, 2015
d40b1ec
Migrate Insights project to use AzureRMCmdlet
Aug 28, 2015
788ff10
Migrate KeyVault project to use AzureRM common classes
Aug 29, 2015
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
38 changes: 20 additions & 18 deletions ChangeLog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,24 @@
## 2015.09.03 version 0.9.8

* Azure Compute (ARM) Cmdlets
* Add -Launch parameter for Get-AzureRemoteDesktopFile cmdlet
* Azure Backup - added the following cmdlets
* Backup-AzureRMBackupItem
* Register-AzureRMBackupContainer
* Disable-AzureRMBackupProtection
* Enable-AzureRMBackupProtection
* Get-AzureRMBackupItem
* Get-AzureRMBackupJob
* Get-AzureRMBackupJobDetails
* Stop-AzureRMBackupJob
* Wait-AzureRMBackupJob
* Get-AzureRMBackupProtectionPolicy
* New-AzureRMBackupProtectionPolicy
* New-AzureRMBackupRetentionPolicyObject
* Remove-AzureRMBackupProtectionPolicy
* Set-AzureRMBackupProtectionPolicy
* Get-AzureRMBackupRecoveryPoint
* Restore-AzureRMBackupItem

## 2015.08.17 version 0.9.7
* Azure Profile cmdlets
* New-AzureProfile
Expand Down Expand Up @@ -29,23 +48,6 @@
* Added Restart-AzureRemoteAppVm cmdlet
* Azure HDInsight cmdlets
* Added cmdlet help
* Azure Backup - added the following cmdlets
* Backup-AzureRMBackupItem
* Register-AzureRMBackupContainer
* Disable-AzureRMBackupProtection
* Enable-AzureRMBackupProtection
* Get-AzureRMBackupItem
* Get-AzureRMBackupJob
* Get-AzureRMBackupJobDetails
* Stop-AzureRMBackupJob
* Wait-AzureRMBackupJob
* Get-AzureRMBackupProtectionPolicy
* New-AzureRMBackupProtectionPolicy
* New-AzureRMBackupRetentionPolicyObject
* Remove-AzureRMBackupProtectionPolicy
* Set-AzureRMBackupProtectionPolicy
* Get-AzureRMBackupRecoveryPoint
* Restore-AzureRMBackupItem

## 2015.08.07 version 0.9.6
* Azure Batch cmdlets
Expand Down
4 changes: 4 additions & 0 deletions setup/azurecmdfiles.wxi
Original file line number Diff line number Diff line change
Expand Up @@ -2077,6 +2077,9 @@
<Component Id="cmp55FEE041CC305952FE17E655815CE51A" Guid="*">
<File Id="fil14F4B8C7E95C606DDDE47BE166D9F241" KeyPath="yes" Source="$(var.sourceDir)\ResourceManager\AzureResourceManager\Sql\Microsoft.Azure.Commands.Sql.format.ps1xml" />
</Component>
<Component Id="cmpF23457BA331434DDB0815F84746FD1E7" Guid="*">
<File Id="fil1972DDA29C9A5FC7D61122B5F5E1D84B" KeyPath="yes" Source="$(var.sourceDir)\ResourceManager\AzureResourceManager\Sql\Microsoft.Azure.Commands.Sql.Types.ps1xml" />
</Component>
<Component Id="cmp057F4C8C0E8E8DB3E57FD8B64885B30F" Guid="*">
<File Id="fil17C8016A3D5AA097BE35FB83C7539AB9" KeyPath="yes" Source="$(var.sourceDir)\ResourceManager\AzureResourceManager\Sql\Microsoft.Azure.Commands.Tags.dll" />
</Component>
Expand Down Expand Up @@ -5475,6 +5478,7 @@
<ComponentRef Id="cmp56F52674BB946225BB64533814DCF37F" />
<ComponentRef Id="cmp499092B04619C0EDE4686B78E1128605" />
<ComponentRef Id="cmp55FEE041CC305952FE17E655815CE51A" />
<ComponentRef Id="cmpF23457BA331434DDB0815F84746FD1E7" />
<ComponentRef Id="cmp057F4C8C0E8E8DB3E57FD8B64885B30F" />
<ComponentRef Id="cmpC6D3C91080AD47682B7959EF9DF193D3" />
<ComponentRef Id="cmpD7CC32C127B6074C2D5CA20EAA1B14A0" />
Expand Down
10 changes: 8 additions & 2 deletions src/AzurePowershell.sln
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 2013
VisualStudioVersion = 12.0.30723.0
# Visual Studio 14
VisualStudioVersion = 14.0.23107.0
MinimumVisualStudioVersion = 10.0.40219.1
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{8531411A-0137-4E27-9C5E-49E07C245048}"
ProjectSection(SolutionItems) = preProject
Expand Down Expand Up @@ -235,6 +235,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Commands.SiteRecovery", "Re
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Commands.SiteRecovery.Test", "ResourceManager\SiteRecovery\Commands.SiteRecovery.Test\Commands.SiteRecovery.Test.csproj", "{6C7D3D81-37AB-445E-8081-78A1FEC0A773}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Commands.ResourceManager.Common", "Common\Commands.ResourceManager.Common\Commands.ResourceManager.Common.csproj", "{3819D8A7-C62C-4C47-8DDD-0332D9CE1252}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -585,6 +587,10 @@ Global
{6C7D3D81-37AB-445E-8081-78A1FEC0A773}.Debug|Any CPU.Build.0 = Debug|Any CPU
{6C7D3D81-37AB-445E-8081-78A1FEC0A773}.Release|Any CPU.ActiveCfg = Release|Any CPU
{6C7D3D81-37AB-445E-8081-78A1FEC0A773}.Release|Any CPU.Build.0 = Release|Any CPU
{3819D8A7-C62C-4C47-8DDD-0332D9CE1252}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{3819D8A7-C62C-4C47-8DDD-0332D9CE1252}.Debug|Any CPU.Build.0 = Debug|Any CPU
{3819D8A7-C62C-4C47-8DDD-0332D9CE1252}.Release|Any CPU.ActiveCfg = Release|Any CPU
{3819D8A7-C62C-4C47-8DDD-0332D9CE1252}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
267 changes: 267 additions & 0 deletions src/Common/AzurePSCmdlet.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,267 @@
// ----------------------------------------------------------------------------------
//
// Copyright Microsoft Corporation
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// ----------------------------------------------------------------------------------

using System;
using System.Collections.Concurrent;
using System.Diagnostics;
using System.Management.Automation;
using System.Net.Http.Headers;
using System.Reflection;
using Microsoft.Azure.Common.Authentication;
using Microsoft.Azure.Common.Authentication.Models;
using Microsoft.WindowsAzure.Commands.Common;

namespace Microsoft.WindowsAzure.Commands.Utilities.Common
{
/// <summary>
/// Represents base class for all Azure cmdlets.
/// </summary>
public abstract class AzurePSCmdlet : PSCmdlet, IDisposable
{
private readonly ConcurrentQueue<string> _debugMessages;

private RecordingTracingInterceptor _httpTracingInterceptor;

private DebugStreamTraceListener _adalListener;

/// <summary>
/// Gets the PowerShell module name used for user agent header.
/// By default uses "Azurepowershell"
/// </summary>
protected virtual string ModuleName { get { return "AzurePowershell"; } }

/// <summary>
/// Gets PowerShell module version used for user agent header.
/// </summary>
protected string ModuleVersion { get { return Assembly.GetCallingAssembly().GetName().Version.ToString(); } }

/// <summary>
/// Gets the default Azure context.
/// </summary>
protected abstract AzureContext DefaultContext { get; }

/// <summary>
/// Initializes AzurePSCmdlet properties.
/// </summary>
public AzurePSCmdlet()
{
_debugMessages = new ConcurrentQueue<string>();
}

/// <summary>
/// Cmdlet begin process. Write to logs, setup Http Tracing and initialize profile and adds user agent.
/// </summary>
protected override void BeginProcessing()
{
if (string.IsNullOrEmpty(ParameterSetName))
{
WriteDebugWithTimestamp(string.Format("{0} begin processing without ParameterSet.", this.GetType().Name));
}
else
{
WriteDebugWithTimestamp(string.Format("{0} begin processing with ParameterSet '{1}'.", this.GetType().Name, ParameterSetName));
}

if (DefaultContext != null && DefaultContext.Account != null && DefaultContext.Account.Id != null)
{
WriteDebugWithTimestamp(string.Format("using account id '{0}'...", DefaultContext.Account.Id));
}

_httpTracingInterceptor = _httpTracingInterceptor ?? new RecordingTracingInterceptor(_debugMessages);
_adalListener = _adalListener ?? new DebugStreamTraceListener(_debugMessages);
RecordingTracingInterceptor.AddToContext(_httpTracingInterceptor);
DebugStreamTraceListener.AddAdalTracing(_adalListener);

ProductInfoHeaderValue userAgentValue = new ProductInfoHeaderValue(
ModuleName, string.Format("v{0}", ModuleVersion));
AzureSession.ClientFactory.UserAgents.Add(userAgentValue);

base.BeginProcessing();
}

/// <summary>
/// End processing. Flush messages in tracing interceptor and save profile and removes user agent.
/// </summary>
protected override void EndProcessing()
{
string message = string.Format("{0} end processing.", this.GetType().Name);
WriteDebugWithTimestamp(message);

RecordingTracingInterceptor.RemoveFromContext(_httpTracingInterceptor);
DebugStreamTraceListener.RemoveAdalTracing(_adalListener);
FlushDebugMessages();

AzureSession.ClientFactory.UserAgents.RemoveAll(u => u.Product.Name == ModuleName);

base.EndProcessing();
}

protected string CurrentPath()
{
// SessionState is only available within Powershell so default to
// the CurrentDirectory when being run from tests.
return (SessionState != null) ?
SessionState.Path.CurrentLocation.Path :
Environment.CurrentDirectory;
}

protected bool IsVerbose()
{
bool verbose = MyInvocation.BoundParameters.ContainsKey("Verbose") && ((SwitchParameter)MyInvocation.BoundParameters["Verbose"]).ToBool();
return verbose;
}

protected new void WriteError(ErrorRecord errorRecord)
{
FlushDebugMessages();
base.WriteError(errorRecord);
}

protected new void WriteObject(object sendToPipeline)
{
FlushDebugMessages();
base.WriteObject(sendToPipeline);
}

protected new void WriteObject(object sendToPipeline, bool enumerateCollection)
{
FlushDebugMessages();
base.WriteObject(sendToPipeline, enumerateCollection);
}

protected new void WriteVerbose(string text)
{
FlushDebugMessages();
base.WriteVerbose(text);
}

protected new void WriteWarning(string text)
{
FlushDebugMessages();
base.WriteWarning(text);
}

protected new void WriteCommandDetail(string text)
{
FlushDebugMessages();
base.WriteCommandDetail(text);
}

protected new void WriteProgress(ProgressRecord progressRecord)
{
FlushDebugMessages();
base.WriteProgress(progressRecord);
}

protected new void WriteDebug(string text)
{
FlushDebugMessages();
base.WriteDebug(text);
}

protected void WriteVerboseWithTimestamp(string message, params object[] args)
{
WriteVerbose(string.Format("{0:T} - {1}", DateTime.Now, string.Format(message, args)));
}

protected void WriteVerboseWithTimestamp(string message)
{
WriteVerbose(string.Format("{0:T} - {1}", DateTime.Now, message));
}

protected void WriteWarningWithTimestamp(string message)
{
WriteWarning(string.Format("{0:T} - {1}", DateTime.Now, message));
}

protected void WriteDebugWithTimestamp(string message, params object[] args)
{
WriteDebug(string.Format("{0:T} - {1}", DateTime.Now, string.Format(message, args)));
}

protected void WriteDebugWithTimestamp(string message)
{
WriteDebug(string.Format("{0:T} - {1}", DateTime.Now, message));
}

protected void WriteErrorWithTimestamp(string message)
{
WriteError(
new ErrorRecord(new Exception(string.Format("{0:T} - {1}", DateTime.Now, message)),
string.Empty,
ErrorCategory.NotSpecified,
null));
}

/// <summary>
/// Write an error message for a given exception.
/// </summary>
/// <param name="ex">The exception resulting from the error.</param>
protected virtual void WriteExceptionError(Exception ex)
{
Debug.Assert(ex != null, "ex cannot be null or empty.");
WriteError(new ErrorRecord(ex, string.Empty, ErrorCategory.CloseError, null));
}

protected PSObject ConstructPSObject(string typeName, params object[] args)
{
return PowerShellUtilities.ConstructPSObject(typeName, args);
}

protected void SafeWriteOutputPSObject(string typeName, params object[] args)
{
PSObject customObject = this.ConstructPSObject(typeName, args);
WriteObject(customObject);
}

private void FlushDebugMessages()
{
string message;
while (_debugMessages.TryDequeue(out message))
{
base.WriteDebug(message);
}
}

/// <summary>
/// Asks for confirmation before executing the action.
/// </summary>
/// <param name="force">Do not ask for confirmation</param>
/// <param name="actionMessage">Message to describe the action</param>
/// <param name="processMessage">Message to prompt after the active is performed.</param>
/// <param name="target">The target name.</param>
/// <param name="action">The action code</param>
protected void ConfirmAction(bool force, string actionMessage, string processMessage, string target, Action action)
{
if (force || ShouldContinue(actionMessage, ""))
{
if (ShouldProcess(target, processMessage))
{
action();
}
}
}

protected virtual void Dispose(bool disposing)
{
_adalListener.Dispose();
}

public void Dispose()
{
Dispose(true);
GC.SuppressFinalize(this);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -166,12 +166,6 @@
<Compile Include="StorageUtilities.cs" />
<Compile Include="WindowsAzureSubscriptionExtensions.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Commands.Common\Commands.Common.csproj">
<Project>{5ee72c53-1720-4309-b54b-5fb79703195f}</Project>
<Name>Commands.Common</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
Expand All @@ -181,6 +175,12 @@
<ItemGroup>
<None Include="packages.config" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Commands.Common\Commands.Common.csproj">
<Project>{5ee72c53-1720-4309-b54b-5fb79703195f}</Project>
<Name>Commands.Common</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Import Project="$(SolutionDir)\.nuget\nuget.targets" />
<Import Project="..\..\packages\Microsoft.Bcl.Build.1.0.14\tools\Microsoft.Bcl.Build.targets" Condition="Exists('..\..\packages\Microsoft.Bcl.Build.1.0.14\tools\Microsoft.Bcl.Build.targets')" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,6 @@
<Compile Include="Common\PSObjectExtensions.cs" />
<Compile Include="Common\RemoveAzurePublishSettings.cs" />
<Compile Include="Common\SimpleServiceManagementAsyncResult.cs" />
<Compile Include="Common\TestBase.cs" />
<Compile Include="Common\ConversionUtilitiesTests.cs" />
<Compile Include="Common\Testing.cs" />
<Compile Include="Mocks\MockCommandRuntime.cs" />
Expand Down
Loading