Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
79ca615
fixing build errors
Apr 2, 2021
0b3bbba
NewAzureAutomationAccount.
Apr 2, 2021
f9d7222
SetAzureAutomationAccount.
Apr 2, 2021
aff23ea
updated test recordings
Apr 4, 2021
2b4b58a
adding default param set
Apr 4, 2021
3149582
UpdateDynamicGroupPrePostTests recordings
Apr 4, 2021
f4c6f2c
schedule and hybrid test recordings
Apr 4, 2021
3518483
UpdateManagementTests recordings
Apr 5, 2021
cd0adba
SourceControlTests recordings
Apr 5, 2021
65e2fd7
HybridWorkerGroupTests records
Apr 5, 2021
7ad535e
Update src/Automation/Automation/Cmdlet/NewAzureAutomationAccount.cs
Apr 6, 2021
6d7fdef
Update src/Automation/Automation/Cmdlet/SetAzureAutomationAccount.cs
Apr 6, 2021
800dcd6
Update src/Automation/Automation/help/Set-AzAutomationAccount.md
Apr 6, 2021
0e13e89
Update src/Automation/Automation/help/Set-AzAutomationAccount.md
Apr 6, 2021
f45ddf0
Update src/Automation/Automation/Cmdlet/NewAzureAutomationAccount.cs
Apr 6, 2021
ec2253f
Update src/Automation/Automation/Cmdlet/NewAzureAutomationAccount.cs
Apr 6, 2021
831de2a
updated changelog
Apr 6, 2021
e8e6160
SourceControlTests
Apr 6, 2021
6109e4c
BreakingChangeIssues
Apr 6, 2021
ffa13a2
avoid breaking change
Apr 6, 2021
f0f8238
removing BreakingChangeIssues
Apr 6, 2021
ce31455
avoid breaking change 2
Apr 6, 2021
fc34ae1
avoid breaking change 3
Apr 6, 2021
1186905
avoid breaking change 4
Apr 6, 2021
800acfd
Merge branch 'release-2021-04-13' into cmk
dingmeng-xue Apr 6, 2021
497565b
UpdateDynamicGroupPrePostTests
Apr 7, 2021
5a45829
Merge branch 'cmk' of https://github.com/sharma224/azure-powershell i…
Apr 7, 2021
260c005
Merge branch 'release-2021-04-13' into cmk
BethanyZhou Apr 7, 2021
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
2 changes: 1 addition & 1 deletion src/Automation/Automation.Test/Automation.Test.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Azure.Management.Automation" Version="3.8.1-preview" />
<PackageReference Include="Microsoft.Azure.Management.Automation" Version="3.8.3-preview" />
<PackageReference Include="MSTest.TestAdapter" Version="1.2.1" />
<PackageReference Include="MSTest.TestFramework" Version="1.2.1" />
</ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public void NewAzureAutomationAccountByNameSuccessfull()
string location = "East US";
string plan = "Free";

this.mockAutomationClient.Setup(f => f.CreateAutomationAccount(resourceGroupName, accountName, location, plan, null));
this.mockAutomationClient.Setup(f => f.CreateAutomationAccount(resourceGroupName, accountName, location, plan, null, false, false, false, null, null, null));

// Test
this.cmdlet.ResourceGroupName = resourceGroupName;
Expand All @@ -60,7 +60,7 @@ public void NewAzureAutomationAccountByNameSuccessfull()
this.cmdlet.ExecuteCmdlet();

