Skip to content

Commit

Permalink
Merge branch 'sergey-entity' of https://github.com/sergey-shandar/azu…
Browse files Browse the repository at this point in the history
…re-powershell into sergey-entity
  • Loading branch information
Hovsep Mkrtchyan committed Nov 30, 2017
2 parents db0f83e + 54a26f7 commit 2f71f18
Show file tree
Hide file tree
Showing 168 changed files with 12,230 additions and 4,316 deletions.
4 changes: 2 additions & 2 deletions documentation/Using-Azure-TestFramework.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,11 @@ Instructions to manually download it are available on NuGet. However TestFramewo

## Setup prior to Record or Playback of tests

In order to Record/Playback a test, you need to setup a connection string that consists of various key/value pairs that provides information to the test environment. You have three options to set up the connection string: run the [New-TestCredential cmdlet](#new-testcredential) (recommended), run the [Set-TestEnvironment cmdlet](#set-testenvironment), or [manually set the environment variables](#manually-set-environment-variables).
In order to Record/Playback a test, you need to setup a connection string that consists of various key/value pairs that provides information to the test environment. You have three options to set up the connection string: run the [New-TestCredential cmdlet](#new-testcredential) (recommended for PowerShell development), run the [Set-TestEnvironment cmdlet](#set-testenvironment), or [manually set the environment variables](#manually-set-environment-variables).

### New-TestCredential

This cmdlet, located in Repo-Tasks, will allow you to create a credentials file (located in C:/Users/\<currentuser\>/.azure/testcredentials.json) that will be used to set the environment variable when scenario tests are run. This credentials file will be used in all future sessions unless it is deleted or the environment variables are manually set.
This cmdlet, located in Repo-Tasks, will allow you to create a credentials file (located in C:/Users/\<currentuser\>/.azure/testcredentials.json) that will be used to set the environment variable when scenario tests are run. This credentials file will be used in all future sessions unless it is deleted or the environment variables are manually set. This cmdlet is not currently available for .NET SDK development.

#### Create New Service Principal

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ public static class AzureEnvironmentConstants
/// </summary>
public const string AzureActiveDirectoryEndpoint = "https://login.microsoftonline.com/";
public const string ChinaActiveDirectoryEndpoint = "https://login.chinacloudapi.cn/";
public const string USGovernmentActiveDirectoryEndpoint = "https://login-us.microsoftonline.com/";
public const string USGovernmentActiveDirectoryEndpoint = "https://login.microsoftonline.us/";
public const string GermanActiveDirectoryEndpoint = "https://login.microsoftonline.de/";

/// <summary>
Expand Down
1 change: 1 addition & 0 deletions src/ResourceManager/AnalysisServices/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
* Remove validate set of location into dynamic lookup so that all clouds are supported.

## Version 0.5.0
* Fixed Synchronize-AzureAsInstance command to work with new AsAzure REST API for sync
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,7 @@ public class NewAnalysisServicesServer : AnalysisServicesCmdletBase
[Parameter(ValueFromPipelineByPropertyName = true, Position = 2, Mandatory = true,
HelpMessage = "Azure region where the server should be created.")]
[ValidateNotNullOrEmpty]
[ValidateSet("North Central US", "South Central US", "Central US", "West Europe", "North Europe", "West US",
"East US",
"East US 2", "Japan East", "Japan West", "Brazil South", "Southeast Asia", "East Asia", "Australia East",
"Australia Southeast", IgnoreCase = true)]
[LocationCompleter("Microsoft.AnalysisServices/servers")]
public string Location { get; set; }

[Parameter(ValueFromPipelineByPropertyName = true, Position = 3, Mandatory = true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
namespace Microsoft.Azure.Commands.ApiManagement.Commands
{
using Microsoft.Azure.Commands.ApiManagement.Models;
using ResourceManager.Common.ArgumentCompleters;
using System.Management.Automation;

[Cmdlet(VerbsCommon.Add, "AzureRmApiManagementRegion"), OutputType(typeof(PsApiManagement))]
Expand All @@ -32,7 +33,7 @@ public class AddAzureApiManagementRegion : AzureApiManagementCmdletBase
ValueFromPipelineByPropertyName = false,
Mandatory = true,
HelpMessage = "Location of the new deployment region.")]

[LocationCompleter("Microsoft.ApiManagement/service")]
[ValidateNotNullOrEmpty]
public string Location { get; set; }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ public class NewAzureApiManagement : AzureApiManagementCmdletBase
ValueFromPipelineByPropertyName = true,
Mandatory = true,
HelpMessage = "Location where want to create API Management.")]
[LocationCompleter("Microsoft.ApiManagement/service")]
[ValidateNotNullOrEmpty]
public string Location { get; set; }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ namespace Microsoft.Azure.Commands.ApiManagement.Commands
{
using Microsoft.Azure.Commands.ApiManagement.Models;
using ResourceManager.Common;
using ResourceManager.Common.ArgumentCompleters;
using System;
using System.Management.Automation;

Expand All @@ -27,6 +28,7 @@ public class NewAzureApiManagementRegion : AzureRMCmdlet
ValueFromPipelineByPropertyName = false,
Mandatory = true,
HelpMessage = "Location of the additional deployment region.")]
[LocationCompleter("Microsoft.ApiManagement/service")]
[ValidateNotNullOrEmpty]
public string Location { get; set; }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ namespace Microsoft.Azure.Commands.ApiManagement.Commands
{
using Microsoft.Azure.Commands.ApiManagement.Models;
using ResourceManager.Common;
using ResourceManager.Common.ArgumentCompleters;
using System;
using System.Management.Automation;

Expand All @@ -27,7 +28,7 @@ public class NewAzureApiManagementVirtualNetwork : AzureRMCmdlet
ValueFromPipelineByPropertyName = false,
Mandatory = true,
HelpMessage = "Location of the virtual network.")]

