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

Merge main into preview branch #24591

Merged
merged 12 commits into from
Apr 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
  •  
  •  
  •  
8 changes: 1 addition & 7 deletions build.proj
Original file line number Diff line number Diff line change
Expand Up @@ -256,13 +256,7 @@
<Exec Command="$(PowerShellCoreCommandPrefix) &quot;. $(RepoTools)CleanupBuild.ps1 -BuildConfig $(Configuration) -GenerateDocumentationFile $(GenerateDocumentationFile) &quot;" />

<Error Condition="'$(NuGetKey)' == ''" Text="You must provide the NuGetKey parameter to the build: /p:NuGetKey=YOUR_PUBLISHING_KEY" />
<Exec Command="$(PowerShellCoreCommandPrefix) &quot;. $(RepoTools)PublishModules.ps1 -TargetBuild $(TargetBuild) -IsNetCore:$$(NetCore) -BuildConfig $(Configuration) -Scope $(Scope) -ApiKey $(NuGetKey) -RepositoryLocation /&quot;$(NuGetPublishingSource)/&quot;&quot; -NugetExe $(NuGetCommand)" />
</Target>

<Target Name="BuildInstaller" AfterTargets="Publish" Condition="('$(Scope)' == 'All' or '$(Scope)' == 'Latest' or '$(Scope)' == 'Netcore')">
<Exec Command="$(PowerShellCoreCommandPrefix) &quot;. Register-PSRepository -Name MSIcreationrepository -SourceLocation $(RepoArtifacts) -InstallationPolicy Trusted &quot;" />
<Exec Command="$(PowerShellCoreCommandPrefix) &quot;. $(RepoRoot)/setup/generate.ps1 -repository MSIcreationrepository &quot;" />
<Exec Command="$(PowerShellCoreCommandPrefix) &quot;. Unregister-PSRepository -Name MSIcreationrepository &quot;" />
<Exec Command="$(PowerShellCoreCommandPrefix) &quot;. $(RepoTools)PublishModules.ps1 -TargetBuild $(TargetBuild) -IsNetCore:$$(NetCore) -BuildConfig $(Configuration) -Scope $(Scope) -ApiKey $(NuGetKey) -RepositoryLocation &quot;$(NuGetPublishingSource)&quot;&quot; -NugetExe $(NuGetCommand)" />
</Target>

<Target Name="BuildImages">
Expand Down
6 changes: 6 additions & 0 deletions documentation/breaking-changes/upcoming-breaking-changes.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Upcoming breaking changes in Azure PowerShell

## General

- In the upcoming major release of Azure PowerShell (Az 12.0.0), the `DisplaySecretsWarning` configuration option will be activated by default. A warning message will be shown when secrets are detected in the output of a cmdlet.
For additional context, please visit [Hardening your defense in depth with secrets awareness in Azure command line tools](https://techcommunity.microsoft.com/t5/azure-tools-blog/hardening-your-defense-in-depth-with-secrets-awareness-in-azure/ba-p/4049883).
For command usage details, please refer to [Protect secrets in Azure PowerShell](https://go.microsoft.com/fwlink/?linkid=2258844).

## Az.Accounts

### `Clear-AzConfig`
Expand Down
2 changes: 1 addition & 1 deletion src/Batch/Batch.Test/Batch.Test.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Azure.Batch" Version="16.0.0" />
<PackageReference Include="Microsoft.Azure.Batch" Version="16.2.0" />
<PackageReference Include="Microsoft.Azure.Management.Batch" Version="15.0.0" />
<PackageReference Include="WindowsAzure.Storage" Version="9.3.0" />
</ItemGroup>
Expand Down
19 changes: 13 additions & 6 deletions src/Batch/Batch.Test/Pools/GetBatchPoolNodeCountsCommandTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,8 @@ public void WhenGetBatchPoolNodeCountsCommandIsCalledWithoutFilter_ShouldReturnA
unknown: 11,
unusable: 12,
waitingForStartTask: 13,
total: 91), // Total
total: 91,
upgradingOS: 1), // Total
LowPriority = new ProxyModels.NodeCounts(
creating: 1,
idle: 2,
Expand All @@ -89,7 +90,8 @@ public void WhenGetBatchPoolNodeCountsCommandIsCalledWithoutFilter_ShouldReturnA
unknown: 11,
unusable: 12,
waitingForStartTask: 13,
total: 91), // Total
total: 91,
upgradingOS: 1), // Total
};