// Assert
this.mockAutomationClient.Verify(f => f.CreateAutomationAccount(resourceGroupName, accountName, location, plan, null), Times.Once());
this.mockAutomationClient.Verify(f => f.CreateAutomationAccount(resourceGroupName, accountName, location, plan, null, false, false, false, null, null, null), Times.Once());
}
}
}
8 changes: 6 additions & 2 deletions src/Automation/Automation.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 15
VisualStudioVersion = 15.0.27703.2042
# Visual Studio Version 16
VisualStudioVersion = 16.0.31129.286
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Automation", "Automation\Automation.csproj", "{90DEF35A-F7FF-40D0-B008-F489A4C092DB}"
EndProject
Expand Down Expand Up @@ -38,6 +38,10 @@ Global
{142D7B0B-388A-4CEB-A228-7F6D423C5C2E}.Debug|Any CPU.Build.0 = Debug|Any CPU
{142D7B0B-388A-4CEB-A228-7F6D423C5C2E}.Release|Any CPU.ActiveCfg = Release|Any CPU
{142D7B0B-388A-4CEB-A228-7F6D423C5C2E}.Release|Any CPU.Build.0 = Release|Any CPU
{6BD6B80A-06AF-4B5B-9230-69CCFC6C8D64}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{6BD6B80A-06AF-4B5B-9230-69CCFC6C8D64}.Debug|Any CPU.Build.0 = Debug|Any CPU
{6BD6B80A-06AF-4B5B-9230-69CCFC6C8D64}.Release|Any CPU.ActiveCfg = Release|Any CPU
{6BD6B80A-06AF-4B5B-9230-69CCFC6C8D64}.Release|Any CPU.Build.0 = Release|Any CPU
{FF81DC73-B8EC-4082-8841-4FBF2B16E7CE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{FF81DC73-B8EC-4082-8841-4FBF2B16E7CE}.Debug|Any CPU.Build.0 = Debug|Any CPU
{FF81DC73-B8EC-4082-8841-4FBF2B16E7CE}.Release|Any CPU.ActiveCfg = Release|Any CPU
Expand Down
2 changes: 1 addition & 1 deletion src/Automation/Automation/Automation.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Azure.Management.Automation" Version="3.8.1-preview" />
<PackageReference Include="Microsoft.Azure.Management.Automation" Version="3.8.3-preview" />
<PackageReference Include="System.Security.Permissions" Version="4.5.0" />
</ItemGroup>

Expand Down
3 changes: 2 additions & 1 deletion src/Automation/Automation/ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,12 @@
- Additional information about change #1
-->
## Upcoming Release
* Fixed issue that disables the schedule for update deployment if schedule was re-created with same name
* Added support for Customer Managed Key Encryption with System Assigned Identity

## Version 1.5.2
* Fixed the issue for starting Python3 runbooks with parameters
* Fixed time zone issue while creating an update deployment schedule.
* Fixed issue that disables the schedule for update deployment if schedule was re-created with same name

## Version 1.5.1
* Fixed te issue that complex object cannot be serialized correctly. [#14431]
Expand Down
64 changes: 62 additions & 2 deletions src/Automation/Automation/Cmdlet/NewAzureAutomationAccount.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,16 @@ namespace Microsoft.Azure.Commands.Automation.Cmdlet
[OutputType(typeof(AutomationAccount))]
public class NewAzureAutomationAccount : ResourceManager.Common.AzureRMCmdlet
{
/// <summary>
/// AutomationServices Encryption parameter set name
/// </summary>
private const string AutomationServicesEncryptionParameterSet = "AutomationServicesEncryption";

/// <summary>
/// KeyVault Encryption parameter set name
/// </summary>
private const string KeyVaultEncryptionParameterSet = "KeyVaultEncryption";

/// <summary>
/// The automation client.
/// </summary>
Expand Down Expand Up @@ -87,14 +97,64 @@ public IAutomationPSClient AutomationClient
[Alias("Tag")]
public IDictionary Tags { get; set; }

[Parameter(
Mandatory = false,
HelpMessage = "Generate and assign a new System Identity for this automation account")]
public SwitchParameter AssignSystemIdentity { get; set; }

[Parameter(HelpMessage = "Whether to set Automation Account KeySource to Microsoft.Automation or not.",
Mandatory = false,
ParameterSetName = AutomationServicesEncryptionParameterSet)]
public SwitchParameter AutomationServicesEncryption { get; set; }

[Parameter(HelpMessage = "Whether to set Automation Account KeySource to Microsoft.KeyVault(enable CMK) or not.",
Mandatory = false,
ParameterSetName = KeyVaultEncryptionParameterSet)]
public SwitchParameter KeyVaultEncryption { get; set; }

[Parameter(HelpMessage = "CMK KeyName",
Mandatory = true,
ParameterSetName = KeyVaultEncryptionParameterSet)]
[ValidateNotNullOrEmpty]
public string KeyName { get; set; }

[Parameter(HelpMessage = "CMK KeyVersion",
Mandatory = true,
ParameterSetName = KeyVaultEncryptionParameterSet)]
[ValidateNotNullOrEmpty]
public string KeyVersion { get; set; }

[Parameter(HelpMessage = "CMK KeyVaultUri",
Mandatory = true,
ParameterSetName = KeyVaultEncryptionParameterSet)]
[ValidateNotNullOrEmpty]
public string KeyVaultUri { get; set; }

/// <summary>
/// Execute this cmdlet.
/// </summary>
[PermissionSet(SecurityAction.Demand, Name = "FullTrust")]
public override void ExecuteCmdlet()
{
var account = this.AutomationClient.CreateAutomationAccount(this.ResourceGroupName, this.Name, this.Location, this.Plan, this.Tags);
this.WriteObject(account);
bool addSystemId = false;
if (AssignSystemIdentity.IsPresent)
{
addSystemId = true;
}
bool enableAMK = false;
if (AutomationServicesEncryption.IsPresent)
{
enableAMK = true;
}
bool enableCMK = false;
if (ParameterSetName == KeyVaultEncryptionParameterSet)
{
enableCMK = true;
}

var account = this.AutomationClient.CreateAutomationAccount(this.ResourceGroupName, this.Name, this.Location, this.Plan, this.Tags, addSystemId, enableAMK, enableCMK, KeyName, KeyVersion, KeyVaultUri);
this.WriteObject(account);

}
}
}
61 changes: 60 additions & 1 deletion src/Automation/Automation/Cmdlet/SetAzureAutomationAccount.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,16 @@ namespace Microsoft.Azure.Commands.Automation.Cmdlet
[OutputType(typeof(AutomationAccount))]
public class SetAzureAutomationAccount : ResourceManager.Common.AzureRMCmdlet
{
/// <summary>
/// AutomationServices Encryption parameter set name
/// </summary>
private const string AutomationServicesEncryptionParameterSet = "AutomationServicesEncryption";

/// <summary>
/// KeyVault Encryption parameter set name
/// </summary>
private const string KeyVaultEncryptionParameterSet = "KeyVaultEncryption";

/// <summary>
/// The automation client.
/// </summary>
Expand Down Expand Up @@ -80,13 +90,62 @@ public IAutomationPSClient AutomationClient
[Alias("Tag")]
public IDictionary Tags { get; set; }

[Parameter(
Mandatory = false,
HelpMessage = "Generate and assign a new System Identity for this automation account")]
public SwitchParameter AssignSystemIdentity { get; set; }

[Parameter(HelpMessage = "Whether to set Automation Account KeySource to Microsoft.Automation or not.",
Mandatory = false,
ParameterSetName = AutomationServicesEncryptionParameterSet)]
public SwitchParameter AutomationServicesEncryption { get; set; }

[Parameter(HelpMessage = "Whether to set Automation Account KeySource to Microsoft.KeyVault(enable CMK) or not.",
Mandatory = false,
ParameterSetName = KeyVaultEncryptionParameterSet)]
public SwitchParameter KeyVaultEncryption { get; set; }

[Parameter(HelpMessage = "CMK KeyName",
Mandatory = true,
ParameterSetName = KeyVaultEncryptionParameterSet)]
[ValidateNotNullOrEmpty]
public string KeyName { get; set; }

[Parameter(HelpMessage = "CMK KeyVersion",
Mandatory = true,
ParameterSetName = KeyVaultEncryptionParameterSet)]
[ValidateNotNullOrEmpty]
public string KeyVersion { get; set; }

[Parameter(HelpMessage = "CMK KeyVaultUri",
Mandatory = true,
ParameterSetName = KeyVaultEncryptionParameterSet)]
[ValidateNotNullOrEmpty]
public string KeyVaultUri { get; set; }

/// <summary>
/// Execute this cmdlet.
/// </summary>
[PermissionSet(SecurityAction.Demand, Name = "FullTrust")]
public override void ExecuteCmdlet()
{
var account = this.AutomationClient.UpdateAutomationAccount(this.ResourceGroupName, this.Name, this.Plan, this.Tags);
bool addSystemId = false;
if (AssignSystemIdentity.IsPresent)
{
addSystemId = true;
}
bool enableAMK = false;
if (AutomationServicesEncryption.IsPresent)
{
enableAMK = true;
}
bool enableCMK = false;
if (ParameterSetName == KeyVaultEncryptionParameterSet)
{
enableCMK = true;
}

var account = this.AutomationClient.UpdateAutomationAccount(this.ResourceGroupName, this.Name, this.Plan, this.Tags, addSystemId, enableAMK, enableCMK, KeyName, KeyVersion, KeyVaultUri);
this.WriteObject(account);
}
}
Expand Down
36 changes: 34 additions & 2 deletions src/Automation/Automation/Common/AutomationPSClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ public AutomationAccount GetAutomationAccount(string resourceGroupName, string a
}

public AutomationAccount CreateAutomationAccount(string resourceGroupName, string automationAccountName,
string location, string plan, IDictionary tags)
string location, string plan, IDictionary tags, bool addSystemId, bool enableAMK, bool enableCMK, string KeyName, string KeyVersion, string KeyVaultUri)
{
Requires.Argument("ResourceGroupName", resourceGroupName).NotNull();
Requires.Argument("Location", location).NotNull();
Expand All @@ -165,13 +165,29 @@ public AutomationAccount CreateAutomationAccount(string resourceGroupName, strin
Tags = accountTags
};

if (addSystemId == true)
{
accountCreateOrUpdateParameters.Identity = new Identity(null, null, ResourceIdentityType.SystemAssigned);
}
if (enableAMK == true)
{
accountCreateOrUpdateParameters.Encryption = new EncryptionProperties(null, EncryptionKeySourceType.MicrosoftAutomation);
}
if (enableCMK == true)
{
accountCreateOrUpdateParameters.Encryption = new EncryptionProperties(
new KeyVaultProperties(KeyVaultUri, KeyName, KeyVersion),
EncryptionKeySourceType.MicrosoftKeyvault
);
}

var account = this.automationManagementClient.AutomationAccount.CreateOrUpdate(resourceGroupName, automationAccountName, accountCreateOrUpdateParameters);

return new AutomationAccount(resourceGroupName, account);
}