[LocationCompleter("Microsoft.ApiManagement/service")]
[ValidateNotNullOrEmpty]
public string Location { get; set; }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
namespace Microsoft.Azure.Commands.ApiManagement.Commands
{
using Microsoft.Azure.Commands.ApiManagement.Models;
using ResourceManager.Common.ArgumentCompleters;
using System.Management.Automation;

[Cmdlet(VerbsCommon.Remove, "AzureRmApiManagementRegion"), OutputType(typeof(PsApiManagement))]
Expand All @@ -31,6 +32,7 @@ public class RemoveAzureApiManagementRegion : AzureApiManagementCmdletBase
ValueFromPipelineByPropertyName = true,
Mandatory = true,
HelpMessage = "Location of the deployment region to remove.")]
[LocationCompleter("Microsoft.ApiManagement/service")]
[ValidateNotNullOrEmpty]
public string Location { get; set; }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ public class UpdateAzureApiManagementDeployment : AzureApiManagementCmdletBase
ValueFromPipelineByPropertyName = true,
Mandatory = true,
HelpMessage = "Location of master API Management deployment region.")]
[LocationCompleter("Microsoft.ApiManagement/service")]
public string Location { get; set; }

[Parameter(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
namespace Microsoft.Azure.Commands.ApiManagement.Commands
{
using Microsoft.Azure.Commands.ApiManagement.Models;
using ResourceManager.Common.ArgumentCompleters;
using System.Management.Automation;

[Cmdlet(VerbsData.Update, "AzureRmApiManagementRegion"), OutputType(typeof(PsApiManagement))]
Expand All @@ -32,7 +33,7 @@ public class UpdateAzureApiManagementRegion : AzureApiManagementCmdletBase
ValueFromPipelineByPropertyName = true,
Mandatory = true,
HelpMessage = "Location of the deployment region to update.")]

[LocationCompleter("Microsoft.ApiManagement/service")]
[ValidateNotNullOrEmpty]
public string Location { get; set; }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ public class NewAzureApplicationInsights : ApplicationInsightsBaseCmdlet
Position = 2,
Mandatory = true,
HelpMessage = "Application Insights Resource Location.")]
[LocationCompleter("Microsoft.Insights/components")]
[ValidateNotNullOrEmpty]
public string Location { get; set; }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ public IAutomationClient AutomationClient
/// Gets or sets the location.
/// </summary>
[Parameter(Position = 2, Mandatory = true, ValueFromPipelineByPropertyName = true, HelpMessage = "The geo region of the automation account")]
[LocationCompleter("Microsoft.Automation/automationAccounts")]
public string Location { get; set; }

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ public class NewAzureRMBackupVault : AzureBackupCmdletBase
public string Name { get; set; }