var poolNodeCounts2 = new ProxyModels.PoolNodeCounts()
Expand All @@ -109,7 +111,8 @@ public void WhenGetBatchPoolNodeCountsCommandIsCalledWithoutFilter_ShouldReturnA
unknown: 21,
unusable: 22,
waitingForStartTask: 23,
total: 221), // Total
total: 221,
upgradingOS: 1), // Total
LowPriority = new ProxyModels.NodeCounts(
creating: 11,
idle: 12,
Expand All @@ -124,7 +127,8 @@ public void WhenGetBatchPoolNodeCountsCommandIsCalledWithoutFilter_ShouldReturnA
unknown: 21,
unusable: 22,
waitingForStartTask: 23,
total: 221), // Total
total: 221,
upgradingOS: 1), // Total
};

// Simulate node state counts for two pools are returned
Expand Down Expand Up @@ -246,6 +250,7 @@ public void WhenPSNodeCountsFormatObjectIsCalled_ShouldSerlializeNodeCountsToStr
const int unusable = 12;
const int waitingForStartTask = 13;
const int total = 91;
const int upgradingOS = 1;

var poolNodeCounts = new ProxyModels.PoolNodeCounts()
{
Expand All @@ -265,7 +270,8 @@ public void WhenPSNodeCountsFormatObjectIsCalled_ShouldSerlializeNodeCountsToStr
unknown: unknown,
unusable: unusable,
waitingForStartTask: waitingForStartTask,
total: total), // Total
total: total,
upgradingOS: upgradingOS), // Total
// all zero properties
LowPriority = new ProxyModels.NodeCounts(
creating: 0,
Expand All @@ -281,7 +287,8 @@ public void WhenPSNodeCountsFormatObjectIsCalled_ShouldSerlializeNodeCountsToStr
unknown: 0,
unusable: 0,
waitingForStartTask: 0,
total: 0), // Total
total: 0,
upgradingOS: 0), // Total
};

BatchAccountContext context = BatchTestHelpers.CreateBatchContextWithKeys();
Expand Down
16 changes: 16 additions & 0 deletions src/Batch/Batch.Test/Pools/NewBatchPoolCommandTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
using System.Management.Automation;
using Xunit;
using BatchClient = Microsoft.Azure.Commands.Batch.Models.BatchClient;
using Microsoft.Azure.Commands.Common.Strategies;