public AutomationAccount UpdateAutomationAccount(string resourceGroupName, string automationAccountName,
string plan, IDictionary tags)
string plan, IDictionary tags, bool addSystemId, bool enableAMK, bool enableCMK, string KeyName, string KeyVersion, string KeyVaultUri)
{
Requires.Argument("ResourceGroupName", resourceGroupName).NotNull();
Requires.Argument("AutomationAccountName", automationAccountName).NotNull();
Expand Down Expand Up @@ -201,6 +217,22 @@ public AutomationAccount UpdateAutomationAccount(string resourceGroupName, strin
Tags = accountTags,
};

if (addSystemId == true)
{
accountUpdateParameters.Identity = new Identity(null, null, ResourceIdentityType.SystemAssigned);
}
if (enableAMK == true)
{
accountUpdateParameters.Encryption = new EncryptionProperties(null, EncryptionKeySourceType.MicrosoftAutomation);
}
if (enableCMK == true)
{
accountUpdateParameters.Encryption = new EncryptionProperties(
new KeyVaultProperties(KeyVaultUri, KeyName, KeyVersion),
EncryptionKeySourceType.MicrosoftKeyvault
);
}

var account = this.automationManagementClient.AutomationAccount.Update(resourceGroupName, automationAccountName, accountUpdateParameters);

return new AutomationAccount(resourceGroupName, account);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ public SoftwareUpdateConfiguration CreateSoftwareUpdateConfiguration(string reso

var sucParameters = new Sdk.SoftwareUpdateConfiguration()
{
ScheduleInfo = new Sdk.ScheduleProperties()
ScheduleInfo = new Sdk.SUCScheduleProperties()
{
StartTime = configuration.ScheduleConfiguration.StartTime,
ExpiryTime = configuration.ScheduleConfiguration.ExpiryTime,
Expand Down
4 changes: 2 additions & 2 deletions src/Automation/Automation/Common/IAutomationPSClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ public interface IAutomationPSClient

AutomationAccount GetAutomationAccount(string resourceGroupName, string automationAccountName);

AutomationAccount CreateAutomationAccount(string resourceGroupName, string automationAccountName, string location, string plan, IDictionary tags);
AutomationAccount CreateAutomationAccount(string resourceGroupName, string automationAccountName, string location, string plan, IDictionary tags, bool addSystemId, bool enableAMK, bool enableCMK, string KeyName, string KeyVersion, string KeyVaultUri);

AutomationAccount UpdateAutomationAccount(string resourceGroupName, string automationAccountName, string plan, IDictionary tags);
AutomationAccount UpdateAutomationAccount(string resourceGroupName, string automationAccountName, string plan, IDictionary tags, bool addSystemId, bool enableAMK, bool enableCMK, string KeyName, string KeyVersion, string KeyVaultUri);

void DeleteAutomationAccount(string resourceGroupName, string automationAccountName);

Expand Down
13 changes: 13 additions & 0 deletions src/Automation/Automation/Model/AutomationAccount.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
// ----------------------------------------------------------------------------------

using Microsoft.Azure.Commands.Automation.Common;
using Microsoft.Azure.Management.Automation.Models;
using System;
using System.Collections;

Expand Down Expand Up @@ -67,6 +68,8 @@ public AutomationAccount(string resourceGroupName, AutomationManagement.Models.A
this.LastModifiedTime = automationAccount.LastModifiedTime.ToLocalTime();
this.State = automationAccount.State;
this.LastModifiedBy = automationAccount.LastModifiedBy;
this.Identity = automationAccount.Identity;
this.Encryption = automationAccount.Encryption;
}

/// <summary>
Expand Down Expand Up @@ -125,5 +128,15 @@ public AutomationAccount()
/// Gets or sets the tags.
/// </summary>
public Hashtable Tags { get; set; }

/// <summary>
/// Gets or sets the identity.
/// </summary>
public Identity Identity { get; private set; }

/// <summary>
/// Gets or sets the encryption properties.
/// </summary>
public EncryptionProperties Encryption { get; private set; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,6 @@ internal SoftwareUpdateRun(string resourceGroupName, string automationAccountNam

public SoftwareUpdateRunStatus Status { get; set; }

public SoftareUpdateConfigurationRunTasks Tasks { get; set; }
public SoftwareUpdateConfigurationRunTasks Tasks { get; set; }
}
}
Loading