[Parameter(Position = 2, Mandatory = true, HelpMessage = AzureBackupCmdletHelpMessage.Location)]
[LocationCompleter("Microsoft.Backup/BackupVault")]
[ValidateNotNullOrEmpty]
public string Region { get; set; }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ public class NewBatchAccountCommand : BatchCmdletBase

[Parameter(Position = 1, Mandatory = true, ValueFromPipelineByPropertyName = true,
HelpMessage = "The region where the account will be created.")]
[LocationCompleter("Microsoft.Batch/batchAccounts")]
[ValidateNotNullOrEmpty]
public string Location { get; set; }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
// ----------------------------------------------------------------------------------

using Microsoft.Azure.Commands.Batch.Models;
using Microsoft.Azure.Commands.ResourceManager.Common.ArgumentCompleters;
using System.Management.Automation;
using Constants = Microsoft.Azure.Commands.Batch.Utils.Constants;

Expand All @@ -25,6 +26,7 @@ public class GetBatchLocationQuotasCommand : BatchCmdletBase
{
[Parameter(Position = 0, Mandatory = true, ValueFromPipelineByPropertyName = true,
HelpMessage = "The region to get the quotas of the subscription in the Batch Service from.")]
[LocationCompleter("Microsoft.Batch/locations/quotas")]
[ValidateNotNullOrEmpty]
public string Location { get; set; }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ public class NewAzureRmCdnEndpoint : AzureCdnCmdletBase
public PSProfile CdnProfile { get; set; }

[Parameter(Mandatory = true, HelpMessage = "The location of the CDN endpoint.", ParameterSetName = FieldsParameterSet)]
[LocationCompleter("Microsoft.Cdn/profiles/endpoints")]
[ValidateNotNullOrEmpty]
public string Location { get; set; }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ public class NewAzureRmCdnProfile : AzureCdnCmdletBase
/// The location in which to create the profile.
/// </summary>
[Parameter(Mandatory = true, HelpMessage = "The location in which to create the CDN profile.")]
[LocationCompleter("Microsoft.Cdn/profiles")]
[ValidateNotNullOrEmpty]
public string Location { get; set; }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ public class NewAzureCognitiveServicesAccountCommand : CognitiveServicesAccountB
Mandatory = true,
ValueFromPipelineByPropertyName = true,
HelpMessage = "Cognitive Services Account Location.")]
[LocationCompleter("Microsoft.CognitiveServices/accounts")]
[ValidateNotNullOrEmpty]
public string Location { get; set; }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@
<Compile Include="StateOperationContext.cs" />
<Compile Include="Compute\ComputeStrategy.cs" />
<Compile Include="Compute\VirtualMachineStrategy.cs" />
<Compile Include="SyncTaskScheduler.cs" />
<Compile Include="UpdateStateExtensions.cs" />
<Compile Include="CreateOrUpdateAsyncParams.cs" />
<Compile Include="EntityConfigExtensions.cs" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,13 @@
// limitations under the License.
// ----------------------------------------------------------------------------------

using System.Threading.Tasks;