namespace Microsoft.Azure.Commands.Batch.Test.Pools
{
Expand Down Expand Up @@ -95,18 +96,27 @@ public void NewBatchPoolParametersGetPassedToRequestTest()
cmdlet.InterComputeNodeCommunicationEnabled = true;
cmdlet.TaskSlotsPerNode = 4;
cmdlet.Metadata = new Dictionary<string, string> { { "meta1", "value1" } };
cmdlet.ResourceTag = new Dictionary<string, string> { { "resource1", "value1" } };
cmdlet.ResizeTimeout = TimeSpan.FromMinutes(20);
cmdlet.StartTask = new PSStartTask("cmd /c echo start task");
cmdlet.TargetDedicatedComputeNodes = 3;
cmdlet.TargetLowPriorityComputeNodes = 2;
cmdlet.TargetNodeCommunicationMode = Microsoft.Azure.Batch.Common.NodeCommunicationMode.Simplified;
cmdlet.TaskSchedulingPolicy = new PSTaskSchedulingPolicy(Azure.Batch.Common.ComputeNodeFillType.Spread);
cmdlet.UpgradePolicy = new PSUpgradePolicy(Azure.Batch.Common.UpgradeMode.Automatic);
cmdlet.VirtualMachineConfiguration = new PSVirtualMachineConfiguration(new PSImageReference("offer", "publisher", "sku"), "node agent");
cmdlet.VirtualMachineConfiguration.Extensions = new List<PSVMExtension>
{
new PSVMExtension("sample-extension", "sample-publisher", "sample-type") { EnableAutomaticUpgrade = true },
};
cmdlet.VirtualMachineConfiguration.ContainerConfiguration = new PSContainerConfiguration() { Type = "CriCompatible" };
cmdlet.VirtualMachineConfiguration.SecurityProfile = new PSSecurityProfile();
cmdlet.VirtualMachineConfiguration.SecurityProfile.SecurityType = Azure.Batch.Common.SecurityTypes.TrustedLaunch;
cmdlet.VirtualMachineConfiguration.SecurityProfile.EncryptionAtHost = true;
cmdlet.VirtualMachineConfiguration.SecurityProfile.UefiSettings = new PSUefiSettings();
cmdlet.VirtualMachineConfiguration.SecurityProfile.UefiSettings.SecureBootEnabled = true;
cmdlet.VirtualMachineConfiguration.SecurityProfile.UefiSettings.VTpmEnabled = true;
cmdlet.VirtualMachineConfiguration.ServiceArtifactReference = new PSServiceArtifactReference("testid");
cmdlet.VirtualMachineSize = "small";
cmdlet.MountConfiguration = new[] {
new PSMountConfiguration(new PSAzureBlobFileSystemConfiguration("foo", "bar", "baz", AzureStorageAuthenticationKey.FromAccountKey("abc"))),
Expand Down Expand Up @@ -141,21 +151,27 @@ public void NewBatchPoolParametersGetPassedToRequestTest()
Assert.Equal(cmdlet.TaskSlotsPerNode, requestParameters.TaskSlotsPerNode);
Assert.Equal(cmdlet.Metadata.Count, requestParameters.Metadata.Count);
Assert.Equal(cmdlet.Metadata["meta1"], requestParameters.Metadata[0].Value);
Assert.Equal(cmdlet.ResourceTag.Count, requestParameters.ResourceTags.Count);
Assert.Equal(cmdlet.ResourceTag["resource1"], requestParameters.ResourceTags["resource1"]);
Assert.Equal(cmdlet.ResizeTimeout, requestParameters.ResizeTimeout);
Assert.Equal(cmdlet.StartTask.CommandLine, requestParameters.StartTask.CommandLine);
Assert.Equal(cmdlet.TargetDedicatedComputeNodes, requestParameters.TargetDedicatedNodes);
Assert.Equal(cmdlet.TargetLowPriorityComputeNodes, requestParameters.TargetLowPriorityNodes);
Assert.Equal(cmdlet.TaskSchedulingPolicy.ComputeNodeFillType.ToString(), requestParameters.TaskSchedulingPolicy.NodeFillType.ToString());
Assert.Equal(cmdlet.UpgradePolicy.Mode.ToString(), requestParameters.UpgradePolicy.Mode.ToString());
Assert.Equal(cmdlet.TargetNodeCommunicationMode.ToString(), NodeCommunicationMode.Simplified.ToString());
Assert.Equal(cmdlet.VirtualMachineConfiguration.NodeAgentSkuId, requestParameters.VirtualMachineConfiguration.NodeAgentSKUId);
Assert.Equal(cmdlet.VirtualMachineConfiguration.ImageReference.Publisher, requestParameters.VirtualMachineConfiguration.ImageReference.Publisher);
Assert.Equal(cmdlet.VirtualMachineConfiguration.ImageReference.Offer, requestParameters.VirtualMachineConfiguration.ImageReference.Offer);
Assert.Equal(cmdlet.VirtualMachineConfiguration.ImageReference.Sku, requestParameters.VirtualMachineConfiguration.ImageReference.Sku);
Assert.Equal(cmdlet.VirtualMachineConfiguration.SecurityProfile.SecurityType.ToString(), requestParameters.VirtualMachineConfiguration.SecurityProfile.SecurityType.ToString());
Assert.Equal(cmdlet.VirtualMachineConfiguration.SecurityProfile.UefiSettings.SecureBootEnabled, requestParameters.VirtualMachineConfiguration.SecurityProfile.UefiSettings.SecureBootEnabled);
Assert.Equal(cmdlet.VirtualMachineConfiguration.Extensions[0].Name, requestParameters.VirtualMachineConfiguration.Extensions[0].Name);
Assert.Equal(cmdlet.VirtualMachineConfiguration.Extensions[0].Publisher, requestParameters.VirtualMachineConfiguration.Extensions[0].Publisher);
Assert.Equal(cmdlet.VirtualMachineConfiguration.Extensions[0].Type, requestParameters.VirtualMachineConfiguration.Extensions[0].Type);
Assert.Equal(cmdlet.VirtualMachineConfiguration.Extensions[0].EnableAutomaticUpgrade, requestParameters.VirtualMachineConfiguration.Extensions[0].EnableAutomaticUpgrade);
Assert.Equal(cmdlet.VirtualMachineConfiguration.ContainerConfiguration.Type, requestParameters.VirtualMachineConfiguration.ContainerConfiguration.Type);
Assert.Equal(cmdlet.VirtualMachineConfiguration.ServiceArtifactReference.Id, requestParameters.VirtualMachineConfiguration.ServiceArtifactReference.Id);
Assert.Equal(cmdlet.VirtualMachineSize, requestParameters.VmSize);
Assert.Equal(cmdlet.MountConfiguration[0].AzureBlobFileSystemConfiguration.AccountName, requestParameters.MountConfiguration[0].AzureBlobFileSystemConfiguration.AccountName);
Assert.Equal(cmdlet.MountConfiguration[0].AzureBlobFileSystemConfiguration.AccountKey, requestParameters.MountConfiguration[0].AzureBlobFileSystemConfiguration.AccountKey);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ public void TestUpdatePoolWithApplicationPackage()
{
context = new ScenarioTestContext();
ScenarioTestHelpers.CreateApplicationPackage(this, context, id, version, filePath);
ScenarioTestHelpers.CreateTestPool(this, context, poolId, targetDedicated: 1, targetLowPriority: 0);
ScenarioTestHelpers.CreateTestPoolVirtualMachine(this, context, poolId, targetDedicated: 1, targetLowPriority: 0);
},
() =>
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,11 +79,14 @@ function Test-CreatePoolWithApplicationPackage
$apr = [Microsoft.Azure.Commands.Batch.Models.PSApplicationPackageReference[]]$apr1

# Create a pool with application package reference
$osFamily = "4"
$targetOSVersion = "*"
$paasConfiguration = New-Object Microsoft.Azure.Commands.Batch.Models.PSCloudServiceConfiguration -ArgumentList @($osFamily, $targetOSVersion)

New-AzBatchPool -Id $poolId -CloudServiceConfiguration $paasConfiguration -TargetDedicated 3 -VirtualMachineSize "small" -BatchContext $context -ApplicationPackageReferences $apr
$vmSize = "standard_d1_v2"
$publisher = "microsoft-azure-batch"
$offer = "ubuntu-server-container"
$osSKU = "20-04-lts"
$nodeAgent = "batch.node.ubuntu 20.04"
$imageRef = New-Object Microsoft.Azure.Commands.Batch.Models.PSImageReference -ArgumentList @($offer, $publisher, $osSKU)
$iaasConfiguration = New-Object Microsoft.Azure.Commands.Batch.Models.PSVirtualMachineConfiguration -ArgumentList @($imageRef, $nodeAgent)
New-AzBatchPool -Id $poolId -VirtualMachineSize "standard_d1_v2" -TargetDedicated 3 -VirtualMachineConfiguration $iaasConfiguration -BatchContext $context -ApplicationPackageReferences $apr
}
finally
{
Expand Down
2 changes: 1 addition & 1 deletion src/Batch/Batch.Test/ScenarioTests/CertificateTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public void TestCancelCertificateDelete()
certRef.ThumbprintAlgorithm = BatchTestHelpers.TestCertificateAlgorithm;
certRef.Thumbprint = thumbprint;
certRef.Visibility = CertificateVisibility.Task;
ScenarioTestHelpers.CreateTestPool(this, context, poolId, targetDedicated: 0, targetLowPriority: 0, certReference: certRef);
ScenarioTestHelpers.CreateTestPoolVirtualMachine(this, context, poolId, targetDedicated: 0, targetLowPriority: 0, certReference: certRef);
ScenarioTestHelpers.DeleteTestCertificate(this, context, BatchTestHelpers.TestCertificateAlgorithm, thumbprint);
ScenarioTestHelpers.WaitForCertificateToFailDeletion(this, context, BatchTestHelpers.TestCertificateAlgorithm, thumbprint);
},
Expand Down
43 changes: 38 additions & 5 deletions src/Batch/Batch.Test/ScenarioTests/ComputeNodeTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@
// limitations under the License.
// ----------------------------------------------------------------------------------

using Microsoft.Azure.Batch;
using Microsoft.WindowsAzure.Commands.ScenarioTest;
using System;
using Xunit;

namespace Microsoft.Azure.Commands.Batch.Test.ScenarioTests
Expand All @@ -33,12 +35,28 @@ public void TestRemoveComputeNodes()
{
BatchAccountContext context = null;
string removeNodePoolId = "removenodepool";
UpgradePolicy upgradePolicy = new UpgradePolicy(Azure.Batch.Common.UpgradeMode.Automatic);
upgradePolicy.AutomaticOSUpgradePolicy = new AutomaticOSUpgradePolicy();
upgradePolicy.AutomaticOSUpgradePolicy.DisableAutomaticRollback = true;
upgradePolicy.AutomaticOSUpgradePolicy.EnableAutomaticOSUpgrade = true;
upgradePolicy.AutomaticOSUpgradePolicy.UseRollingUpgradePolicy = true;
upgradePolicy.AutomaticOSUpgradePolicy.OsRollingUpgradeDeferral = true;

upgradePolicy.RollingUpgradePolicy = new RollingUpgradePolicy();
upgradePolicy.RollingUpgradePolicy.EnableCrossZoneUpgrade = true;
upgradePolicy.RollingUpgradePolicy.MaxBatchInstancePercent = 20;
upgradePolicy.RollingUpgradePolicy.MaxUnhealthyUpgradedInstancePercent = 20;
upgradePolicy.RollingUpgradePolicy.MaxUnhealthyInstancePercent = 20;
upgradePolicy.RollingUpgradePolicy.PauseTimeBetweenBatches = TimeSpan.FromSeconds(5);
upgradePolicy.RollingUpgradePolicy.PrioritizeUnhealthyInstances = false;
upgradePolicy.RollingUpgradePolicy.RollbackFailedInstancesOnPolicyBreach = false;

TestRunner.RunTestScript(
null,
mockContext =>
{
context = new ScenarioTestContext();
ScenarioTestHelpers.CreateTestPool(this, context, removeNodePoolId, targetDedicated: 2, targetLowPriority: 0);
ScenarioTestHelpers.CreateTestPoolVirtualMachine(this, context, removeNodePoolId, targetDedicated: 2, targetLowPriority: 0, upgradePolicy: upgradePolicy);
ScenarioTestHelpers.WaitForSteadyPoolAllocation(this, context, removeNodePoolId);
},
() =>
Expand All @@ -53,10 +71,15 @@ public void TestRemoveComputeNodes()
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestRebootAndReimageComputeNode()
{
BatchAccountContext context = null;
string poolId = "rebootandreimagenodepool";

TestRunner.RunTestScript(
mockContext =>
{
_ = new ScenarioTestContext();
context = new ScenarioTestContext();
ScenarioTestHelpers.CreateTestPoolVirtualMachine(this, context, poolId, targetDedicated: 2, targetLowPriority: 0);
ScenarioTestHelpers.WaitForSteadyPoolAllocation(this, context, poolId);
},
$"Test-RebootAndReimageComputeNode '{poolId}'"
);
Expand All @@ -66,10 +89,15 @@ public void TestRebootAndReimageComputeNode()
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestDisableAndEnableComputeNodeScheduling()
{
BatchAccountContext context = null;
string poolId = "disableandenablenodepool";

TestRunner.RunTestScript(
mockContext =>
{
_ = new ScenarioTestContext();
context = new ScenarioTestContext();
ScenarioTestHelpers.CreateTestPoolVirtualMachine(this, context, poolId, targetDedicated: 2, targetLowPriority: 0);
ScenarioTestHelpers.WaitForSteadyPoolAllocation(this, context, poolId);
},
$"Test-DisableAndEnableComputeNodeScheduling '{poolId}'"
);
Expand All @@ -79,12 +107,17 @@ public void TestDisableAndEnableComputeNodeScheduling()
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestGetComputeNodeRemoteLoginSettings()
{
BatchAccountContext context = null;
string poolId = "noderemoteloginpool";

TestRunner.RunTestScript(
mockContext =>
{
_ = new ScenarioTestContext();
context = new ScenarioTestContext();
ScenarioTestHelpers.CreateTestPoolVirtualMachine(this, context, poolId, targetDedicated: 2, targetLowPriority: 0);
ScenarioTestHelpers.WaitForSteadyPoolAllocation(this, context, poolId);
},
$"Test-GetRemoteLoginSettings '{iaasPoolId}'"
$"Test-GetRemoteLoginSettings '{poolId}'"
);
}
}
Expand Down
Loading
Loading