namespace Microsoft.Azure.Commands.Common.Strategies
{
public interface IShouldProcess
{
bool ShouldCreate<TModel>(ResourceConfig<TModel> config, TModel model)
Task<bool> ShouldCreate<TModel>(ResourceConfig<TModel> config, TModel model)
where TModel : class;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
// ----------------------------------------------------------------------------------
//
// 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.Threading;
using System.Threading.Tasks;

namespace Microsoft.Azure.Commands.Common.Strategies
{
public sealed class SyncTaskScheduler
{
readonly ConcurrentQueue<Task> _Tasks = new ConcurrentQueue<Task>();

public async Task<T> Invoke<T>(Func<T> func)
{
var task = new Task<T>(func);
_Tasks.Enqueue(task);
// note: don't use 'await' keyword for the 'task' because it may start the task in
// another thread.
while (!task.IsCompleted)
{
await Task.Yield();
}
return task.Result;
}

public void BeginInvoke(Action action)
=> _Tasks.Enqueue(new Task(action));

public void Wait(Task task)
{
while (!task.IsCompleted)
{
HandleActions();
Thread.Yield();
}
HandleActions();
}

void HandleActions()
{
Task task;
while (_Tasks.TryDequeue(out task))
{
task.RunSynchronously();
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ await _OperationContext.GetOrAdd(
.Select(UpdateStateAsyncDispatch);
await Task.WhenAll(tasks);
// call the CreateOrUpdateAsync function for the resource.
if (_ShouldProcess.ShouldCreate(config, model))
if (await _ShouldProcess.ShouldCreate(config, model))
{
_ProgressReport.Report(config, 0.0);
var result = await config.CreateOrUpdateAsync(
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
// ----------------------------------------------------------------------------------
//
// 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.
// ----------------------------------------------------------------------------------

namespace Microsoft.Azure.Commands.ResourceManager.Common.ArgumentCompleters
{
public class PSArgumentCompleterAttribute : PSCompleterBaseAttribute
{
private static string[] _argumentList;
public PSArgumentCompleterAttribute(params string[] argumentList)
{
_argumentList = argumentList;
}

public override string[] GetCompleterValues()
{
return _argumentList;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@
</ItemGroup>
<ItemGroup>
<Compile Include="AccessTokenExtensions.cs" />
<Compile Include="ArgumentCompleters\PSArgumentCompleter.cs" />
<Compile Include="ArgumentCompleters\PSCompleterBase.cs" />
<Compile Include="AzureRmCmdlet.cs" />
<Compile Include="Generated\DeploymentOperations.cs" />
Expand Down
1 change: 1 addition & 0 deletions src/ResourceManager/Compute/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
* Update Disable-AzureRmVmssDiskEncryption to fix issue https://github.com/Azure/azure-powershell/issues/5038

## Version 4.0.1
* Fixed assembly loading issue that caused some cmdlets to fail when executing
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,13 @@ public void TestDisableVirtualMachineScaleSetDiskEncryption()
ComputeTestController.NewInstance.RunPsTest("Test-DisableVirtualMachineScaleSetDiskEncryption");
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestDisableVirtualMachineScaleSetDiskEncryption2()
{
ComputeTestController.NewInstance.RunPsTest("Test-DisableVirtualMachineScaleSetDiskEncryption2");
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestGetVirtualMachineScaleSetDiskEncryptionStatus()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,29 @@ function Test-DisableVirtualMachineScaleSetDiskEncryption
}
}

<#
.SYNOPSIS
Test Virtual Machine Scale Set Disk Encryption Extension
#>
function Test-DisableVirtualMachineScaleSetDiskEncryption2
{
try
{
# Common
$loc = 'westcentralus';
$rgname = "hyleevmssdetest2"
$vmssName = 'vmss' + $rgname;

$result = Disable-AzureRmVmssDiskEncryption -ResourceGroupName $rgname -VMScaleSetName $vmssName -Force;
$result_string = $result | Out-String;
}
finally
{
# Cleanup
Clean-ResourceGroup $rgname
}
}

<#
.SYNOPSIS
Test Get Virtual Machine Scale Set Disk Encryption Status for VMSS without encryption
Expand Down
Loading

0 comments on commit 2f71f18

Please sign in to comment.