From 4e58d81ad6949c2da468bf37fd4c4007be7579cc Mon Sep 17 00:00:00 2001 From: Sergey Shandar Date: Wed, 15 Nov 2017 18:22:58 -0800 Subject: [PATCH] No experiments. --- .../Azure.Experiments/Azure.Experiments.sln | 31 - .../Azure.Experiments/AsyncOperation.cs | 47 - .../Azure.Experiments.csproj | 21 - .../Compute/ComputePolicy.cs | 24 - .../Compute/VirtualMachinePolicy.cs | 66 - .../Azure.Experiments/Context.cs | 38 - .../CreateOrUpdateAsyncOperation.cs | 64 - .../CreateOrUpdateAsyncParams.cs | 43 - .../Azure.Experiments/EnumerableEx.cs | 11 - .../Azure.Experiments/GetAsyncOperation.cs | 58 - .../Azure.Experiments/GetAsyncParams.cs | 37 - .../Azure.Experiments/IClient.cs | 12 - .../Azure.Experiments/IResourceConfig.cs | 26 - .../Azure.Experiments/IResourcePolicy.cs | 6 - .../Azure.Experiments/IState.cs | 8 - .../Azure.Experiments/NestedResourceConfig.cs | 49 - .../Azure.Experiments/NestedResourcePolicy.cs | 38 - .../Network/NetworkInterfacePolicy.cs | 48 - .../Network/NetworkPolicy.cs | 24 - .../Network/NetworkSecurityGroupPolicy.cs | 22 - .../Network/PublicIPAddressPolicy.cs | 22 - .../Azure.Experiments/Network/SubnetPolicy.cs | 40 - .../Network/VirtualNetworkPolicy.cs | 33 - .../Azure.Experiments/Old/AzureObject.cs | 128 -- .../Old/Compute/ComputePolicy.cs | 11 - .../Old/Compute/VirtualMachineObject.cs | 87 -- .../Azure.Experiments/Old/Context.cs | 14 - .../Old/DependencyLocation.cs | 18 - .../Azure.Experiments/Old/IInfoPolicy.cs | 7 - .../Old/Network/NetworkInterfaceObject.cs | 58 - .../Old/Network/NetworkObject.cs | 20 - .../Old/Network/NetworkPolicy.cs | 11 - .../Old/Network/NetworkSecurityGroup.cs | 33 - .../Old/Network/PublicIpAddressObject.cs | 33 - .../Old/Network/SubnetObject.cs | 41 - .../Old/Network/SubnetPolicy.cs | 9 - .../Old/Network/VirtualNetworkObject.cs | 44 - .../Old/ResourceGroupObject.cs | 34 - .../Old/ResourceGroupPolicy.cs | 10 - .../Azure.Experiments/Old/ResourceObject.cs | 26 - .../Azure.Experiments/Parameters.cs | 62 - .../Azure.Experiments/ResourceConfig.cs | 81 -- .../ResourceManager/ResourceGroupPolicy.cs | 21 - .../Azure.Experiments/ResourceName.cs | 15 - .../Azure.Experiments/ResourcePolicy.cs | 73 - .../Azure.Experiments/State.cs | 22 - .../Azure.Experiments/StateLocation.cs | 74 -- .../Azure.Experiments/readme.md | 54 - .../Tests/AuthenticationResponse.cs | 8 - experiments/Azure.Experiments/Tests/Client.cs | 44 - .../Azure.Experiments/Tests/Configuration.cs | 10 - .../Azure.Experiments/Tests/Credentials.cs | 16 - .../Azure.Experiments/Tests/KeyValuePair.cs | 10 - .../Tests/NetworkInterfaceTest.cs | 34 - .../Tests/NetworkSecurityGroupTest.cs | 29 - .../Tests/Old/ComputeTest.cs | 102 -- .../Azure.Experiments/Tests/Old/UnitTests.cs | 82 -- .../Tests/PublicIPAddressTest.cs | 29 - .../Tests/ResourceGroupTest.cs | 57 - .../Azure.Experiments/Tests/SubnetTest.cs | 30 - .../Azure.Experiments/Tests/Tests.csproj | 23 - .../Azure.Experiments/Tests/TokenProvider.cs | 54 - .../Tests/VirtualMachineTest.cs | 36 - .../Tests/VirtualNetworkTest.cs | 30 - .../AzureRM.Compute.Experiments-help.xml | 385 ------ .../AzureRM.Compute.Experiments.Tests.ps1 | 53 - .../AzureRM.Compute.Experiments.psd1 | 126 -- .../AzureRM.Compute.Experiments.psm1 | 749 ----------- .../AzureRM.Compute.Experiments.test.ps1 | 9 - experiments/Compute.Experiments/copy-dev.ps1 | 7 - .../help/AzureRM.Compute.Experiments.md | 16 - .../Compute.Experiments/help/New-AzVm.md | 338 ----- .../Compute.Experiments/publish-dev.ps1 | 15 - .../AzureRM.Websites.Experiments.Tests.ps1 | 1176 ----------------- ...AzureRM.Websites.Experiments.format.ps1xml | 44 - .../AzureRM.Websites.Experiments.psd1 | Bin 8684 -> 0 bytes .../AzureRM.Websites.Experiments.psm1 | 1055 --------------- .../CustomWebSiteManagementClient.cs | 510 ------- .../Websites.Experiments/MSSharedLibKey.snk | Bin 160 -> 0 bytes ...Azure.Commands.Websites.Experiments.csproj | 94 -- ...ft.Azure.Commands.Websites.Experiments.sln | 22 - .../Models/ResourceNameAvailability.cs | 78 -- .../Models/ResourceNameAvailabilityRequest.cs | 78 -- .../Properties/AssemblyInfo.cs | 36 - .../Websites.Experiments/Run-UnitTests.ps1 | 5 - .../AzureRM.Websites.Experiments-help.xml | 410 ------ .../Websites.Experiments/help/New-AzWebApp.md | 190 --- .../help/New-AzWebAppGrayParam.md | 185 --- .../Websites.Experiments/packages.config | 6 - 89 files changed, 7935 deletions(-) delete mode 100644 experiments/Azure.Experiments/Azure.Experiments.sln delete mode 100644 experiments/Azure.Experiments/Azure.Experiments/AsyncOperation.cs delete mode 100644 experiments/Azure.Experiments/Azure.Experiments/Azure.Experiments.csproj delete mode 100644 experiments/Azure.Experiments/Azure.Experiments/Compute/ComputePolicy.cs delete mode 100644 experiments/Azure.Experiments/Azure.Experiments/Compute/VirtualMachinePolicy.cs delete mode 100644 experiments/Azure.Experiments/Azure.Experiments/Context.cs delete mode 100644 experiments/Azure.Experiments/Azure.Experiments/CreateOrUpdateAsyncOperation.cs delete mode 100644 experiments/Azure.Experiments/Azure.Experiments/CreateOrUpdateAsyncParams.cs delete mode 100644 experiments/Azure.Experiments/Azure.Experiments/EnumerableEx.cs delete mode 100644 experiments/Azure.Experiments/Azure.Experiments/GetAsyncOperation.cs delete mode 100644 experiments/Azure.Experiments/Azure.Experiments/GetAsyncParams.cs delete mode 100644 experiments/Azure.Experiments/Azure.Experiments/IClient.cs delete mode 100644 experiments/Azure.Experiments/Azure.Experiments/IResourceConfig.cs delete mode 100644 experiments/Azure.Experiments/Azure.Experiments/IResourcePolicy.cs delete mode 100644 experiments/Azure.Experiments/Azure.Experiments/IState.cs delete mode 100644 experiments/Azure.Experiments/Azure.Experiments/NestedResourceConfig.cs delete mode 100644 experiments/Azure.Experiments/Azure.Experiments/NestedResourcePolicy.cs delete mode 100644 experiments/Azure.Experiments/Azure.Experiments/Network/NetworkInterfacePolicy.cs delete mode 100644 experiments/Azure.Experiments/Azure.Experiments/Network/NetworkPolicy.cs delete mode 100644 experiments/Azure.Experiments/Azure.Experiments/Network/NetworkSecurityGroupPolicy.cs delete mode 100644 experiments/Azure.Experiments/Azure.Experiments/Network/PublicIPAddressPolicy.cs delete mode 100644 experiments/Azure.Experiments/Azure.Experiments/Network/SubnetPolicy.cs delete mode 100644 experiments/Azure.Experiments/Azure.Experiments/Network/VirtualNetworkPolicy.cs delete mode 100644 experiments/Azure.Experiments/Azure.Experiments/Old/AzureObject.cs delete mode 100644 experiments/Azure.Experiments/Azure.Experiments/Old/Compute/ComputePolicy.cs delete mode 100644 experiments/Azure.Experiments/Azure.Experiments/Old/Compute/VirtualMachineObject.cs delete mode 100644 experiments/Azure.Experiments/Azure.Experiments/Old/Context.cs delete mode 100644 experiments/Azure.Experiments/Azure.Experiments/Old/DependencyLocation.cs delete mode 100644 experiments/Azure.Experiments/Azure.Experiments/Old/IInfoPolicy.cs delete mode 100644 experiments/Azure.Experiments/Azure.Experiments/Old/Network/NetworkInterfaceObject.cs delete mode 100644 experiments/Azure.Experiments/Azure.Experiments/Old/Network/NetworkObject.cs delete mode 100644 experiments/Azure.Experiments/Azure.Experiments/Old/Network/NetworkPolicy.cs delete mode 100644 experiments/Azure.Experiments/Azure.Experiments/Old/Network/NetworkSecurityGroup.cs delete mode 100644 experiments/Azure.Experiments/Azure.Experiments/Old/Network/PublicIpAddressObject.cs delete mode 100644 experiments/Azure.Experiments/Azure.Experiments/Old/Network/SubnetObject.cs delete mode 100644 experiments/Azure.Experiments/Azure.Experiments/Old/Network/SubnetPolicy.cs delete mode 100644 experiments/Azure.Experiments/Azure.Experiments/Old/Network/VirtualNetworkObject.cs delete mode 100644 experiments/Azure.Experiments/Azure.Experiments/Old/ResourceGroupObject.cs delete mode 100644 experiments/Azure.Experiments/Azure.Experiments/Old/ResourceGroupPolicy.cs delete mode 100644 experiments/Azure.Experiments/Azure.Experiments/Old/ResourceObject.cs delete mode 100644 experiments/Azure.Experiments/Azure.Experiments/Parameters.cs delete mode 100644 experiments/Azure.Experiments/Azure.Experiments/ResourceConfig.cs delete mode 100644 experiments/Azure.Experiments/Azure.Experiments/ResourceManager/ResourceGroupPolicy.cs delete mode 100644 experiments/Azure.Experiments/Azure.Experiments/ResourceName.cs delete mode 100644 experiments/Azure.Experiments/Azure.Experiments/ResourcePolicy.cs delete mode 100644 experiments/Azure.Experiments/Azure.Experiments/State.cs delete mode 100644 experiments/Azure.Experiments/Azure.Experiments/StateLocation.cs delete mode 100644 experiments/Azure.Experiments/Azure.Experiments/readme.md delete mode 100644 experiments/Azure.Experiments/Tests/AuthenticationResponse.cs delete mode 100644 experiments/Azure.Experiments/Tests/Client.cs delete mode 100644 experiments/Azure.Experiments/Tests/Configuration.cs delete mode 100644 experiments/Azure.Experiments/Tests/Credentials.cs delete mode 100644 experiments/Azure.Experiments/Tests/KeyValuePair.cs delete mode 100644 experiments/Azure.Experiments/Tests/NetworkInterfaceTest.cs delete mode 100644 experiments/Azure.Experiments/Tests/NetworkSecurityGroupTest.cs delete mode 100644 experiments/Azure.Experiments/Tests/Old/ComputeTest.cs delete mode 100644 experiments/Azure.Experiments/Tests/Old/UnitTests.cs delete mode 100644 experiments/Azure.Experiments/Tests/PublicIPAddressTest.cs delete mode 100644 experiments/Azure.Experiments/Tests/ResourceGroupTest.cs delete mode 100644 experiments/Azure.Experiments/Tests/SubnetTest.cs delete mode 100644 experiments/Azure.Experiments/Tests/Tests.csproj delete mode 100644 experiments/Azure.Experiments/Tests/TokenProvider.cs delete mode 100644 experiments/Azure.Experiments/Tests/VirtualMachineTest.cs delete mode 100644 experiments/Azure.Experiments/Tests/VirtualNetworkTest.cs delete mode 100644 experiments/Compute.Experiments/AzureRM.Compute.Experiments-help.xml delete mode 100644 experiments/Compute.Experiments/AzureRM.Compute.Experiments.Tests.ps1 delete mode 100644 experiments/Compute.Experiments/AzureRM.Compute.Experiments.psd1 delete mode 100644 experiments/Compute.Experiments/AzureRM.Compute.Experiments.psm1 delete mode 100644 experiments/Compute.Experiments/AzureRM.Compute.Experiments.test.ps1 delete mode 100644 experiments/Compute.Experiments/copy-dev.ps1 delete mode 100644 experiments/Compute.Experiments/help/AzureRM.Compute.Experiments.md delete mode 100644 experiments/Compute.Experiments/help/New-AzVm.md delete mode 100644 experiments/Compute.Experiments/publish-dev.ps1 delete mode 100644 experiments/Websites.Experiments/AzureRM.Websites.Experiments.Tests.ps1 delete mode 100644 experiments/Websites.Experiments/AzureRM.Websites.Experiments.format.ps1xml delete mode 100644 experiments/Websites.Experiments/AzureRM.Websites.Experiments.psd1 delete mode 100644 experiments/Websites.Experiments/AzureRM.Websites.Experiments.psm1 delete mode 100644 experiments/Websites.Experiments/CustomWebSiteManagementClient.cs delete mode 100644 experiments/Websites.Experiments/MSSharedLibKey.snk delete mode 100644 experiments/Websites.Experiments/Microsoft.Azure.Commands.Websites.Experiments.csproj delete mode 100644 experiments/Websites.Experiments/Microsoft.Azure.Commands.Websites.Experiments.sln delete mode 100644 experiments/Websites.Experiments/Models/ResourceNameAvailability.cs delete mode 100644 experiments/Websites.Experiments/Models/ResourceNameAvailabilityRequest.cs delete mode 100644 experiments/Websites.Experiments/Properties/AssemblyInfo.cs delete mode 100644 experiments/Websites.Experiments/Run-UnitTests.ps1 delete mode 100644 experiments/Websites.Experiments/help/AzureRM.Websites.Experiments-help.xml delete mode 100644 experiments/Websites.Experiments/help/New-AzWebApp.md delete mode 100644 experiments/Websites.Experiments/help/New-AzWebAppGrayParam.md delete mode 100644 experiments/Websites.Experiments/packages.config diff --git a/experiments/Azure.Experiments/Azure.Experiments.sln b/experiments/Azure.Experiments/Azure.Experiments.sln deleted file mode 100644 index cbb86a94d9ae..000000000000 --- a/experiments/Azure.Experiments/Azure.Experiments.sln +++ /dev/null @@ -1,31 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 15 -VisualStudioVersion = 15.0.27004.2005 -MinimumVisualStudioVersion = 10.0.40219.1 -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Azure.Experiments", "Azure.Experiments\Azure.Experiments.csproj", "{1D707014-5D2B-4C4E-9D1A-3A449A234329}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Tests", "Tests\Tests.csproj", "{636E4926-8F71-4D98-8169-4261AD4B754D}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Any CPU = Debug|Any CPU - Release|Any CPU = Release|Any CPU - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {1D707014-5D2B-4C4E-9D1A-3A449A234329}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {1D707014-5D2B-4C4E-9D1A-3A449A234329}.Debug|Any CPU.Build.0 = Debug|Any CPU - {1D707014-5D2B-4C4E-9D1A-3A449A234329}.Release|Any CPU.ActiveCfg = Release|Any CPU - {1D707014-5D2B-4C4E-9D1A-3A449A234329}.Release|Any CPU.Build.0 = Release|Any CPU - {636E4926-8F71-4D98-8169-4261AD4B754D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {636E4926-8F71-4D98-8169-4261AD4B754D}.Debug|Any CPU.Build.0 = Debug|Any CPU - {636E4926-8F71-4D98-8169-4261AD4B754D}.Release|Any CPU.ActiveCfg = Release|Any CPU - {636E4926-8F71-4D98-8169-4261AD4B754D}.Release|Any CPU.Build.0 = Release|Any CPU - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection - GlobalSection(ExtensibilityGlobals) = postSolution - SolutionGuid = {EF4DF79C-5085-40DC-93AD-6E1B2B6AC835} - EndGlobalSection -EndGlobal diff --git a/experiments/Azure.Experiments/Azure.Experiments/AsyncOperation.cs b/experiments/Azure.Experiments/Azure.Experiments/AsyncOperation.cs deleted file mode 100644 index 42904333c835..000000000000 --- a/experiments/Azure.Experiments/Azure.Experiments/AsyncOperation.cs +++ /dev/null @@ -1,47 +0,0 @@ -using System.Collections.Concurrent; -using System.Threading; -using System.Threading.Tasks; - -namespace Microsoft.Azure.Experiments -{ - abstract class AsyncOperation : IResourceConfigVisitor> - { - public AsyncOperation(IClient client, CancellationToken cancellationToken) - { - Client = client; - CancellationToken = cancellationToken; - } - - public async Task GetOrAddUntyped(IResourceConfig config) - => await TaskMap.GetOrAdd( - config, - async _ => - { - var info = await config.Apply(this); - Result.GetOrAddUntyped(config, () => info); - return info; - }); - - public async Task GetOrAdd(IResourceConfig config) - where Config : class - { - var result = await GetOrAddUntyped(config); - return result as Config; - } - - public abstract Task Visit(ResourceConfig config) where Config : class; - - public abstract Task Visit(NestedResourceConfig config) - where Config : class - where ParentConfig : class; - - public IClient Client { get; } - - public CancellationToken CancellationToken { get; } - - public State Result { get; } = new State(); - - ConcurrentDictionary> TaskMap { get; } - = new ConcurrentDictionary>(); - } -} diff --git a/experiments/Azure.Experiments/Azure.Experiments/Azure.Experiments.csproj b/experiments/Azure.Experiments/Azure.Experiments/Azure.Experiments.csproj deleted file mode 100644 index de6d6e7d4828..000000000000 --- a/experiments/Azure.Experiments/Azure.Experiments/Azure.Experiments.csproj +++ /dev/null @@ -1,21 +0,0 @@ - - - - netstandard1.4;net452 - Microsoft.Azure.Experiments - Microsoft.Azure.Experiments - true - 1.1.0 - - - - - - - - - - - - - diff --git a/experiments/Azure.Experiments/Azure.Experiments/Compute/ComputePolicy.cs b/experiments/Azure.Experiments/Azure.Experiments/Compute/ComputePolicy.cs deleted file mode 100644 index cc461430840e..000000000000 --- a/experiments/Azure.Experiments/Azure.Experiments/Compute/ComputePolicy.cs +++ /dev/null @@ -1,24 +0,0 @@ -using Microsoft.Azure.Management.Compute; -using Microsoft.Azure.Management.Compute.Models; -using System; -using System.Threading.Tasks; - -namespace Microsoft.Azure.Experiments.Compute -{ - public static class ComputePolicy - { - public static ResourcePolicy Create( - string header, - Func getOperations, - Func, Task> getAsync, - Func, Task> createOrUpdateAsync) - where Config : Resource - => ResourcePolicy.Create( - new[] { "Microsoft.Compute", header }, - getOperations, - getAsync, - createOrUpdateAsync, - config => config.Location, - (config, location) => config.Location = location); - } -} diff --git a/experiments/Azure.Experiments/Azure.Experiments/Compute/VirtualMachinePolicy.cs b/experiments/Azure.Experiments/Azure.Experiments/Compute/VirtualMachinePolicy.cs deleted file mode 100644 index e454a872f12e..000000000000 --- a/experiments/Azure.Experiments/Azure.Experiments/Compute/VirtualMachinePolicy.cs +++ /dev/null @@ -1,66 +0,0 @@ -using Microsoft.Azure.Management.Compute; -using Microsoft.Azure.Management.Compute.Models; -using Microsoft.Azure.Management.Network.Models; -using Microsoft.Azure.Management.ResourceManager.Models; - -namespace Microsoft.Azure.Experiments.Compute -{ - public static class VirtualMachinePolicy - { - public static ResourcePolicy Policy { get; } - = ComputePolicy.Create( - "virtualMachines", - client => client.VirtualMachines, - p => p.Operations.GetAsync( - p.ResourceGroupName, p.Name, null, p.CancellationToken), - p => p.Operations.CreateOrUpdateAsync( - p.ResourceGroupName, p.Name, p.Config, p.CancellationToken)); - - public static ResourceConfig CreateVirtualMachineConfig( - this ResourceConfig resourceGroup, - string name, - ResourceConfig networkInterface, - string adminUsername, - string adminPassword) - => Policy.CreateConfig( - resourceGroup, - name, - subscription => new VirtualMachine - { - OsProfile = new OSProfile - { - ComputerName = name, - WindowsConfiguration = new WindowsConfiguration - { - }, - AdminUsername = adminUsername, - AdminPassword = adminPassword, - }, - NetworkProfile = new NetworkProfile - { - NetworkInterfaces = new[] - { - new NetworkInterfaceReference - { - Id = networkInterface.GetId(subscription).IdToString() - } - } - }, - HardwareProfile = new HardwareProfile - { - VmSize = "Standard_DS1_v2" - }, - StorageProfile = new StorageProfile - { - ImageReference = new ImageReference - { - Publisher = "MicrosoftWindowsServer", - Offer = "WindowsServer", - Sku = "2016-Datacenter", - Version = "latest" - } - }, - }, - new[] { networkInterface }); - } -} diff --git a/experiments/Azure.Experiments/Azure.Experiments/Context.cs b/experiments/Azure.Experiments/Azure.Experiments/Context.cs deleted file mode 100644 index 4c1d5ac4da35..000000000000 --- a/experiments/Azure.Experiments/Azure.Experiments/Context.cs +++ /dev/null @@ -1,38 +0,0 @@ -using Microsoft.Azure.Management.Compute; -using Microsoft.Azure.Management.Network; -using Microsoft.Azure.Management.ResourceManager; -using Microsoft.Rest; - -namespace Microsoft.Azure.Experiments -{ - public sealed class Context - { - public Context(ServiceClientCredentials credentials, string subscriptionId) - { - Credentials = credentials; - SubscriptionId = subscriptionId; - } - - public ServiceClientCredentials Credentials { get; } - - public string SubscriptionId { get; } - - public NetworkManagementClient CreateNetworkManagementClient() - => new NetworkManagementClient(Credentials) - { - SubscriptionId = SubscriptionId - }; - - public ComputeManagementClient CreateComputeManagementClient() - => new ComputeManagementClient(Credentials) - { - SubscriptionId = SubscriptionId - }; - - public ResourceManagementClient CreateResourceManagementClient() - => new ResourceManagementClient(Credentials) - { - SubscriptionId = SubscriptionId - }; - } -} diff --git a/experiments/Azure.Experiments/Azure.Experiments/CreateOrUpdateAsyncOperation.cs b/experiments/Azure.Experiments/Azure.Experiments/CreateOrUpdateAsyncOperation.cs deleted file mode 100644 index c237a2bc07aa..000000000000 --- a/experiments/Azure.Experiments/Azure.Experiments/CreateOrUpdateAsyncOperation.cs +++ /dev/null @@ -1,64 +0,0 @@ -using System.Linq; -using System.Threading; -using System.Threading.Tasks; - -namespace Microsoft.Azure.Experiments -{ - public static class CreateOrUpdateAsyncOperation - { - public static async Task CreateOrUpdateAsync( - this IResourceConfig config, - IClient client, - IState current, - IState parameters, - CancellationToken cancellationToken) - where Config : class - { - var visitor = new CreateAsyncVisitor(client, current, parameters, cancellationToken); - await visitor.GetOrAdd(config); - return visitor.Result; - } - - sealed class CreateAsyncVisitor : AsyncOperation - { - public override async Task Visit(ResourceConfig config) - { - var current = Current.GetOrNull(config); - if (current != null) - { - return current; - } - var tasks = config.Dependencies.Select(GetOrAddUntyped); - await Task.WhenAll(tasks); - return await config.Policy.CreateOrUpdateAsync(CreateOrUpdateAsyncParams.Create( - Client, - config.ResourceGroupName, - config.Name, - Parameters.GetOrNull(config), - CancellationToken)); - } - - public override async Task Visit( - NestedResourceConfig config) - { - var parent = await GetOrAdd(config.Parent); - return config.Policy.Get(parent, config.Name); - } - - public CreateAsyncVisitor( - IClient client, - IState current, - IState parameters, - CancellationToken cancellationToken) - : base(client, cancellationToken) - { - Current = current; - Parameters = parameters; - } - - IState Current { get; } - - IState Parameters { get; } - } - } -} diff --git a/experiments/Azure.Experiments/Azure.Experiments/CreateOrUpdateAsyncParams.cs b/experiments/Azure.Experiments/Azure.Experiments/CreateOrUpdateAsyncParams.cs deleted file mode 100644 index 1f0424c8045a..000000000000 --- a/experiments/Azure.Experiments/Azure.Experiments/CreateOrUpdateAsyncParams.cs +++ /dev/null @@ -1,43 +0,0 @@ -using System.Threading; - -namespace Microsoft.Azure.Experiments -{ - public static class CreateOrUpdateAsyncParams - { - public static CreateOrUpdateAsyncParams Create( - Operations operations, - string resourceGroupName, - string name, - Config config, - CancellationToken cancellationToken) - => new CreateOrUpdateAsyncParams( - operations, resourceGroupName, name, config, cancellationToken); - } - - public sealed class CreateOrUpdateAsyncParams - { - public TOperations Operations { get; } - - public string ResourceGroupName { get; } - - public string Name { get; } - - public CancellationToken CancellationToken { get; } - - public TConfig Config { get; } - - public CreateOrUpdateAsyncParams( - TOperations operations, - string resourceGroupName, - string name, - TConfig config, - CancellationToken cancellationToken) - { - Operations = operations; - ResourceGroupName = resourceGroupName; - Name = name; - Config = config; - CancellationToken = cancellationToken; - } - } -} diff --git a/experiments/Azure.Experiments/Azure.Experiments/EnumerableEx.cs b/experiments/Azure.Experiments/Azure.Experiments/EnumerableEx.cs deleted file mode 100644 index 6b8791eac451..000000000000 --- a/experiments/Azure.Experiments/Azure.Experiments/EnumerableEx.cs +++ /dev/null @@ -1,11 +0,0 @@ -using System.Collections.Generic; -using System.Linq; - -namespace Microsoft.Azure.Experiments -{ - public static class EnumerableEx - { - public static IEnumerable EmptyIfNull(this IEnumerable value) - => value ?? Enumerable.Empty(); - } -} diff --git a/experiments/Azure.Experiments/Azure.Experiments/GetAsyncOperation.cs b/experiments/Azure.Experiments/Azure.Experiments/GetAsyncOperation.cs deleted file mode 100644 index abf1433d2844..000000000000 --- a/experiments/Azure.Experiments/Azure.Experiments/GetAsyncOperation.cs +++ /dev/null @@ -1,58 +0,0 @@ -using Microsoft.Rest.Azure; -using System.Linq; -using System.Net; -using System.Threading; -using System.Threading.Tasks; - -namespace Microsoft.Azure.Experiments -{ - public static class GetAsyncOperation - { - public static async Task GetAsync( - this IResourceConfig resourceConfig, - IClient client, - CancellationToken cancellationToken) - where Config : class - { - var visitor = new Visitor(client, cancellationToken); - await visitor.GetOrAdd(resourceConfig); - return visitor.Result; - } - - sealed class Visitor : AsyncOperation - { - public override async Task Visit(ResourceConfig config) - { - Config info; - try - { - info = await config.Policy.GetAsync(GetAsyncParams.Create( - Client, config.ResourceGroupName, config.Name, CancellationToken)); - } - catch (CloudException e) when (e.Response.StatusCode == HttpStatusCode.NotFound) - { - info = null; - } - if (info == null) - { - var tasks = config.Dependencies.Select(GetOrAddUntyped); - await Task.WhenAll(tasks); - return null; - } - return info; - } - - public override async Task Visit( - NestedResourceConfig config) - { - var parent = await GetOrAdd(config.Parent); - return parent == null ? null : config.Policy.Get(parent, config.Name); - } - - public Visitor(IClient client, CancellationToken cancellationToken) - : base(client, cancellationToken) - { - } - } - } -} diff --git a/experiments/Azure.Experiments/Azure.Experiments/GetAsyncParams.cs b/experiments/Azure.Experiments/Azure.Experiments/GetAsyncParams.cs deleted file mode 100644 index 05a6c80572ed..000000000000 --- a/experiments/Azure.Experiments/Azure.Experiments/GetAsyncParams.cs +++ /dev/null @@ -1,37 +0,0 @@ -using System.Threading; - -namespace Microsoft.Azure.Experiments -{ - public static class GetAsyncParams - { - public static GetAsyncParams Create( - Operations operations, - string resourceGroupName, - string name, - CancellationToken cancellationToken) - => new GetAsyncParams(operations, resourceGroupName, name, cancellationToken); - } - - public class GetAsyncParams - { - public TOperations Operations { get; } - - public string ResourceGroupName { get; } - - public string Name { get; } - - public CancellationToken CancellationToken { get; } - - public GetAsyncParams( - TOperations operations, - string resourceGroupName, - string name, - CancellationToken cancellationToken) - { - Operations = operations; - ResourceGroupName = resourceGroupName; - Name = name; - CancellationToken = cancellationToken; - } - } -} diff --git a/experiments/Azure.Experiments/Azure.Experiments/IClient.cs b/experiments/Azure.Experiments/Azure.Experiments/IClient.cs deleted file mode 100644 index c929658a0de1..000000000000 --- a/experiments/Azure.Experiments/Azure.Experiments/IClient.cs +++ /dev/null @@ -1,12 +0,0 @@ -using System; - -namespace Microsoft.Azure.Experiments -{ - public interface IClient - { - Context Context { get; } - - T GetClient() - where T : class, IDisposable; - } -} diff --git a/experiments/Azure.Experiments/Azure.Experiments/IResourceConfig.cs b/experiments/Azure.Experiments/Azure.Experiments/IResourceConfig.cs deleted file mode 100644 index 3a402ca3ab67..000000000000 --- a/experiments/Azure.Experiments/Azure.Experiments/IResourceConfig.cs +++ /dev/null @@ -1,26 +0,0 @@ -using System.Collections.Generic; - -namespace Microsoft.Azure.Experiments -{ - public interface IResourceConfigVisitor - { - Result Visit(ResourceConfig config) - where Config : class; - - Result Visit(NestedResourceConfig config) - where Config : class - where ParentConfig : class; - } - - public interface IResourceConfig - { - Result Apply(IResourceConfigVisitor visitor); - - IEnumerable GetId(string subscription); - } - - public interface IResourceConfig : IResourceConfig - where Config : class - { - } -} diff --git a/experiments/Azure.Experiments/Azure.Experiments/IResourcePolicy.cs b/experiments/Azure.Experiments/Azure.Experiments/IResourcePolicy.cs deleted file mode 100644 index b6e3496ca80d..000000000000 --- a/experiments/Azure.Experiments/Azure.Experiments/IResourcePolicy.cs +++ /dev/null @@ -1,6 +0,0 @@ -namespace Microsoft.Azure.Experiments -{ - public interface IResourcePolicy - { - } -} diff --git a/experiments/Azure.Experiments/Azure.Experiments/IState.cs b/experiments/Azure.Experiments/Azure.Experiments/IState.cs deleted file mode 100644 index 4390473004c5..000000000000 --- a/experiments/Azure.Experiments/Azure.Experiments/IState.cs +++ /dev/null @@ -1,8 +0,0 @@ -namespace Microsoft.Azure.Experiments -{ - public interface IState - { - Config GetOrNull(IResourceConfig config) - where Config : class; - } -} diff --git a/experiments/Azure.Experiments/Azure.Experiments/NestedResourceConfig.cs b/experiments/Azure.Experiments/Azure.Experiments/NestedResourceConfig.cs deleted file mode 100644 index accc567b79eb..000000000000 --- a/experiments/Azure.Experiments/Azure.Experiments/NestedResourceConfig.cs +++ /dev/null @@ -1,49 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; - -namespace Microsoft.Azure.Experiments -{ - public static class NestedResourceConfig - { - public static NestedResourceConfig CreateConfig( - this NestedResourcePolicy policy, - IResourceConfig parent, - string name, - Func create) - where Config : class - where ParentConfig : class - => new NestedResourceConfig(policy, parent, name, create); - } - - public sealed class NestedResourceConfig : IResourceConfig - where Config : class - where ParentConfig : class - { - public NestedResourcePolicy Policy { get; } - - public string Name { get; } - - public IResourceConfig Parent { get; } - - public Func Create { get; } - - public NestedResourceConfig( - NestedResourcePolicy policy, - IResourceConfig parent, - string name, - Func create) - { - Policy = policy; - Name = name; - Parent = parent; - Create = create; - } - - public Result Apply(IResourceConfigVisitor visitor) - => visitor.Visit(this); - - public IEnumerable GetId(string subscription) - => Parent.GetId(subscription).Concat(Policy.GetId(Name)); - } -} diff --git a/experiments/Azure.Experiments/Azure.Experiments/NestedResourcePolicy.cs b/experiments/Azure.Experiments/Azure.Experiments/NestedResourcePolicy.cs deleted file mode 100644 index e2afa2e3f38d..000000000000 --- a/experiments/Azure.Experiments/Azure.Experiments/NestedResourcePolicy.cs +++ /dev/null @@ -1,38 +0,0 @@ -using System; -using System.Collections.Generic; - -namespace Microsoft.Azure.Experiments -{ - public sealed class NestedResourcePolicy : IResourcePolicy - { - public Func> GetId { get; } - - public Func Get { get; } - - public Action Set { get; } - - public NestedResourcePolicy( - Func> getId, - Func get, - Action set) - { - GetId = getId; - Get = get; - Set = set; - } - } - - public static class NestedResourcePolicy - { - public static NestedResourcePolicy Create( - string header, - Func get, - Action set) - where Config : class - where ParentConfig : class - => new NestedResourcePolicy( - name => new[] { header, name}, - get, - set); - } -} diff --git a/experiments/Azure.Experiments/Azure.Experiments/Network/NetworkInterfacePolicy.cs b/experiments/Azure.Experiments/Azure.Experiments/Network/NetworkInterfacePolicy.cs deleted file mode 100644 index 00f50663ffb4..000000000000 --- a/experiments/Azure.Experiments/Azure.Experiments/Network/NetworkInterfacePolicy.cs +++ /dev/null @@ -1,48 +0,0 @@ -using Microsoft.Azure.Management.Network; -using Microsoft.Azure.Management.Network.Models; -using Microsoft.Azure.Management.ResourceManager.Models; - -namespace Microsoft.Azure.Experiments.Network -{ - public static class NetworkInterfacePolicy - { - public static ResourcePolicy Policy { get; } - = NetworkPolicy.Create( - "networkInterfaces", - client => client.NetworkInterfaces, - p => p.Operations.GetAsync( - p.ResourceGroupName, p.Name, null, p.CancellationToken), - p => p.Operations.CreateOrUpdateAsync( - p.ResourceGroupName, p.Name, p.Config, p.CancellationToken)); - - public static ResourceConfig CreateNetworkInterfaceConfig( - this ResourceConfig resourceGroup, - string name, - NestedResourceConfig subnet, - ResourceConfig publicIPAddress, - ResourceConfig networkSecurityGroup) - => Policy.CreateConfig( - resourceGroup, - name, - subscription => new NetworkInterface - { - IpConfigurations = new [] - { - new NetworkInterfaceIPConfiguration - { - Name = name, - Subnet = new Subnet { Id = subnet.GetId(subscription).IdToString() }, - PublicIPAddress = new PublicIPAddress - { - Id = publicIPAddress.GetId(subscription).IdToString() - } - } - }, - NetworkSecurityGroup = new NetworkSecurityGroup - { - Id = networkSecurityGroup.GetId(subscription).IdToString() - } - }, - new IResourceConfig[] { subnet, publicIPAddress, networkSecurityGroup }); - } -} diff --git a/experiments/Azure.Experiments/Azure.Experiments/Network/NetworkPolicy.cs b/experiments/Azure.Experiments/Azure.Experiments/Network/NetworkPolicy.cs deleted file mode 100644 index 47145576f71f..000000000000 --- a/experiments/Azure.Experiments/Azure.Experiments/Network/NetworkPolicy.cs +++ /dev/null @@ -1,24 +0,0 @@ -using Microsoft.Azure.Management.Network; -using Microsoft.Azure.Management.Network.Models; -using System; -using System.Threading.Tasks; - -namespace Microsoft.Azure.Experiments.Network -{ - public static class NetworkPolicy - { - public static ResourcePolicy Create( - string header, - Func getOperations, - Func, Task> getAsync, - Func, Task> createOrUpdateAsync) - where Config : Resource - => ResourcePolicy.Create( - new [] { "Microsoft.Network", header }, - getOperations, - getAsync, - createOrUpdateAsync, - config => config.Location, - (config, location) => config.Location = location); - } -} diff --git a/experiments/Azure.Experiments/Azure.Experiments/Network/NetworkSecurityGroupPolicy.cs b/experiments/Azure.Experiments/Azure.Experiments/Network/NetworkSecurityGroupPolicy.cs deleted file mode 100644 index 1fed9994dfb3..000000000000 --- a/experiments/Azure.Experiments/Azure.Experiments/Network/NetworkSecurityGroupPolicy.cs +++ /dev/null @@ -1,22 +0,0 @@ -using Microsoft.Azure.Management.Network; -using Microsoft.Azure.Management.Network.Models; -using Microsoft.Azure.Management.ResourceManager.Models; - -namespace Microsoft.Azure.Experiments.Network -{ - public static class NetworkSecurityGroupPolicy - { - public static ResourcePolicy Policy { get; } - = NetworkPolicy.Create( - "networkSecurityGroups", - client => client.NetworkSecurityGroups, - p => p.Operations.GetAsync( - p.ResourceGroupName, p.Name, null, p.CancellationToken), - p => p.Operations.CreateOrUpdateAsync( - p.ResourceGroupName, p.Name, p.Config, p.CancellationToken)); - - public static ResourceConfig CreateNetworkSecurityGroupConfig( - this ResourceConfig resourceGroup, string name) - => Policy.CreateConfig(resourceGroup, name); - } -} diff --git a/experiments/Azure.Experiments/Azure.Experiments/Network/PublicIPAddressPolicy.cs b/experiments/Azure.Experiments/Azure.Experiments/Network/PublicIPAddressPolicy.cs deleted file mode 100644 index c2467a908606..000000000000 --- a/experiments/Azure.Experiments/Azure.Experiments/Network/PublicIPAddressPolicy.cs +++ /dev/null @@ -1,22 +0,0 @@ -using Microsoft.Azure.Management.Network; -using Microsoft.Azure.Management.Network.Models; -using Microsoft.Azure.Management.ResourceManager.Models; - -namespace Microsoft.Azure.Experiments.Network -{ - public static class PublicIPAddressPolicy - { - public static ResourcePolicy Policy { get; } - = NetworkPolicy.Create( - "publicIPAddresses", - client => client.PublicIPAddresses, - p => p.Operations.GetAsync( - p.ResourceGroupName, p.Name, null, p.CancellationToken), - p => p.Operations.CreateOrUpdateAsync( - p.ResourceGroupName, p.Name, p.Config, p.CancellationToken)); - - public static ResourceConfig CreatePublicIPAddressConfig( - this ResourceConfig resourceGroup, string name) - => Policy.CreateConfig(resourceGroup, name); - } -} diff --git a/experiments/Azure.Experiments/Azure.Experiments/Network/SubnetPolicy.cs b/experiments/Azure.Experiments/Azure.Experiments/Network/SubnetPolicy.cs deleted file mode 100644 index 96ee57646eb8..000000000000 --- a/experiments/Azure.Experiments/Azure.Experiments/Network/SubnetPolicy.cs +++ /dev/null @@ -1,40 +0,0 @@ -using Microsoft.Azure.Management.Network.Models; -using System.Collections.Generic; -using System.Linq; - -namespace Microsoft.Azure.Experiments.Network -{ - public static class SubnetPolicy - { - public static NestedResourcePolicy Policy { get; } - = NestedResourcePolicy.Create( - "subnets", - (vn, name) => vn.Subnets?.FirstOrDefault(s => s.Name == name), - (vn, name, subnet) => - { - subnet.Name = name; - if (vn.Subnets == null) - { - vn.Subnets = new List { subnet }; - return; - } - var s = vn - .Subnets - .Select((sn, i) => new { sn, i }) - .FirstOrDefault(p => p.sn.Name == name); - if (s != null) - { - vn.Subnets[s.i] = subnet; - return; - } - vn.Subnets.Add(subnet); - }); - - public static NestedResourceConfig CreateSubnet( - this ResourceConfig virtualNetwork, string name, string addressPrefix) - => Policy.CreateConfig( - virtualNetwork, - name, - () => new Subnet { Name = name, AddressPrefix = addressPrefix }); - } -} diff --git a/experiments/Azure.Experiments/Azure.Experiments/Network/VirtualNetworkPolicy.cs b/experiments/Azure.Experiments/Azure.Experiments/Network/VirtualNetworkPolicy.cs deleted file mode 100644 index cf77501bbdab..000000000000 --- a/experiments/Azure.Experiments/Azure.Experiments/Network/VirtualNetworkPolicy.cs +++ /dev/null @@ -1,33 +0,0 @@ -using Microsoft.Azure.Management.Network; -using Microsoft.Azure.Management.Network.Models; -using Microsoft.Azure.Management.ResourceManager.Models; - -namespace Microsoft.Azure.Experiments.Network -{ - public static class VirtualNetworkPolicy - { - public static ResourcePolicy Policy { get; } - = NetworkPolicy.Create( - "virtualNetworks", - client => client.VirtualNetworks, - p => p.Operations.GetAsync( - p.ResourceGroupName, p.Name, null, p.CancellationToken), - p => p.Operations.CreateOrUpdateAsync( - p.ResourceGroupName, p.Name, p.Config, p.CancellationToken)); - - public static ResourceConfig CreateVirtualNetworkConfig( - this ResourceConfig resourceGroup, - string name, - string addressPrefix) - => Policy.CreateConfig( - resourceGroup, - name, - _ => new VirtualNetwork - { - AddressSpace = new AddressSpace - { - AddressPrefixes = new[] { addressPrefix } - } - }); - } -} diff --git a/experiments/Azure.Experiments/Azure.Experiments/Old/AzureObject.cs b/experiments/Azure.Experiments/Azure.Experiments/Old/AzureObject.cs deleted file mode 100644 index ddda1f67aea8..000000000000 --- a/experiments/Azure.Experiments/Azure.Experiments/Old/AzureObject.cs +++ /dev/null @@ -1,128 +0,0 @@ -using Microsoft.Rest.Azure; -using System.Collections.Generic; -using System.Linq; -using System.Net; -using System.Threading.Tasks; - -namespace Azure.Experiments -{ - public abstract class AzureObject - { - public static IEnumerable NoDependencies { get; } - = Enumerable.Empty(); - - public abstract string Name { get; } - - public IEnumerable Dependencies { get; } - - public abstract Task CheckOrCreateAsync(string location); - - public int Priority { get; } - - /// - /// The function should be called only after GetInfo is called for the - /// object and its dependencies. - /// - /// - public abstract Task GetInfoLocationAsync(); - - /// - /// The function should be called only after GetInfo is called for the - /// object and its dependencies. - /// - /// - public async Task GetDependencyLocationAsync() - { - if (DependencyLocation == null) - { - var location = await GetInfoLocationAsync(); - if (location != null) - { - return new DependencyLocation(location, Priority); - } - var taskList = Dependencies.Select(d => GetDependencyLocationAsync()); - var dlList = await Task.WhenAll(taskList); - DependencyLocation = dlList.Aggregate( - DependencyLocation.None, - (a, b) => a.Priority > b.Priority ? a : b); - } - return DependencyLocation; - } - - protected AzureObject(IEnumerable dependencies) - { - // Name = name; - Dependencies = dependencies; - Priority = dependencies.Any() - ? dependencies.Max(d => d.Priority) + 1 - : 1; - } - - private DependencyLocation DependencyLocation { get; set; } - } - - public abstract class AzureObject : AzureObject - where T: class - where P: struct, IInfoPolicy - { - private T Info { get; set; } - - public override async Task GetInfoLocationAsync() - => await GetOrNullAsync() == null ? null : new P().GetLocation(Info); - - public async Task GetOrNullAsync() - { - if (!IsGetCalled) - { - IsGetCalled = true; - try - { - Info = await GetOrThrowAsync(); - } - catch (CloudException e) - when (e.Response.StatusCode == HttpStatusCode.NotFound) - { - } - } - return Info; - } - - public async Task GetOrCreateAsync(string location) - { - Info = await GetOrNullAsync(); - if (Info == null) - { - // this can be optimized by using WaitForAll and a state - // machine for `Task Info`. The state machine is required to - // avoid multiple creations of the same resource group. - foreach (var d in Dependencies) - { - await d.CheckOrCreateAsync(location); - } - Info = await CreateAsync(location); - } - return Info; - } - - public async Task GetOrCreateAsync() - { - var dl = await GetDependencyLocationAsync(); - var location = dl.Location ?? "eastus"; - return await GetOrCreateAsync(location); - } - - protected AzureObject(IEnumerable dependencies) - : base(dependencies) - { - } - - public override Task CheckOrCreateAsync(string location) - => GetOrCreateAsync(location); - - protected abstract Task GetOrThrowAsync(); - - protected abstract Task CreateAsync(string location); - - private bool IsGetCalled; - } -} diff --git a/experiments/Azure.Experiments/Azure.Experiments/Old/Compute/ComputePolicy.cs b/experiments/Azure.Experiments/Azure.Experiments/Old/Compute/ComputePolicy.cs deleted file mode 100644 index a2009cffc7f3..000000000000 --- a/experiments/Azure.Experiments/Azure.Experiments/Old/Compute/ComputePolicy.cs +++ /dev/null @@ -1,11 +0,0 @@ -using Microsoft.Azure.Management.Compute.Models; - -namespace Azure.Experiments.Compute -{ - public struct ComputePolicy : IInfoPolicy - where T : Resource - { - public string GetLocation(T value) - => value.Location; - } -} diff --git a/experiments/Azure.Experiments/Azure.Experiments/Old/Compute/VirtualMachineObject.cs b/experiments/Azure.Experiments/Azure.Experiments/Old/Compute/VirtualMachineObject.cs deleted file mode 100644 index c06392b45db0..000000000000 --- a/experiments/Azure.Experiments/Azure.Experiments/Old/Compute/VirtualMachineObject.cs +++ /dev/null @@ -1,87 +0,0 @@ -using Azure.Experiments.Network; -using Microsoft.Azure.Experiments; -using Microsoft.Azure.Management.Compute; -using Microsoft.Azure.Management.Compute.Models; -using System.Threading.Tasks; - -namespace Azure.Experiments.Compute -{ - public sealed class VirtualMachineObject - : ResourceObject> - { - public VirtualMachineObject( - Context c, - string name, - ResourceGroupObject rg, - NetworkInterfaceObject ni, - string adminUsername, - string adminPassword) - : base(rg, new[] { ni }) - { - Name = name; - Client = new ComputeManagementClient(c.Credentials) - { - SubscriptionId = c.SubscriptionId - } - .VirtualMachines; - AdminUsername = adminUsername; - AdminPassword = adminPassword; - Ni = ni; - } - - protected override async Task CreateAsync(string location) - { - var ni = await Ni.GetOrNullAsync(); - return await Client.CreateOrUpdateAsync( - ResourceGroupName, - Name, - new VirtualMachine - { - Location = "eastus", - OsProfile = new OSProfile - { - ComputerName = Name, - WindowsConfiguration = new WindowsConfiguration - { - }, - AdminUsername = AdminUsername, - AdminPassword = AdminPassword, - }, - NetworkProfile = new NetworkProfile - { - NetworkInterfaces = new NetworkInterfaceReference[] - { - new NetworkInterfaceReference(ni.Id) - } - }, - HardwareProfile = new HardwareProfile - { - VmSize = "Standard_DS1_v2" - }, - StorageProfile = new StorageProfile - { - ImageReference = new ImageReference - { - Publisher = "MicrosoftWindowsServer", - Offer = "WindowsServer", - Sku = "2016-Datacenter", - Version = "latest" - } - }, - }); - } - - protected override Task GetOrThrowAsync() - => Client.GetAsync(ResourceGroupName, Name); - - private string AdminUsername { get; } - - private string AdminPassword { get; } - - private NetworkInterfaceObject Ni { get; } - - private IVirtualMachinesOperations Client { get; } - - public override string Name { get; } - } -} diff --git a/experiments/Azure.Experiments/Azure.Experiments/Old/Context.cs b/experiments/Azure.Experiments/Azure.Experiments/Old/Context.cs deleted file mode 100644 index 80c8f469c9f6..000000000000 --- a/experiments/Azure.Experiments/Azure.Experiments/Old/Context.cs +++ /dev/null @@ -1,14 +0,0 @@ -using Microsoft.Azure.Experiments; -using Microsoft.Azure.Management.Network; - -namespace Azure.Experiments -{ - public static class ContextEx - { - public static NetworkManagementClient CreateNetwork(this Context context) - => new NetworkManagementClient(context.Credentials) - { - SubscriptionId = context.SubscriptionId - }; - } -} diff --git a/experiments/Azure.Experiments/Azure.Experiments/Old/DependencyLocation.cs b/experiments/Azure.Experiments/Azure.Experiments/Old/DependencyLocation.cs deleted file mode 100644 index 8e23210dccd8..000000000000 --- a/experiments/Azure.Experiments/Azure.Experiments/Old/DependencyLocation.cs +++ /dev/null @@ -1,18 +0,0 @@ -namespace Azure.Experiments -{ - public sealed class DependencyLocation - { - public static DependencyLocation None { get; } - = new DependencyLocation(null, 0); - - public string Location { get; } - - public int Priority { get; } - - public DependencyLocation(string location, int priority) - { - Location = location; - Priority = priority; - } - } -} diff --git a/experiments/Azure.Experiments/Azure.Experiments/Old/IInfoPolicy.cs b/experiments/Azure.Experiments/Azure.Experiments/Old/IInfoPolicy.cs deleted file mode 100644 index 3f9f66574ccc..000000000000 --- a/experiments/Azure.Experiments/Azure.Experiments/Old/IInfoPolicy.cs +++ /dev/null @@ -1,7 +0,0 @@ -namespace Azure.Experiments -{ - public interface IInfoPolicy - { - string GetLocation(T value); - } -} diff --git a/experiments/Azure.Experiments/Azure.Experiments/Old/Network/NetworkInterfaceObject.cs b/experiments/Azure.Experiments/Azure.Experiments/Old/Network/NetworkInterfaceObject.cs deleted file mode 100644 index 87e31cd42665..000000000000 --- a/experiments/Azure.Experiments/Azure.Experiments/Old/Network/NetworkInterfaceObject.cs +++ /dev/null @@ -1,58 +0,0 @@ -using Microsoft.Azure.Management.Network; -using Microsoft.Azure.Management.Network.Models; -using System.Threading.Tasks; - -namespace Azure.Experiments.Network -{ - public sealed class NetworkInterfaceObject - : NetworkObject - { - public NetworkInterfaceObject( - INetworkManagementClient client, - string name, - ResourceGroupObject rg, - SubnetObject subnet, - PublicIpAddressObject pia, - NetworkSecurityGroupObject nsg) - : base(rg, new AzureObject[] { subnet, pia, nsg }) - { - Name = name; - Client = client.NetworkInterfaces; - Pia = pia; - Subnet = subnet; - } - - protected override async Task CreateAsync(string location) - { - var subnet = await Subnet.GetOrNullAsync(); - var pia = await Pia.GetOrNullAsync(); - return await Client.CreateOrUpdateAsync( - ResourceGroupName, - Name, - new NetworkInterface - { - Location = location, - IpConfigurations = new[] - { - new NetworkInterfaceIPConfiguration - { - Name = Name, - Subnet = subnet, - PublicIPAddress = pia, - } - } - }); - } - - protected override Task GetOrThrowAsync() - => Client.GetAsync(ResourceGroupName, Name); - - private PublicIpAddressObject Pia { get; } - - private SubnetObject Subnet { get; } - - private INetworkInterfacesOperations Client { get; } - - public override string Name { get; } - } -} diff --git a/experiments/Azure.Experiments/Azure.Experiments/Old/Network/NetworkObject.cs b/experiments/Azure.Experiments/Azure.Experiments/Old/Network/NetworkObject.cs deleted file mode 100644 index 6a4e10162ee2..000000000000 --- a/experiments/Azure.Experiments/Azure.Experiments/Old/Network/NetworkObject.cs +++ /dev/null @@ -1,20 +0,0 @@ -using System.Collections.Generic; -using Microsoft.Azure.Management.Network.Models; - -namespace Azure.Experiments.Network -{ - public abstract class NetworkObject : ResourceObject> - where T : Resource - { - protected NetworkObject(ResourceGroupObject rg) - : base(rg) - { - } - - protected NetworkObject( - ResourceGroupObject rg, - IEnumerable dependencies) : base(rg, dependencies) - { - } - } -} diff --git a/experiments/Azure.Experiments/Azure.Experiments/Old/Network/NetworkPolicy.cs b/experiments/Azure.Experiments/Azure.Experiments/Old/Network/NetworkPolicy.cs deleted file mode 100644 index 1ef5d56d0835..000000000000 --- a/experiments/Azure.Experiments/Azure.Experiments/Old/Network/NetworkPolicy.cs +++ /dev/null @@ -1,11 +0,0 @@ -using Microsoft.Azure.Management.Network.Models; - -namespace Azure.Experiments.Network -{ - public struct NetworkPolicy : IInfoPolicy - where T : Resource - { - public string GetLocation(T value) - => value.Location; - } -} diff --git a/experiments/Azure.Experiments/Azure.Experiments/Old/Network/NetworkSecurityGroup.cs b/experiments/Azure.Experiments/Azure.Experiments/Old/Network/NetworkSecurityGroup.cs deleted file mode 100644 index 1efc2b9cfd5a..000000000000 --- a/experiments/Azure.Experiments/Azure.Experiments/Old/Network/NetworkSecurityGroup.cs +++ /dev/null @@ -1,33 +0,0 @@ -using Microsoft.Azure.Management.Network; -using Microsoft.Azure.Management.Network.Models; -using System.Threading.Tasks; - -namespace Azure.Experiments.Network -{ - public sealed class NetworkSecurityGroupObject - : NetworkObject - { - public NetworkSecurityGroupObject( - INetworkManagementClient client, - string name, - ResourceGroupObject rg) - : base(rg) - { - Name = name; - Client = client.NetworkSecurityGroups; - } - - protected override Task CreateAsync(string location) - => Client.CreateOrUpdateAsync( - ResourceGroupName, - Name, - new NetworkSecurityGroup { Location = location }); - - protected override Task GetOrThrowAsync() - => Client.GetAsync(ResourceGroupName, Name); - - private INetworkSecurityGroupsOperations Client { get; } - - public override string Name { get; } - } -} diff --git a/experiments/Azure.Experiments/Azure.Experiments/Old/Network/PublicIpAddressObject.cs b/experiments/Azure.Experiments/Azure.Experiments/Old/Network/PublicIpAddressObject.cs deleted file mode 100644 index d440a7944001..000000000000 --- a/experiments/Azure.Experiments/Azure.Experiments/Old/Network/PublicIpAddressObject.cs +++ /dev/null @@ -1,33 +0,0 @@ -using Microsoft.Azure.Management.Network; -using Microsoft.Azure.Management.Network.Models; -using System.Threading.Tasks; - -namespace Azure.Experiments.Network -{ - public sealed class PublicIpAddressObject : - NetworkObject - { - public PublicIpAddressObject( - INetworkManagementClient client, - string name, - ResourceGroupObject rg) - : base(rg) - { - Name = name; - Client = client.PublicIPAddresses; - } - - protected override Task CreateAsync(string location) - => Client.CreateOrUpdateAsync( - ResourceGroupName, - Name, - new PublicIPAddress { Location = location }); - - protected override Task GetOrThrowAsync() - => Client.GetAsync(ResourceGroupName, Name); - - private IPublicIPAddressesOperations Client { get; } - - public override string Name { get; } - } -} diff --git a/experiments/Azure.Experiments/Azure.Experiments/Old/Network/SubnetObject.cs b/experiments/Azure.Experiments/Azure.Experiments/Old/Network/SubnetObject.cs deleted file mode 100644 index 084b522ec415..000000000000 --- a/experiments/Azure.Experiments/Azure.Experiments/Old/Network/SubnetObject.cs +++ /dev/null @@ -1,41 +0,0 @@ -using Microsoft.Azure.Management.Network; -using Microsoft.Azure.Management.Network.Models; -using System.Linq; -using System.Threading.Tasks; - -namespace Azure.Experiments.Network -{ - public sealed class SubnetObject : AzureObject - { - public string AddressPrefix { get; } - - public SubnetObject( - string name, VirtualNetworkObject vn, string addressPrefix) - : base(new[] { vn }) - { - Name = name; - Vn = vn; - AddressPrefix = addressPrefix; - } - - protected override async Task CreateAsync(string location) - { - // The Virtual Network should be created at this point. - var vn = await Vn.GetOrNullAsync(); - vn.Subnets.Add(new Subnet { Name = Name, AddressPrefix = AddressPrefix }); - vn = await Vn.Client.CreateOrUpdateAsync( - Vn.ResourceGroupName, Vn.Name, vn); - return GetSubnet(vn); - } - - protected override async Task GetOrThrowAsync() - => GetSubnet(await Vn.GetOrNullAsync()); - - private VirtualNetworkObject Vn { get; } - - public override string Name { get; } - - private Subnet GetSubnet(VirtualNetwork vn) - => vn?.Subnets.FirstOrDefault(s => s.Name == Name); - } -} diff --git a/experiments/Azure.Experiments/Azure.Experiments/Old/Network/SubnetPolicy.cs b/experiments/Azure.Experiments/Azure.Experiments/Old/Network/SubnetPolicy.cs deleted file mode 100644 index 5ea39290e792..000000000000 --- a/experiments/Azure.Experiments/Azure.Experiments/Old/Network/SubnetPolicy.cs +++ /dev/null @@ -1,9 +0,0 @@ -using Microsoft.Azure.Management.Network.Models; - -namespace Azure.Experiments -{ - public struct SubnetPolicy : IInfoPolicy - { - public string GetLocation(Subnet value) => null; - } -} diff --git a/experiments/Azure.Experiments/Azure.Experiments/Old/Network/VirtualNetworkObject.cs b/experiments/Azure.Experiments/Azure.Experiments/Old/Network/VirtualNetworkObject.cs deleted file mode 100644 index 97d38a7770e8..000000000000 --- a/experiments/Azure.Experiments/Azure.Experiments/Old/Network/VirtualNetworkObject.cs +++ /dev/null @@ -1,44 +0,0 @@ -using Microsoft.Azure.Management.Network; -using Microsoft.Azure.Management.Network.Models; -using System.Threading.Tasks; - -namespace Azure.Experiments.Network -{ - public sealed class VirtualNetworkObject : - NetworkObject - { - public VirtualNetworkObject( - INetworkManagementClient client, - string name, - ResourceGroupObject rg, - string addressPrefix) - : base(rg, NoDependencies) - { - Name = name; - Client = client.VirtualNetworks; - AddressPrefix = addressPrefix; - } - - protected override Task CreateAsync(string location) - => Client.CreateOrUpdateAsync( - ResourceGroupName, - Name, - new VirtualNetwork - { - Location = "eastus", - AddressSpace = new AddressSpace - { - AddressPrefixes = new[] { AddressPrefix } - } - }); - - protected override Task GetOrThrowAsync() - => Client.GetAsync(ResourceGroupName, Name); - - private string AddressPrefix { get; } - - public IVirtualNetworksOperations Client { get; } - - public override string Name { get; } - } -} diff --git a/experiments/Azure.Experiments/Azure.Experiments/Old/ResourceGroupObject.cs b/experiments/Azure.Experiments/Azure.Experiments/Old/ResourceGroupObject.cs deleted file mode 100644 index 1d5a0d04f233..000000000000 --- a/experiments/Azure.Experiments/Azure.Experiments/Old/ResourceGroupObject.cs +++ /dev/null @@ -1,34 +0,0 @@ -using Microsoft.Azure.Management.ResourceManager.Models; -using Microsoft.Azure.Management.ResourceManager; -using System.Threading.Tasks; -using Microsoft.Azure.Experiments; - -namespace Azure.Experiments -{ - public sealed class ResourceGroupObject : AzureObject< - ResourceGroup, ResourceGroupPolicy> - { - public ResourceGroupObject(Context client, string name) - : base(NoDependencies) - { - Name = name; - Client = new ResourceManagementClient(client.Credentials) - { - SubscriptionId = client.SubscriptionId - } - .ResourceGroups; - } - - protected override Task CreateAsync(string location) - => Client.CreateOrUpdateAsync( - Name, - new ResourceGroup { Location = location }); - - protected override Task GetOrThrowAsync() - => Client.GetAsync(Name); - - private IResourceGroupsOperations Client { get; } - - public override string Name { get; } - } -} diff --git a/experiments/Azure.Experiments/Azure.Experiments/Old/ResourceGroupPolicy.cs b/experiments/Azure.Experiments/Azure.Experiments/Old/ResourceGroupPolicy.cs deleted file mode 100644 index 607cb375a54b..000000000000 --- a/experiments/Azure.Experiments/Azure.Experiments/Old/ResourceGroupPolicy.cs +++ /dev/null @@ -1,10 +0,0 @@ -using Microsoft.Azure.Management.ResourceManager.Models; - -namespace Azure.Experiments -{ - public struct ResourceGroupPolicy : IInfoPolicy - { - public string GetLocation(ResourceGroup value) - => value.Location; - } -} diff --git a/experiments/Azure.Experiments/Azure.Experiments/Old/ResourceObject.cs b/experiments/Azure.Experiments/Azure.Experiments/Old/ResourceObject.cs deleted file mode 100644 index e38d790a70fe..000000000000 --- a/experiments/Azure.Experiments/Azure.Experiments/Old/ResourceObject.cs +++ /dev/null @@ -1,26 +0,0 @@ -using System.Collections.Generic; -using System.Linq; - -namespace Azure.Experiments -{ - public abstract class ResourceObject : AzureObject - where T : class - where P : struct, IInfoPolicy - { - public string ResourceGroupName { get; } - - protected ResourceObject( - ResourceGroupObject rg, - IEnumerable dependencies) - : base(dependencies.Concat(new[] { rg })) - { - ResourceGroupName = rg.Name; - } - - protected ResourceObject( - ResourceGroupObject rg) - : this(rg, NoDependencies) - { - } - } -} diff --git a/experiments/Azure.Experiments/Azure.Experiments/Parameters.cs b/experiments/Azure.Experiments/Azure.Experiments/Parameters.cs deleted file mode 100644 index a07169a8a15f..000000000000 --- a/experiments/Azure.Experiments/Azure.Experiments/Parameters.cs +++ /dev/null @@ -1,62 +0,0 @@ -using System.Linq; - -namespace Microsoft.Azure.Experiments -{ - public static class Parameters - { - public static IState GetParameters( - this IResourceConfig config, - string subscription, - string location) - where Config : class - { - var visitor = new Visitor(subscription, location); - visitor.Get(config); - return visitor.Result; - } - - sealed class Visitor : IResourceConfigVisitor - { - public Visitor(string subscription, string location) - { - Subscription = subscription; - Location = location; - } - - public object GetUntyped(IResourceConfig config) - => Result.GetOrAddUntyped(config, () => config.Apply(this)); - - public Config Get(IResourceConfig config) - where Config : class - => GetUntyped(config) as Config; - - public object Visit(ResourceConfig config) - where Config : class - { - foreach (var d in config.Dependencies) - { - GetUntyped(d); - } - var p = config.CreateConfig(Subscription); - config.Policy.SetLocation(p, Location); - return p; - } - - public object Visit( - NestedResourceConfig config) - where Config : class - where ParentConfig : class - { - var result = config.Create(); - config.Policy.Set(Get(config.Parent), config.Name, result); - return result; - } - - string Subscription { get; } - - string Location { get; } - - public State Result { get; } = new State(); - } - } -} diff --git a/experiments/Azure.Experiments/Azure.Experiments/ResourceConfig.cs b/experiments/Azure.Experiments/Azure.Experiments/ResourceConfig.cs deleted file mode 100644 index 138eecd12b48..000000000000 --- a/experiments/Azure.Experiments/Azure.Experiments/ResourceConfig.cs +++ /dev/null @@ -1,81 +0,0 @@ -using Microsoft.Azure.Management.ResourceManager.Models; -using System; -using System.Collections.Generic; -using System.Linq; - -namespace Microsoft.Azure.Experiments -{ - public sealed class ResourceConfig : IResourceConfig - where Config : class - { - public ResourcePolicy Policy { get; } - - public string ResourceGroupName { get; } - - public string Name { get; } - - public Func CreateConfig { get; } - - public IEnumerable Dependencies { get; } - - public ResourceConfig( - ResourcePolicy policy, - string resourceGroupName, - string name, - Func createConfig, - IEnumerable dependencies) - { - Policy = policy; - ResourceGroupName = resourceGroupName; - Name = name; - CreateConfig = createConfig; - Dependencies = dependencies; - } - - public Result Apply(IResourceConfigVisitor visitor) - => visitor.Visit(this); - - public IEnumerable GetId(string subscription) - => new[] - { - "subscriptions", - subscription, - "resourceGroups", - ResourceGroupName - } - .Concat(Policy.GetId(Name)); - } - - public static class ResourceConfig - { - public static ResourceConfig CreateConfig( - this ResourcePolicy policy, - string resourceGroupName, - string name, - Func createConfig = null, - IEnumerable dependencies = null) - where Config : class, new() - => new ResourceConfig( - policy, - resourceGroupName, - name, - createConfig ?? (_ => new Config()), - dependencies.EmptyIfNull()); - - public static ResourceConfig CreateConfig( - this ResourcePolicy policy, - ResourceConfig resourceGroup, - string name, - Func createConfig = null, - IEnumerable dependencies = null) - where Config : class, new() - => policy.CreateConfig( - resourceGroup.Name, - name, - createConfig, - dependencies.EmptyIfNull().Concat(new[] { resourceGroup })); - - public static string IdToString(this IEnumerable id) - => "/" + string.Join("/", id); - } -} diff --git a/experiments/Azure.Experiments/Azure.Experiments/ResourceManager/ResourceGroupPolicy.cs b/experiments/Azure.Experiments/Azure.Experiments/ResourceManager/ResourceGroupPolicy.cs deleted file mode 100644 index a883870eaf32..000000000000 --- a/experiments/Azure.Experiments/Azure.Experiments/ResourceManager/ResourceGroupPolicy.cs +++ /dev/null @@ -1,21 +0,0 @@ -using Microsoft.Azure.Management.ResourceManager; -using Microsoft.Azure.Management.ResourceManager.Models; -using System.Linq; - -namespace Microsoft.Azure.Experiments.ResourceManager -{ - public static class ResourceGroupPolicy - { - public static ResourcePolicy Policy { get; } - = ResourcePolicy.Create( - _ => Enumerable.Empty(), - client => client.ResourceGroups, - p => p.Operations.GetAsync(p.Name, p.CancellationToken), - p => p.Operations.CreateOrUpdateAsync(p.Name, p.Config, p.CancellationToken), - config => config.Location, - (config, location) => config.Location = location); - - public static ResourceConfig CreateResourceGroupConfig(string name) - => Policy.CreateConfig(name, name); - } -} diff --git a/experiments/Azure.Experiments/Azure.Experiments/ResourceName.cs b/experiments/Azure.Experiments/Azure.Experiments/ResourceName.cs deleted file mode 100644 index c3a442f4800e..000000000000 --- a/experiments/Azure.Experiments/Azure.Experiments/ResourceName.cs +++ /dev/null @@ -1,15 +0,0 @@ -namespace Microsoft.Azure.Experiments -{ - public sealed class ResourceName - { - public string ResourceGroupName { get; } - - public string Name { get; } - - public ResourceName(string resourceGroupName, string name) - { - ResourceGroupName = resourceGroupName; - Name = name; - } - } -} diff --git a/experiments/Azure.Experiments/Azure.Experiments/ResourcePolicy.cs b/experiments/Azure.Experiments/Azure.Experiments/ResourcePolicy.cs deleted file mode 100644 index baa93ab21f7d..000000000000 --- a/experiments/Azure.Experiments/Azure.Experiments/ResourcePolicy.cs +++ /dev/null @@ -1,73 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; - -namespace Microsoft.Azure.Experiments -{ - public sealed class ResourcePolicy : IResourcePolicy - { - public Func> GetId { get; } - - public Func, Task> GetAsync { get; } - - public Func, Task> CreateOrUpdateAsync { get; } - - public Func GetLocation { get; } - - public Action SetLocation { get; } - - public ResourcePolicy( - Func> getId, - Func, Task> getAsync, - Func, Task> createOrUpdateAsync, - Func getLocation, - Action setLocation) - { - GetId = getId; - GetAsync = getAsync; - CreateOrUpdateAsync = createOrUpdateAsync; - GetLocation = getLocation; - SetLocation = setLocation; - } - } - - public static class ResourcePolicy - { - public static ResourcePolicy Create( - Func> getId, - Func getOperations, - Func, Task> getAsync, - Func, Task> createOrUpdateAsync, - Func getLocation, - Action setLocation) - where Client : class, IDisposable - { - Operations GetOperations(IClient client) => getOperations(client.GetClient()); - return new ResourcePolicy( - getId, - p => getAsync(GetAsyncParams.Create( - GetOperations(p.Operations), p.ResourceGroupName, p.Name, p.CancellationToken)), - p => createOrUpdateAsync(CreateOrUpdateAsyncParams.Create( - GetOperations(p.Operations), p.ResourceGroupName, p.Name, p.Config, p.CancellationToken)), - getLocation, - setLocation); - } - - public static ResourcePolicy Create( - IEnumerable headers, - Func getOperations, - Func, Task> getAsync, - Func, Task> createOrUpdateAsync, - Func getLocation, - Action setLocation) - where Client : class, IDisposable - => Create( - name => new[] { "providers" }.Concat(headers).Concat(new[] { name }), - getOperations, - getAsync, - createOrUpdateAsync, - getLocation, - setLocation); - } -} diff --git a/experiments/Azure.Experiments/Azure.Experiments/State.cs b/experiments/Azure.Experiments/Azure.Experiments/State.cs deleted file mode 100644 index 587b36a17ab1..000000000000 --- a/experiments/Azure.Experiments/Azure.Experiments/State.cs +++ /dev/null @@ -1,22 +0,0 @@ -using System; -using System.Collections.Concurrent; - -namespace Microsoft.Azure.Experiments -{ - sealed class State : IState - { - public Config GetOrNull(IResourceConfig config) - where Config : class - => Map.TryGetValue(config, out var result) ? result as Config : null; - - public Config GetOrAdd(IResourceConfig config, Func f) - where Config : class - => GetOrAddUntyped(config, f) as Config; - - public object GetOrAddUntyped(IResourceConfig config, Func f) - => Map.GetOrAdd(config, _ => f()); - - ConcurrentDictionary Map { get; } - = new ConcurrentDictionary(); - } -} diff --git a/experiments/Azure.Experiments/Azure.Experiments/StateLocation.cs b/experiments/Azure.Experiments/Azure.Experiments/StateLocation.cs deleted file mode 100644 index a0011a799d87..000000000000 --- a/experiments/Azure.Experiments/Azure.Experiments/StateLocation.cs +++ /dev/null @@ -1,74 +0,0 @@ -using Microsoft.Azure.Management.ResourceManager.Models; -using System.Linq; - -namespace Microsoft.Azure.Experiments -{ - public static class StateLocation - { - public static string GetLocation(this IState state, IResourceConfig config) - => config.Apply(new Visitor(state))?.Location; - - class DependencyLocation - { - public string Location { get; } - - public bool IsCompulsory { get; } - - public DependencyLocation(string location, bool isCompulsory) - { - Location = location; - IsCompulsory = isCompulsory; - } - } - - static DependencyLocation Merge(this DependencyLocation a, DependencyLocation b) - { - if (a == null) - { - return b; - } - if (b == null) - { - return a; - } - - if (a.IsCompulsory != b.IsCompulsory) - { - return a.IsCompulsory ? b : a; - } - - // a.IsCompulsory == b.IsCompulsory - return a.Location == b.Location ? a : new DependencyLocation(null, a.IsCompulsory); - } - - sealed class Visitor : IResourceConfigVisitor - { - public DependencyLocation Visit(ResourceConfig config) - where Config : class - { - var info = State.GetOrNull(config); - return info != null - ? new DependencyLocation( - config.Policy.GetLocation(info), - typeof(Config) != typeof(ResourceGroup)) - : config - .Dependencies - .Select(c => c.Apply(this)) - .Aggregate((DependencyLocation)null, Merge); - } - - public DependencyLocation Visit( - NestedResourceConfig config) - where Config : class - where ParentConfig : class - => config.Parent.Apply(this); - - public Visitor(IState state) - { - State = state; - } - - IState State { get; } - } - } -} diff --git a/experiments/Azure.Experiments/Azure.Experiments/readme.md b/experiments/Azure.Experiments/Azure.Experiments/readme.md deleted file mode 100644 index 11fe75025942..000000000000 --- a/experiments/Azure.Experiments/Azure.Experiments/readme.md +++ /dev/null @@ -1,54 +0,0 @@ -## Stages - -1. Get a current Azure state. Each resource has a function to get information from Azure. - The function is an asynchronous operation. -2. Analyze the state. For example, extract a location from the state. - The analysis is a syncronous operation. On this stage, a user interaction may be required. - All decisions has to be made on this stage. -3. Create a graph of create/update operations. This operation is synchronous. -4. Execute the graph. This operation is asynchronous and may require a progress bar, AsJob etc. - It can also create several resources simultaneously. - -## Policies - -```cs -interface IInfoMap -{ - Info Get(IResourcePolicy info) - where Info : class; -} -interface IResourcePolicy -{ -} -interface IResourcePolicy : IResourcePolicy - where Info : class -{ - IEnumerable Dependencies { get; } - string GetLocation(Info info); - Task CreateAsync(Context context, Info info); -} -interface IResourcePolicy : IResourcePolicy - where Info : class -{ - Task GetAsync(Context context, Id id); -} -sealed class ManagedResourceId -{ - string ResourceGroupName { get; } - string Name { get; } -} -interface IManagedResourcePolicy : IResource -{ - ResourceGroupPolicy - void UpdateInfo(Info info, IInfoMap infoMap); -} -interface IResourceGroupPolicy : IResourcePolicy -{ -} -interface ISubresource : IResource -{ - IResource Parent { get; } - Info Get(ParentInfo parentInfo); - void Set(ParentInfo info, Info info); -} -``` \ No newline at end of file diff --git a/experiments/Azure.Experiments/Tests/AuthenticationResponse.cs b/experiments/Azure.Experiments/Tests/AuthenticationResponse.cs deleted file mode 100644 index dc15f0456c2b..000000000000 --- a/experiments/Azure.Experiments/Tests/AuthenticationResponse.cs +++ /dev/null @@ -1,8 +0,0 @@ -namespace Microsoft.Azure.Experiments.Tests -{ - internal sealed class AuthenticationResponse - { - public string token_type; - public string access_token; - } -} diff --git a/experiments/Azure.Experiments/Tests/Client.cs b/experiments/Azure.Experiments/Tests/Client.cs deleted file mode 100644 index 2952ae10b175..000000000000 --- a/experiments/Azure.Experiments/Tests/Client.cs +++ /dev/null @@ -1,44 +0,0 @@ -using Microsoft.Azure.Management.Compute; -using Microsoft.Azure.Management.Network; -using Microsoft.Azure.Management.ResourceManager; -using System; - -namespace Microsoft.Azure.Experiments.Tests -{ - class Client : IClient - { - public Client(Context context) - { - Context = context; - } - - public Context Context { get; } - - public T GetClient() - where T: class, IDisposable - { - if (typeof(T) == typeof(INetworkManagementClient)) - { - return new NetworkManagementClient(Context.Credentials) - { - SubscriptionId = Context.SubscriptionId - } as T; - } - else if (typeof(T) == typeof(IResourceManagementClient)) - { - return new ResourceManagementClient(Context.Credentials) - { - SubscriptionId = Context.SubscriptionId - } as T; - } - else if (typeof(T) == typeof(IComputeManagementClient)) - { - return new ComputeManagementClient(Context.Credentials) - { - SubscriptionId = Context.SubscriptionId - } as T; - } - throw new Exception("unknown client type"); - } - } -} diff --git a/experiments/Azure.Experiments/Tests/Configuration.cs b/experiments/Azure.Experiments/Tests/Configuration.cs deleted file mode 100644 index 16183a8ee5ed..000000000000 --- a/experiments/Azure.Experiments/Tests/Configuration.cs +++ /dev/null @@ -1,10 +0,0 @@ -namespace Microsoft.Azure.Experiments.Tests -{ - internal sealed class Configuration - { - public string applicationId; - public string tenantId; - public string clientSecret; - public string subscriptionId; - } -} diff --git a/experiments/Azure.Experiments/Tests/Credentials.cs b/experiments/Azure.Experiments/Tests/Credentials.cs deleted file mode 100644 index d54d7a59ebf3..000000000000 --- a/experiments/Azure.Experiments/Tests/Credentials.cs +++ /dev/null @@ -1,16 +0,0 @@ -using Microsoft.Rest; -using Newtonsoft.Json; -using System.IO; - -namespace Microsoft.Azure.Experiments.Tests -{ - internal static class Credentials - { - public static Context Get() - { - var text = File.ReadAllText(@"c:\Users\sergey\Desktop\php-test.json"); - var c = JsonConvert.DeserializeObject(text); - return new Context(new TokenCredentials(new TokenProvider(c)), c.subscriptionId); - } - } -} diff --git a/experiments/Azure.Experiments/Tests/KeyValuePair.cs b/experiments/Azure.Experiments/Tests/KeyValuePair.cs deleted file mode 100644 index 003ac3175fdc..000000000000 --- a/experiments/Azure.Experiments/Tests/KeyValuePair.cs +++ /dev/null @@ -1,10 +0,0 @@ -using System.Collections.Generic; - -namespace Microsoft.Azure.Experiments.Tests -{ - internal static class KeyValuePair - { - public static KeyValuePair Create(K k, V v) - => new KeyValuePair(k, v); - } -} diff --git a/experiments/Azure.Experiments/Tests/NetworkInterfaceTest.cs b/experiments/Azure.Experiments/Tests/NetworkInterfaceTest.cs deleted file mode 100644 index ea48bba110a6..000000000000 --- a/experiments/Azure.Experiments/Tests/NetworkInterfaceTest.cs +++ /dev/null @@ -1,34 +0,0 @@ -using Microsoft.Azure.Experiments.Network; -using Microsoft.Azure.Experiments.ResourceManager; -using System.Threading; -using System.Threading.Tasks; -using Xunit; - -namespace Microsoft.Azure.Experiments.Tests -{ - public class NetworkInterfaceTest - { - [Fact] - public async Task CreateAsyncTest() - { - var rg = ResourceGroupPolicy.CreateResourceGroupConfig("nirg"); - var vn = rg.CreateVirtualNetworkConfig("Vnni", "192.168.0.0/16"); - var sn = vn.CreateSubnet("mysubnet", "192.168.1.0/24"); - var pipa = rg.CreatePublicIPAddressConfig("pipani"); - var nsg = rg.CreateNetworkSecurityGroupConfig("nsgni"); - var ni = rg.CreateNetworkInterfaceConfig("ni", sn, pipa, nsg); - - var client = new Client(Credentials.Get()); - var state = await ni.GetAsync(client, new CancellationToken()); - var location = state.GetLocation(rg); - var parameters = ni.GetParameters(client.Context.SubscriptionId, "eastus"); - var nic = parameters.GetOrNull(ni); - var createState = await ni.CreateOrUpdateAsync( - client, state, parameters, new CancellationToken()); - var nicc = createState.GetOrNull(ni); - Assert.Equal("eastus", nicc.Location); - Assert.Equal("ni", nicc.Name); - Assert.Equal(ni.GetId(client.Context.SubscriptionId).IdToString(), nicc.Id); - } - } -} diff --git a/experiments/Azure.Experiments/Tests/NetworkSecurityGroupTest.cs b/experiments/Azure.Experiments/Tests/NetworkSecurityGroupTest.cs deleted file mode 100644 index 21eaddb22696..000000000000 --- a/experiments/Azure.Experiments/Tests/NetworkSecurityGroupTest.cs +++ /dev/null @@ -1,29 +0,0 @@ -using Microsoft.Azure.Experiments.Network; -using Microsoft.Azure.Experiments.ResourceManager; -using System.Threading; -using System.Threading.Tasks; -using Xunit; - -namespace Microsoft.Azure.Experiments.Tests -{ - public class NetworkSecurityGroupTest - { - [Fact] - public async Task CreateAsyncTest() - { - var rg = ResourceGroupPolicy.CreateResourceGroupConfig("nsgrg"); - var vn = rg.CreateNetworkSecurityGroupConfig("nsg"); - var client = new Client(Credentials.Get()); - var state = await vn.GetAsync(client, new CancellationToken()); - var location = state.GetLocation(rg); - var parameters = vn.GetParameters(client.Context.SubscriptionId, "eastus"); - var vnc = parameters.GetOrNull(vn); - var createState = await vn.CreateOrUpdateAsync( - client, state, parameters, new CancellationToken()); - var vncc = createState.GetOrNull(vn); - Assert.Equal("eastus", vncc.Location); - Assert.Equal("nsg", vncc.Name); - Assert.Equal(vn.GetId(client.Context.SubscriptionId).IdToString(), vncc.Id); - } - } -} diff --git a/experiments/Azure.Experiments/Tests/Old/ComputeTest.cs b/experiments/Azure.Experiments/Tests/Old/ComputeTest.cs deleted file mode 100644 index 2aa10d361269..000000000000 --- a/experiments/Azure.Experiments/Tests/Old/ComputeTest.cs +++ /dev/null @@ -1,102 +0,0 @@ -using Xunit; -using Microsoft.Azure.Management.Compute; -using System.Threading.Tasks; -using Azure.Experiments.Network; -using Azure.Experiments.Compute; - -namespace Azure.Experiments.Tests -{ - public class ComputeTest - { - //[Fact] - public async Task ResourceGroupTest() - { - var c = Microsoft.Azure.Experiments.Tests.Credentials.Get(); - var rg = new ResourceGroupObject(c, "My"); - // - var info = await rg.GetOrNullAsync(); - var infoCreate = await rg.GetOrCreateAsync(); - // await rg.DeleteAsync(c); - } - - //[Fact] - public async Task VirtualNetworkTest() - { - var c = Microsoft.Azure.Experiments.Tests.Credentials.Get(); - var rg = new ResourceGroupObject(c, "My1"); - var vn = new VirtualNetworkObject(c.CreateNetwork(), "My1", rg, "192.168.0.0/16"); - // - var info = await vn.GetOrNullAsync(); - var infoCreate = await vn.GetOrCreateAsync(); - } - - //[Fact] - public async Task PublicIpAddressTest() - { - var c = Microsoft.Azure.Experiments.Tests.Credentials.Get(); - var rg = new ResourceGroupObject(c, "MyPIA"); - var pia = new PublicIpAddressObject(c.CreateNetwork(), "MyPIA", rg); - // - var info = await pia.GetOrCreateAsync(); - } - - //[Fact] - public async Task NetworkSecurityGroupTest() - { - var c = Microsoft.Azure.Experiments.Tests.Credentials.Get(); - var rg = new ResourceGroupObject(c, "MyNSG"); - var nsg = new NetworkSecurityGroupObject(c.CreateNetwork(), "MyNSG", rg); - var info = await nsg.GetOrCreateAsync(); - } - - //[Fact] - public async Task SubnetTest() - { - var c = Microsoft.Azure.Experiments.Tests.Credentials.Get(); - var rg = new ResourceGroupObject(c, "MySubnet"); - var vn = new VirtualNetworkObject(c.CreateNetwork(), "MySubnet", rg, "192.168.0.0/16"); - var subnet = new SubnetObject("MySubnet", vn, "192.168.1.0/24"); - var info = await subnet.GetOrCreateAsync(); - } - - //[Fact] - public async Task NetworkInterfaceObject() - { - var c = Microsoft.Azure.Experiments.Tests.Credentials.Get(); - var network = c.CreateNetwork(); - var rg = new ResourceGroupObject(c, "MyNI"); - var vn = new VirtualNetworkObject(network, "MyNI", rg, "192.168.0.0/16"); - var subnet = new SubnetObject("MyNI", vn, "192.168.1.0/24"); - var pia = new PublicIpAddressObject(network, "MyNI", rg); - var nsg = new NetworkSecurityGroupObject(network, "MyNI", rg); - var ni = new NetworkInterfaceObject(network, "MyNI", rg, subnet, pia, nsg); - var info = await ni.GetOrCreateAsync(); - } - - //[Fact] - public async Task VmObject() - { - var c = Microsoft.Azure.Experiments.Tests.Credentials.Get(); - var network = c.CreateNetwork(); - var rg = new ResourceGroupObject(c, "MyVM"); - var vn = new VirtualNetworkObject(network, "MyVM", rg, "192.168.0.0/16"); - var subnet = new SubnetObject("MyVM", vn, "192.168.1.0/24"); - var pia = new PublicIpAddressObject(network, "MyVM", rg); - var nsg = new NetworkSecurityGroupObject(network, "MyVM", rg); - var ni = new NetworkInterfaceObject(network, "MyVM", rg, subnet, pia, nsg); - var vm = new VirtualMachineObject(c, "MyVM", rg, ni, "MyVMUser", "@3as54dDd"); - var info = await vm.GetOrCreateAsync(); - } - - //[Fact] - public async Task Test1() - { - var c = Microsoft.Azure.Experiments.Tests.Credentials.Get(); - var client = new ComputeManagementClient(c.Credentials) - { - SubscriptionId = c.SubscriptionId - }; - var list = await client.VirtualMachines.ListAllAsync(); - } - } -} diff --git a/experiments/Azure.Experiments/Tests/Old/UnitTests.cs b/experiments/Azure.Experiments/Tests/Old/UnitTests.cs deleted file mode 100644 index 7caeaf594c01..000000000000 --- a/experiments/Azure.Experiments/Tests/Old/UnitTests.cs +++ /dev/null @@ -1,82 +0,0 @@ -using Azure.Experiments.Compute; -using Azure.Experiments.Network; -using Microsoft.Azure.Experiments; -using Microsoft.Rest; -using Xunit; - -namespace Azure.Experiments.Tests -{ - public class UnitTests - { - private static Context C { get; } - = new Context(new TokenCredentials("a"), string.Empty); - - [Fact] - public void ResourceGroupObjectTest() - { - var rg = new ResourceGroupObject(C, "My"); - Assert.Equal(1, rg.Priority); - } - - [Fact] - public void VirtualNetworkObjectTest() - { - var rg = new ResourceGroupObject(C, "My1"); - var vn = new VirtualNetworkObject(C.CreateNetwork(), "My1", rg, "192.168.0.0/16"); - Assert.Equal(2, vn.Priority); - } - - [Fact] - public void PublicIpAddressObjectTest() - { - var rg = new ResourceGroupObject(C, "MyPIA"); - var pia = new PublicIpAddressObject(C.CreateNetwork(), "MyPIA", rg); - Assert.Equal(2, pia.Priority); - } - - //[Fact] - public void NetworkSecurityGroupTest() - { - var c = Microsoft.Azure.Experiments.Tests.Credentials.Get(); - var rg = new ResourceGroupObject(c, "MyNSG"); - var nsg = new NetworkSecurityGroupObject(c.CreateNetwork(), "MyNSG", rg); - Assert.Equal(2, nsg.Priority); - } - - [Fact] - public void SubnetObjectTest() - { - var rg = new ResourceGroupObject(C, "MySubnet"); - var vn = new VirtualNetworkObject(C.CreateNetwork(), "MySubnet", rg, "192.168.0.0/16"); - var subnet = new SubnetObject("MySubnet", vn, "192.168.1.0/24"); - Assert.Equal(3, subnet.Priority); - } - - [Fact] - public void NetworkInterfaceObjectTest() - { - var network = C.CreateNetwork(); - var rg = new ResourceGroupObject(C, "MyNI"); - var vn = new VirtualNetworkObject(network, "MyNI", rg, "192.168.0.0/16"); - var subnet = new SubnetObject("MyNI", vn, "192.168.1.0/24"); - var pia = new PublicIpAddressObject(network, "MyNI", rg); - var nsg = new NetworkSecurityGroupObject(network, "MyNI", rg); - var ni = new NetworkInterfaceObject(network, "MyNI", rg, subnet, pia, nsg); - Assert.Equal(4, ni.Priority); - } - - [Fact] - public void VmObjectTest() - { - var network = C.CreateNetwork(); - var rg = new ResourceGroupObject(C, "MyVM"); - var vn = new VirtualNetworkObject(network, "MyVM", rg, "192.168.0.0/16"); - var subnet = new SubnetObject("MyVM", vn, "192.168.1.0/24"); - var pia = new PublicIpAddressObject(network, "MyVM", rg); - var nsg = new NetworkSecurityGroupObject(network, "MyVM", rg); - var ni = new NetworkInterfaceObject(network, "MyVM", rg, subnet, pia, nsg); - var vm = new VirtualMachineObject(C, "MyVM", rg, ni, "MyVMUser", "@3as54dDd"); - Assert.Equal(5, vm.Priority); - } - } -} diff --git a/experiments/Azure.Experiments/Tests/PublicIPAddressTest.cs b/experiments/Azure.Experiments/Tests/PublicIPAddressTest.cs deleted file mode 100644 index 37c09597ddba..000000000000 --- a/experiments/Azure.Experiments/Tests/PublicIPAddressTest.cs +++ /dev/null @@ -1,29 +0,0 @@ -using Microsoft.Azure.Experiments.Network; -using Microsoft.Azure.Experiments.ResourceManager; -using System.Threading; -using System.Threading.Tasks; -using Xunit; - -namespace Microsoft.Azure.Experiments.Tests -{ - public class PublicIPAddressTest - { - [Fact] - public async Task CreateAsyncTest() - { - var rg = ResourceGroupPolicy.CreateResourceGroupConfig("piparg"); - var vn = rg.CreatePublicIPAddressConfig("pipa"); - var client = new Client(Credentials.Get()); - var state = await vn.GetAsync(client, new CancellationToken()); - var location = state.GetLocation(rg); - var parameters = vn.GetParameters(client.Context.SubscriptionId, "eastus"); - var vnc = parameters.GetOrNull(vn); - var createState = await vn.CreateOrUpdateAsync( - client, state, parameters, new CancellationToken()); - var vncc = createState.GetOrNull(vn); - Assert.Equal("eastus", vncc.Location); - Assert.Equal("pipa", vncc.Name); - Assert.Equal(vn.GetId(client.Context.SubscriptionId).IdToString(), vncc.Id); - } - } -} diff --git a/experiments/Azure.Experiments/Tests/ResourceGroupTest.cs b/experiments/Azure.Experiments/Tests/ResourceGroupTest.cs deleted file mode 100644 index 3e5e70acfffc..000000000000 --- a/experiments/Azure.Experiments/Tests/ResourceGroupTest.cs +++ /dev/null @@ -1,57 +0,0 @@ -using Microsoft.Azure.Experiments.ResourceManager; -using System.Threading; -using System.Threading.Tasks; -using Xunit; - -namespace Microsoft.Azure.Experiments.Tests -{ - public class ResourceGroupTest - { - [Fact] - public void CreateConfigTest() - { - var rg = ResourceGroupPolicy.CreateResourceGroupConfig("new"); - var id = rg.GetId("12345").IdToString(); - Assert.Equal("/subscriptions/12345/resourceGroups/new", id); - } - - [Fact] - public async Task GetAsyncTest() - { - var rg = ResourceGroupPolicy.CreateResourceGroupConfig("new"); - var client = new Client(Credentials.Get()); - var state = await rg.GetAsync(client, new CancellationToken()); - var location = state.GetLocation(rg); - Assert.Null(location); - } - - [Fact] - public async Task CreateParameterTest() - { - var rg = ResourceGroupPolicy.CreateResourceGroupConfig("new"); - var client = new Client(Credentials.Get()); - var state = await rg.GetAsync(client, new CancellationToken()); - var location = state.GetLocation(rg); - var parameters = rg.GetParameters(client.Context.SubscriptionId, "eastus"); - var rgc = parameters.GetOrNull(rg); - Assert.Equal("eastus", rgc.Location); - } - - [Fact] - public async Task CreateAsyncTest() - { - var rg = ResourceGroupPolicy.CreateResourceGroupConfig("new1"); - var client = new Client(Credentials.Get()); - var state = await rg.GetAsync(client, new CancellationToken()); - var location = state.GetLocation(rg); - var parameters = rg.GetParameters(client.Context.SubscriptionId, "eastus"); - var rgc = parameters.GetOrNull(rg); - var createState = await rg.CreateOrUpdateAsync( - client, state, parameters, new CancellationToken()); - var rgcc = createState.GetOrNull(rg); - Assert.Equal("eastus", rgcc.Location); - Assert.Equal("new1", rgcc.Name); - Assert.Equal(rg.GetId(client.Context.SubscriptionId).IdToString(), rgcc.Id); - } - } -} diff --git a/experiments/Azure.Experiments/Tests/SubnetTest.cs b/experiments/Azure.Experiments/Tests/SubnetTest.cs deleted file mode 100644 index b0273e1a0775..000000000000 --- a/experiments/Azure.Experiments/Tests/SubnetTest.cs +++ /dev/null @@ -1,30 +0,0 @@ -using Microsoft.Azure.Experiments.Network; -using Microsoft.Azure.Experiments.ResourceManager; -using System.Threading; -using System.Threading.Tasks; -using Xunit; - -namespace Microsoft.Azure.Experiments.Tests -{ - public class SubnetTest - { - [Fact] - public async Task CreateAsyncTest() - { - var rg = ResourceGroupPolicy.CreateResourceGroupConfig("Snrg"); - var vn = rg.CreateVirtualNetworkConfig("Vn", "192.168.0.0/16"); - var sn = vn.CreateSubnet("mysubnet", "192.168.1.0/24"); - - var client = new Client(Credentials.Get()); - var state = await sn.GetAsync(client, new CancellationToken()); - var location = state.GetLocation(rg); - var parameters = sn.GetParameters(client.Context.SubscriptionId, "eastus"); - var snc = parameters.GetOrNull(sn); - var createState = await sn.CreateOrUpdateAsync( - client, state, parameters, new CancellationToken()); - var sncc = createState.GetOrNull(sn); - Assert.Equal("mysubnet", sncc.Name); - Assert.Equal(sn.GetId(client.Context.SubscriptionId).IdToString(), sncc.Id); - } - } -} diff --git a/experiments/Azure.Experiments/Tests/Tests.csproj b/experiments/Azure.Experiments/Tests/Tests.csproj deleted file mode 100644 index daf903087c4a..000000000000 --- a/experiments/Azure.Experiments/Tests/Tests.csproj +++ /dev/null @@ -1,23 +0,0 @@ - - - - netcoreapp2.0;net452 - - false - - Tests - - Microsoft.Azure.Experiments.Tests - - - - - - - - - - - - - diff --git a/experiments/Azure.Experiments/Tests/TokenProvider.cs b/experiments/Azure.Experiments/Tests/TokenProvider.cs deleted file mode 100644 index 41fc440cd6f1..000000000000 --- a/experiments/Azure.Experiments/Tests/TokenProvider.cs +++ /dev/null @@ -1,54 +0,0 @@ -using Microsoft.Rest; -using System.Net.Http.Headers; -using System.Threading; -using System.Threading.Tasks; -using System.Net.Http; -using System; -using Newtonsoft.Json; - -namespace Microsoft.Azure.Experiments.Tests -{ - sealed class TokenProvider : ITokenProvider - { - public TokenProvider(Configuration c) - { - var parameters = new[] - { - KeyValuePair.Create("grant_type", "client_credentials"), - KeyValuePair.Create("client_id", c.applicationId), - KeyValuePair.Create("client_secret", c.clientSecret), - KeyValuePair.Create("resource", "https://management.core.windows.net/") - }; - Content = new FormUrlEncodedContent(parameters); - Uri = new Uri("https://login.microsoftonline.com/" + c.tenantId + "/oauth2/token"); - } - - public async Task GetAuthenticationHeaderAsync( - CancellationToken cancellationToken) - { - if (Header == null) - { - using (var client = new HttpClient()) - { - var response = await client - .PostAsync(Uri, Content) - .Result - .Content - .ReadAsStringAsync(); - var responseObject = JsonConvert.DeserializeObject( - response); - Header = new AuthenticationHeaderValue( - responseObject.token_type, - responseObject.access_token); - } - } - return Header; - } - - private Uri Uri { get; } - - private FormUrlEncodedContent Content { get; } - - private AuthenticationHeaderValue Header { get; set; } - } -} diff --git a/experiments/Azure.Experiments/Tests/VirtualMachineTest.cs b/experiments/Azure.Experiments/Tests/VirtualMachineTest.cs deleted file mode 100644 index f9a6012e142e..000000000000 --- a/experiments/Azure.Experiments/Tests/VirtualMachineTest.cs +++ /dev/null @@ -1,36 +0,0 @@ -using Microsoft.Azure.Experiments.Compute; -using Microsoft.Azure.Experiments.Network; -using Microsoft.Azure.Experiments.ResourceManager; -using System.Threading; -using System.Threading.Tasks; -using Xunit; - -namespace Microsoft.Azure.Experiments.Tests -{ - public sealed class VirtualMachineTest - { - [Fact] - public async Task CreateAsyncTest() - { - var rg = ResourceGroupPolicy.CreateResourceGroupConfig("vmrg"); - var vn = rg.CreateVirtualNetworkConfig("Vnni", "192.168.0.0/16"); - var sn = vn.CreateSubnet("mysubnet", "192.168.1.0/24"); - var pipa = rg.CreatePublicIPAddressConfig("pipavm"); - var nsg = rg.CreateNetworkSecurityGroupConfig("nsgvm"); - var ni = rg.CreateNetworkInterfaceConfig("nivm", sn, pipa, nsg); - var vm = rg.CreateVirtualMachineConfig("vm", ni, "MyVMUser", "@3as54dDd"); - - var client = new Client(Credentials.Get()); - var state = await vm.GetAsync(client, new CancellationToken()); - var location = state.GetLocation(rg); - var parameters = vm.GetParameters(client.Context.SubscriptionId, "eastus"); - var vmc = parameters.GetOrNull(vm); - var createState = await vm.CreateOrUpdateAsync( - client, state, parameters, new CancellationToken()); - var vmcc = createState.GetOrNull(vm); - Assert.Equal("eastus", vmcc.Location); - Assert.Equal("vm", vmcc.Name); - Assert.Equal(vm.GetId(client.Context.SubscriptionId).IdToString(), vmcc.Id); - } - } -} diff --git a/experiments/Azure.Experiments/Tests/VirtualNetworkTest.cs b/experiments/Azure.Experiments/Tests/VirtualNetworkTest.cs deleted file mode 100644 index 963e6694fb6e..000000000000 --- a/experiments/Azure.Experiments/Tests/VirtualNetworkTest.cs +++ /dev/null @@ -1,30 +0,0 @@ -using Microsoft.Azure.Experiments.Network; -using Microsoft.Azure.Experiments.ResourceManager; -using System.Threading; -using System.Threading.Tasks; -using Xunit; - -namespace Microsoft.Azure.Experiments.Tests -{ - public class VirtualNetworkTest - { - [Fact] - public async Task CreateAsyncTest() - { - var rg = ResourceGroupPolicy.CreateResourceGroupConfig("vnnew"); - var vn = rg.CreateVirtualNetworkConfig("vn", "192.168.0.0/16"); - var client = new Client(Credentials.Get()); - var state = await vn.GetAsync(client, new CancellationToken()); - var location = state.GetLocation(rg); - var parameters = vn.GetParameters(client.Context.SubscriptionId, "eastus"); - var vnc = parameters.GetOrNull(vn); - var createState = await vn.CreateOrUpdateAsync( - client, state, parameters, new CancellationToken()); - var vncc = createState.GetOrNull(vn); - Assert.Equal("eastus", vncc.Location); - Assert.Equal("192.168.0.0/16", vncc.AddressSpace.AddressPrefixes[0]); - Assert.Equal("vn", vncc.Name); - Assert.Equal(vn.GetId(client.Context.SubscriptionId).IdToString(), vncc.Id); - } - } -} diff --git a/experiments/Compute.Experiments/AzureRM.Compute.Experiments-help.xml b/experiments/Compute.Experiments/AzureRM.Compute.Experiments-help.xml deleted file mode 100644 index 058e230cbb7e..000000000000 --- a/experiments/Compute.Experiments/AzureRM.Compute.Experiments-help.xml +++ /dev/null @@ -1,385 +0,0 @@ - - - - -New-AzVm -New -AzVm -Creates a virtual machine and all required resources. - - - -The cmdlet creates a virtual machine and all required resources in Azure. - - -New-AzVm -Name -A name of a virtual machine. - - -String -String - -None - -Credential -Specifies the user name and password for the virtual machine as a PSCredential object. - - -PSCredential -PSCredential - -None - -ImageName -A name of virtual machine image. - - -String -String - -None - -ResourceGroupName -Specifies the name of a resource group. - - -String -String - -None - -Location -Specifies a location for the virtual machine. - - -String -String - -None - -VirtualNetworkName -Specifies a Virtual Network name. - - -String -String - -None - -PublicIpAddressName -Specifies a name of PublicIPAddress object to assign to a network interface. - - -String -String - -None - -SecurityGroupName -Specifies a Network Security Group name. - - -String -String - -None - -AddressPrefix -Specifies a range of IP addresses for a virtual network. - - -String -String - -None - -AllocationMethod -Specifies the method with which to allocate the public IP address. The acceptable values for this parameter are: Static or Dynamic. - - -String -String - -None - -AsJob -Specifies the cmdlet executes as a job. - - -SwitchParameter - -False - -AzureRmContext -Azure context. - - -Object -Object - -None - -DomainNameLabel -Specifies the relative DNS name for a public IP address. - - -String -String - -None - -OpenPorts -Ports. - - -Int32[] -Int32[] - -None - -Size -Specifies the size for the virtual machine. - - -String -String - -None - -SubnetAddressPrefix -Specifies a range of IP addresses for a subnet configuration. - - -String -String - -None - -SubnetName -Specifies the name of the subnet configuration to create. - - -String -String - -None - -Confirm -Prompts you for confirmation before running the cmdlet. - - -SwitchParameter - -False - -WhatIf -Shows what would happen if the cmdlet runs. The cmdlet is not run. - - -SwitchParameter - -False - - - -AddressPrefix -Specifies a range of IP addresses for a virtual network. - - -String -String - -None - -AllocationMethod -Specifies the method with which to allocate the public IP address. The acceptable values for this parameter are: Static or Dynamic. - - -String -String - -None - -AsJob -Specifies the cmdlet executes as a job. - - -SwitchParameter -SwitchParameter - -False - -AzureRmContext -Azure context. - - -Object -Object - -None - -Credential -Specifies the user name and password for the virtual machine as a PSCredential object. - - -PSCredential -PSCredential - -None - -DomainNameLabel -Specifies the relative DNS name for a public IP address. - - -String -String - -None - -ImageName -A name of virtual machine image. - - -String -String - -None - -Location -Specifies a location for the virtual machine. - - -String -String - -None - -Name -A name of a virtual machine. - - -String -String - -None - -OpenPorts -Ports. - - -Int32[] -Int32[] - -None - -PublicIpAddressName -Specifies a name of PublicIPAddress object to assign to a network interface. - - -String -String - -None - -ResourceGroupName -Specifies the name of a resource group. - - -String -String - -None - -SecurityGroupName -Specifies a Network Security Group name. - - -String -String - -None - -Size -Specifies the size for the virtual machine. - - -String -String - -None - -SubnetAddressPrefix -Specifies a range of IP addresses for a subnet configuration. - - -String -String - -None - -SubnetName -Specifies the name of the subnet configuration to create. - - -String -String - -None - -VirtualNetworkName -Specifies a Virtual Network name. - - -String -String - -None - -Confirm -Prompts you for confirmation before running the cmdlet. - - -SwitchParameter -SwitchParameter - -False - -WhatIf -Shows what would happen if the cmdlet runs. The cmdlet is not run. - - -SwitchParameter -SwitchParameter - -False - - -None - - - - - - -System.Object - - - - - - - - - - -Example 1 -PS C:\> New-AzVm -Name MyCoolVM -Creates a virtual machine with name `MyCoolVM`. - - - - - - - diff --git a/experiments/Compute.Experiments/AzureRM.Compute.Experiments.Tests.ps1 b/experiments/Compute.Experiments/AzureRM.Compute.Experiments.Tests.ps1 deleted file mode 100644 index 2d2c31f85214..000000000000 --- a/experiments/Compute.Experiments/AzureRM.Compute.Experiments.Tests.ps1 +++ /dev/null @@ -1,53 +0,0 @@ -$build = Resolve-Path "..\build\" -$out = Join-Path $build "AzureRM.Compute.Experiments\" -Copy-Item .\AzureRM.Compute.Experiments.psd1 $out -Copy-Item .\AzureRM.Compute.Experiments.psm1 $out -Copy-Item ..\Azure.Experiments\Azure.Experiments\bin\Debug\net452\*.dll $out - -$env:PSModulePath = $env:PSModulePath + ";" + $build.ToString() - -# Login -$credentials = Get-Content -Path "C:\Users\sergey\Desktop\php-test.json" | ConvertFrom-Json -$clientSecret = ConvertTo-SecureString $credentials.clientSecret -AsPlainText -Force -$pscredentials = New-Object System.Management.Automation.PSCredential($credentials.applicationId, $clientSecret) -Login-AzureRmAccount -ServicePrincipal -Credential $pscredentials -TenantId $credentials.tenantId | Out-Null - -$vmComputerPassword = $credentials.vmPassword; -$vmComputerUser = $credentials.vmUser; -$password = ConvertTo-SecureString $vmComputerPassword -AsPlainText -Force; -$vmCredential = New-Object System.Management.Automation.PSCredential ($vmComputerUser, $password); - -Describe 'New-AzVm' { - It 'WhatIf' { - $result = New-AzVm -Name MyVM -Credential $vmCredential -WhatIf - } - <# - It 'Create Windows VM' { - Remove-AzureRmResourceGroup -Name Something1 -Force - - $result = New-AzVm -Name MyVMA1 -Credential $vmCredential -ResourceGroupName Something1 -Verbose - - $result.Name | Should Be MyVMA1 - } - It 'Create Linux VM' { - $context = Get-AzureRmContext - $result = New-AzVm ` - -Name X2 ` - -Credential $vmCredential ` - -Location westus2 ` - -ResourceGroupName Something1 ` - -AzureRmContext $context ` - -ImageName UbuntuLTS ` - -Verbose - $result.Name | Should Be X2 - } - It 'Create Linux VM AsJob' { - Remove-AzureRmResourceGroup -Name MyVMA3 -Force - - $job = New-AzVm -Name MyVMA3 -Credential $vmCredential -AsJob -ImageName UbuntuLTS -Verbose - $result = Receive-Job $job -Wait -Verbose - - $result.Name | Should Be MyVMA3 - } - #> -} diff --git a/experiments/Compute.Experiments/AzureRM.Compute.Experiments.psd1 b/experiments/Compute.Experiments/AzureRM.Compute.Experiments.psd1 deleted file mode 100644 index 85e74c5523c0..000000000000 --- a/experiments/Compute.Experiments/AzureRM.Compute.Experiments.psd1 +++ /dev/null @@ -1,126 +0,0 @@ -# -# Module manifest for module 'AzureRM.Compute.Experiments' -# -# Generated by: Microsoft -# -# Generated on: 9/1/2017 -# - -@{ - -# Script module or binary module file associated with this manifest. -RootModule = ".\AzureRM.Compute.Experiments.psm1" - -# Version number of this module. -ModuleVersion = '1.0.29' - -# Supported PSEditions -# CompatiblePSEditions = @() - -# ID used to uniquely identify this module -GUID = 'b5a94030-df85-43fa-b581-54069f88428f' - -# Author of this module -Author = 'Microsoft' - -# Company or vendor of this module -CompanyName = 'Microsoft' - -# Copyright statement for this module -Copyright = 'Microsoft' - -# Description of the functionality provided by this module -Description = 'Azure Compute experiments for VM creation' - -# Minimum version of the Windows PowerShell engine required by this module -PowerShellVersion = '5.0' - -# Name of the Windows PowerShell host required by this module -# PowerShellHostName = '' - -# Minimum version of the Windows PowerShell host required by this module -# PowerShellHostVersion = '' - -# Minimum version of Microsoft .NET Framework required by this module. This prerequisite is valid for the PowerShell Desktop edition only. -DotNetFrameworkVersion = '4.5.2' - -# Minimum version of the common language runtime (CLR) required by this module. This prerequisite is valid for the PowerShell Desktop edition only. -# CLRVersion = '' - -# Processor architecture (None, X86, Amd64) required by this module -# ProcessorArchitecture = '' - -# Modules that must be imported into the global environment prior to importing this module -RequiredModules = @( - @{ ModuleName = "AzureRM.Resources"; ModuleVersion = "4.4.0"; }, - @{ ModuleName = "AzureRM.Network"; ModuleVersion = "4.4.0"; }, - @{ ModuleName = "AzureRM.Compute"; ModuleVersion = "3.4.0"; } -) - -# Assemblies that must be loaded prior to importing this module -RequiredAssemblies = @("Azure.Experiments.dll") - -# Script files (.ps1) that are run in the caller's environment prior to importing this module. -# ScriptsToProcess = @() - -# Type files (.ps1xml) to be loaded when importing this module -# TypesToProcess = @() - -# Format files (.ps1xml) to be loaded when importing this module -# FormatsToProcess = @() - -# Modules to import as nested modules of the module specified in RootModule/ModuleToProcess -# NestedModules = @() - -# Functions to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no functions to export. -FunctionsToExport = 'New-AzVm' - -# Cmdlets to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no cmdlets to export. -# CmdletsToExport = - -# Variables to export from this module -VariablesToExport = '*' - -# Aliases to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no aliases to export. -AliasesToExport = @() - -# DSC resources to export from this module -# DscResourcesToExport = @() - -# List of all modules packaged with this module -# ModuleList = @() - -# List of all files packaged with this module -# FileList = @() - -# Private data to pass to the module specified in RootModule/ModuleToProcess. This may also contain a PSData hashtable with additional module metadata used by PowerShell. -PrivateData = @{ - - PSData = @{ - - # Tags applied to this module. These help with module discovery in online galleries. - # Tags = @() - - # A URL to the license for this module. - # LicenseUri = '' - - # A URL to the main website for this project. - # ProjectUri = '' - - # A URL to an icon representing this module. - # IconUri = '' - - # ReleaseNotes of this module - # ReleaseNotes = '' - - } # End of PSData hashtable - -} # End of PrivateData hashtable - -# HelpInfo URI of this module -# HelpInfoURI = '' - -# Default prefix for commands exported from this module. Override the default prefix using Import-Module -Prefix. -# DefaultCommandPrefix = '' - -} diff --git a/experiments/Compute.Experiments/AzureRM.Compute.Experiments.psm1 b/experiments/Compute.Experiments/AzureRM.Compute.Experiments.psm1 deleted file mode 100644 index 69da2c77b4b3..000000000000 --- a/experiments/Compute.Experiments/AzureRM.Compute.Experiments.psm1 +++ /dev/null @@ -1,749 +0,0 @@ -<# -.ExternalHelp AzureRM.Compute.Experiments-help.xml -#> -function New-AzVm { - [CmdletBinding(SupportsShouldProcess = $true)] - param ( - [Parameter(Mandatory=$true, Position=0)][string] $Name = "VM", - [Parameter(Mandatory=$true)][PSCredential] $Credential, - - [Parameter()][string] $ResourceGroupName = $Name, - [Parameter()][string] $Location, - - [Parameter()][string] $VirtualNetworkName = $Name, - [Parameter()][string] $AddressPrefix = "192.168.0.0/16", - - [Parameter()][string] $SubnetName = $Name, - [Parameter()][string] $SubnetAddressPrefix = "192.168.1.0/24", - - [Parameter()][string] $PublicIpAddressName = $Name, - [Parameter()][string] $DomainNameLabel = $Name + $ResourceGroupName, - [Parameter()][ValidateSet("Static", "Dynamic")][string] $AllocationMethod = "Static", - - [Parameter()][string] $SecurityGroupName = $Name, - [Parameter()][int[]] $OpenPorts, - - [Parameter()][string] $ImageName = "Win2016Datacenter", - [Parameter()][string] $Size = "Standard_DS1_v2", - - [Parameter()][object] $AzureRmContext, - [Parameter()][switch] $AsJob - ) - - PROCESS { - $x = New-Object Azure.Experiments.Context($null, $null) - Write-Host "X: " + $x - - # TODO: make sure it's logged in. - $context = if ($AzureRmContext) { - Get-AzureRmContext -AzureRmContext $AzureRmContext - } else { - Get-AzureRmContext - } - - # find image - $image = Get-Image($ImageName) - - # ports - if (!$OpenPorts) { - switch ($image.Type) { - "Windows" { - $OpenPorts = @(3389, 5985) - } - "Linux" { - $OpenPorts = @(22) - } - } - } - - $rgi = [ResourceGroup]::new($ResourceGroupName) - - $vni = [VirtualNetwork]::new($VirtualNetworkName, $rgi, $AddressPrefix) - $subnet = [Subnet]::new($SubnetName, $vni, $SubnetAddressPrefix) - $piai = [PublicIpAddress]::new($PublicIpAddressName, $rgi, $DomainNameLabel, $AllocationMethod) - $sgi = [SecurityGroup]::new($SecurityGroupName, $rgi, $OpenPorts) - - # we don't allow to reuse NetworkInterface - $nii = [NetworkInterface]::new( - $Name, - $rgi, - $subnet, - $piai, - $sgi) - - # the purpouse of the New-AzVm cmdlet is to create (not get) a VM so $name is $null. - $vmi = [VirtualMachine]::new( - $Name, - $rgi, - $nii, - $Credential, - $image, - $Size) - - # infer a location - $locationi = [Location]::new() - if (-not $Location) { - $vmi.UpdateLocation($locationi, $context) - if (-not $locationi.Value) { - $locationi.Value = "eastus" - } - } else { - $locationi.Value = $Location - } - - $createParams = [CreateParams]::new($locationi.Value, $context) - - if ($PSCmdlet.ShouldProcess($Name, "Creating a virtual machine")) { - if ($AsJob) { - $boundParams = $PSCmdlet.MyInvocation.BoundParameters - $arguments = @{ 'AzureRmContext' = $context } - foreach ($argName in $boundParams.Keys) { - if ($argName -ne 'AsJob' -and $argName -ne 'AzureRmContext') { - $arguments[$argName] = $boundParams[$argName] - } - } - $script = { - [hashtable] $params = $args[0] - New-AzVm @params - } - - $jobName = "Creating VM $Name" - return Start-Job -Name $jobName -ScriptBlock $script -ArgumentList $arguments - } else { - $vm = $vmi.GetOrCreate($createParams, [ProgressRange]::new(0.0, 1.0)) - Write-Progress "Done." -Completed - $fqdn = $piai.DomainNameLabel + "." + $locationi.Value + ".cloudapp.azure.com" - switch ($image.Type) { - "Windows" { - Write-Verbose ("Use 'mstsc /v:$fqdn' to connect to the VM." ) - } - "Linux" { - Write-Verbose ("Use 'ssh $($Credential.UserName)@$fqdn' to connect to the VM." ) - } - } - return [PSAzureVm]::new($vm, $fqdn) - } - } - } -} - -class PSAzureVm { - [Microsoft.Azure.Commands.Compute.Models.PSVirtualMachine] $Vm; - [string] $Name; - [string] $ResourceGroupName; - [string] $Fqdn; - - PSAzureVm([Microsoft.Azure.Commands.Compute.Models.PSVirtualMachine] $vm, [string] $fqdn) { - $this.Vm = $vm - $this.Name = $vm.Name - $this.ResourceGroupName = $vm.ResourceGroupName - $this.Fqdn = $fqdn - } -} - -class Location { - [int] $Priority; - [string] $Value; - - Location() { - $this.Priority = 0 - $this.Value = $null - } -} - -class CreateParams { - [string] $Location; - [object] $Context; - - CreateParams( - [string] $location, - [object] $context) - { - $this.Location = $location - $this.Context = $context - } -} - -class ProgressRange { - [double] $Start; - [double] $Size; - - ProgressRange([double] $start, [double] $size) { - $this.Start = $start; - $this.Size = $size; - } -} - -class AzureObject { - [string] $Name; - [AzureObject[]] $Children; - [int] $Priority; - [int] $ObjectSize; - - [bool] $GetInfoCalled = $false; - [object] $info = $null; - - AzureObject([string] $name, [AzureObject[]] $children) { - $this.Name = $name - $this.Children = $children - $this.Priority = 0 - $this.ObjectSize = 1 - foreach ($child in $this.Children) { - if ($this.Priority -lt $child.Priority) { - $this.Priority = $child.Priority - } - $this.ObjectSize += $child.ObjectSize - } - $this.Priority++ - } - - [string] GetResourceType() { - return $null - } - - [object] GetInfoOrThrow([object] $context) { - return $null - } - - [object] Create([CreateParams] $p) { - return $null - } - - [object] GetInfo([object] $context) { - if (!$this.GetInfoCalled) { - $this.GetInfoCalled = $true - try { - $this.Info = $this.GetInfoOrThrow($context) - if ($this.Info) { - Write-Verbose ("Found '" + $this.Name + "' " + $this.GetResourceType() + ".") - } - } catch { - # ignore all errors - } - } - return $this.Info; - } - - [void] UpdateLocation([Location] $location, [object] $context) { - if ($this.Priority -gt $location.Priority) { - if ($this.Name) { - $i = $this.GetInfo($context) - if ($i) { - $location.Value = $i.Location - $location.Priority = $this.Priority - return; - } - } - foreach ($child in $this.Children) { - $child.UpdateLocation($location, $context) - } - } - } - - [object] GetOrCreate([CreateParams] $p, [ProgressRange] $progressRange) { - $i = $this.GetInfo($p.Context) - if ($i) { - return $i - } - $pSize = $progressRange.Size / $this.ObjectSize - $offset = $progressRange.Start - foreach ($child in $this.Children) { - $pChildSize = $pSize * $child.ObjectSize - $pc = [ProgressRange]::new($offset, $pChildSize) - $child.GetOrCreate($p, $pc) | Out-Null - $offset += $pChildSize - } - $message = "Creating '" + $this.Name + "' " + $this.GetResourceType() + "." - $percent = [convert]::ToInt32($offset * 100) - Write-Progress $message -PercentComplete $percent -Status "$percent% Complete:" - Write-Verbose $message - $this.Info = $this.Create($p) - return $this.Info - } -} - -class ResourceGroup: AzureObject { - ResourceGroup([string] $name): base($name, @()) { - } - - [string] GetResourceType() { - return "Resource Group" - } - - [object] GetInfoOrThrow([object] $context) { - return Get-AzureRmResourceGroup ` - -Name $this.Name ` - -AzureRmContext $context ` - -ErrorAction Stop - } - - [object] Create([CreateParams] $p) { - return New-AzureRmResourceGroup ` - -Name $this.Name ` - -Location $p.Location ` - -AzureRmContext $p.Context ` - -WarningAction SilentlyContinue ` - -ErrorAction Stop - } -} - -class Resource1: AzureObject { - [ResourceGroup] $ResourceGroup; - - Resource1( - [string] $name, - [ResourceGroup] $resourceGroup, - [AzureObject[]] $children - ): base($name, @($resourceGroup) + $children) { - $this.ResourceGroup = $resourceGroup - } - - Resource1( - [string] $name, - [ResourceGroup] $resourceGroup - ): base($name, @($resourceGroup)) { - $this.ResourceGroup = $resourceGroup - } - - [string] GetResourceGroupName() { - return $this.ResourceGroup.Info.ResourceGroupName; - } -} - -class VirtualNetwork: Resource1 { - [string] $AddressPrefix; - - VirtualNetwork( - [string] $name, - [ResourceGroup] $resourceGroup, - [string] $addressPrefix - ): base($name, $resourceGroup) { - $this.AddressPrefix = $addressPrefix - } - - [string] GetResourceType() { - return "Virtual Network" - } - - [object] GetInfoOrThrow([object] $context) { - return Get-AzureRmVirtualNetwork ` - -ResourceGroupName $this.ResourceGroup.Name ` - -Name $this.Name ` - -AzureRmContext $context ` - -ErrorAction Stop - } - - [object] Create([CreateParams] $p) { - return New-AzureRmVirtualNetwork ` - -ResourceGroupName $this.GetResourceGroupName() ` - -Location $p.Location ` - -Name $this.Name ` - -AddressPrefix $this.AddressPrefix ` - -AzureRmContext $p.Context ` - -WarningAction SilentlyContinue ` - -ErrorAction Stop - } -} - -class PublicIpAddress: Resource1 { - [string] $DomainNameLabel; - [string] $AllocationMethod; - - PublicIpAddress( - [string] $name, - [ResourceGroup] $resourceGroup, - [string] $domainNameLabel, - [string] $allocationMethod - ): base($name, $resourceGroup) { - $this.DomainNameLabel = $domainNameLabel.ToLower() - $this.AllocationMethod = $allocationMethod - } - - [string] GetResourceType() { - return "Public IP Address" - } - - [object] GetInfoOrThrow([object] $context) { - return Get-AzureRMPublicIpAddress ` - -ResourceGroupName $this.ResourceGroup.Name ` - -Name $this.Name ` - -AzureRmContext $context ` - -ErrorAction Stop - } - - [object] Create([CreateParams] $p) { - return New-AzureRmPublicIpAddress ` - -ResourceGroupName $this.GetResourceGroupName() ` - -Location $p.Location ` - -Name $this.Name ` - -DomainNameLabel $this.DomainNameLabel ` - -AllocationMethod $this.AllocationMethod ` - -AzureRmContext $p.Context ` - -WarningAction SilentlyContinue ` - -ErrorAction Stop - } -} - -class SecurityGroup: Resource1 { - [int[]] $OpenPorts; - - SecurityGroup( - [string] $name, - [ResourceGroup] $resourceGroup, - [int[]] $OpenPorts - ): base($name, $resourceGroup) { - $this.OpenPorts = $OpenPorts - } - - [string] GetResourceType() { - return "Security Group" - } - - [object] GetInfoOrThrow([object] $context) { - return Get-AzureRmNetworkSecurityGroup ` - -ResourceGroupName $this.ResourceGroup.Name ` - -Name $this.Name ` - -AzureRmContext $context ` - -ErrorAction Stop - } - - [object] Create([CreateParams] $p) { - $rules = New-Object ` - "System.Collections.Generic.List[Microsoft.Azure.Commands.Network.Models.PSSecurityRule]" - $priority = 1000 - foreach ($port in $this.OpenPorts) { - $name = $this.Name + $port - $securityRuleConfig = New-AzureRmNetworkSecurityRuleConfig ` - -Name $name ` - -Protocol "Tcp" ` - -Priority $priority ` - -Access "Allow" ` - -Direction "Inbound" ` - -SourcePortRange "*" ` - -SourceAddressPrefix "*" ` - -DestinationPortRange $port ` - -DestinationAddressPrefix "*" ` - -ErrorAction Stop - $rules.Add($securityRuleConfig) - ++$priority - } - return New-AzureRmNetworkSecurityGroup ` - -ResourceGroupName $this.GetResourceGroupName() ` - -Location $p.Location ` - -Name $this.Name ` - -SecurityRules $rules ` - -AzureRmContext $p.Context ` - -WarningAction SilentlyContinue ` - -ErrorAction Stop - } -} - -class Subnet: AzureObject { - [VirtualNetwork] $VirtualNetwork; - [string] $SubnetAddressPrefix; - - Subnet([string] $name, [VirtualNetwork] $virtualNetwork, [string] $subnetAddressPrefix): - base($name, @($virtualNetwork)) { - $this.VirtualNetwork = $virtualNetwork - $this.SubnetAddressPrefix = $subnetAddressPrefix - } - - [string] GetResourceType() { - return "Subnet" - } - - [object] GetInfoFromVirtualNetworkInfo([object] $virtualNetworkInfo) { - return $virtualNetworkInfo ` - | Get-AzureRmVirtualNetworkSubnetConfig -Name $this.Name -ErrorAction Stop - } - - [object] GetInfoOrThrow([object] $context) { - $virtualNetworkInfo = $this.VirtualNetwork.GetInfo($context) - if ($virtualNetworkInfo) { - return $this.GetInfoFromVirtualNetworkInfo($virtualNetworkInfo) - } - return $null - } - - [object] Create([CreateParams] $p) { - $virtualNetworkInfo = $this.VirtualNetwork.Info - try { - return $this.GetInfoFromVirtualNetworkInfo($virtualNetworkInfo) - } catch { - } - $virtualNetworkInfo = Add-AzureRmVirtualNetworkSubnetConfig ` - -VirtualNetwork $virtualNetworkInfo ` - -Name $this.Name ` - -AddressPrefix $this.SubnetAddressPrefix - $virtualNetworkInfo = Set-AzureRmVirtualNetwork ` - -VirtualNetwork $virtualNetworkInfo ` - -AzureRmContext $p.Context ` - -ErrorAction Stop - return $this.GetInfoFromVirtualNetworkInfo($virtualNetworkInfo) - } -} - -class NetworkInterface: Resource1 { - [Subnet] $Subnet; - [PublicIpAddress] $PublicIpAddress; - [SecurityGroup] $SecurityGroup; - - NetworkInterface( - [string] $name, - [ResourceGroup] $resourceGroup, - [Subnet] $subnet, - [PublicIpAddress] $publicIpAddress, - [SecurityGroup] $securityGroup - ): base($name, $resourceGroup, @($subnet, $publicIpAddress, $securityGroup)) { - $this.Subnet = $subnet - $this.PublicIpAddress = $publicIpAddress - $this.SecurityGroup = $securityGroup - } - - [string] GetResourceType() { - return "Network Interface" - } - - [object] GetInfoOrThrow([object] $context) { - return Get-AzureRMNetworkInterface ` - -ResourceGroupName $this.ResourceGroup.Name ` - -Name $this.Name ` - -AzureRmContext $context ` - -ErrorAction Stop - } - - [object] Create([CreateParams] $p) { - $publicIpAddressInfo = $this.PublicIpAddress.Info - $subnetInfo = $this.Subnet.Info - $securityGroupInfo = $this.SecurityGroup.Info - return New-AzureRmNetworkInterface ` - -ResourceGroupName $this.ResourceGroup.Name ` - -Location $p.Location ` - -Name $this.Name ` - -PublicIpAddressId $publicIpAddressInfo.Id ` - -SubnetId $subnetInfo.Id ` - -NetworkSecurityGroupId $securityGroupInfo.Id ` - -AzureRmContext $p.Context ` - -WarningAction SilentlyContinue ` - -ErrorAction Stop - } -} - -class VirtualMachine: Resource1 { - [NetworkInterface] $NetworkInterface; - [pscredential] $Credential; - [object] $Image; - [string] $Size; - - VirtualMachine( - [string] $name, - [ResourceGroup] $resourceGroup, - [NetworkInterface] $networkInterface, - [PSCredential] $credential, - [object] $image, - [string] $size): - base($name, $resourceGroup, @($networkInterface)) { - - $this.Credential = $credential - $this.NetworkInterface = $networkInterface - $this.Image = $image - $this.Size = $size - } - - [string] GetResourceType() { - return "Virtual Machine" - } - - [object] GetInfoOrThrow([object] $context) { - return Get-AzureRmVM ` - -ResourceGroupName $this.ResourceGroup.Name ` - -Name $this.Name ` - -AzureRmContext $context ` - -ErrorAction Stop - } - - [object] Create([CreateParams] $p) { - $networkInterfaceInstance = $this.NetworkInterface.Info - - $vmConfig = New-AzureRmVMConfig ` - -VMName $this.Name ` - -VMSize $this.Size ` - -ErrorAction Stop - $vmConfig = $vmConfig | Set-AzureRmVMBootDiagnostics -Disable -ErrorAction Stop - $vmComputerName = $this.Name - switch ($this.Image.Type) { - "Windows" { - $vmConfig = $vmConfig | Set-AzureRmVMOperatingSystem ` - -Windows ` - -ComputerName $vmComputerName ` - -Credential $this.Credential ` - -ErrorAction Stop - } - "Linux" { - $vmConfig = $vmConfig | Set-AzureRmVMOperatingSystem ` - -Linux ` - -ComputerName $vmComputerName ` - -Credential $this.Credential ` - -ErrorAction Stop - } - } - - $vmImageImage = $this.Image.Image - $vmConfig = $vmConfig ` - | Set-AzureRmVMSourceImage ` - -PublisherName $vmImageImage.publisher ` - -Offer $vmImageImage.offer ` - -Skus $vmImageImage.sku ` - -Version $vmImageImage.version ` - -ErrorAction Stop ` - | Add-AzureRmVMNetworkInterface ` - -Id $networkInterfaceInstance.Id ` - -ErrorAction Stop - - $rgName = $this.GetResourceGroupName() - New-AzureRmVm ` - -ResourceGroupName $rgName ` - -Location $p.Location ` - -VM $vmConfig ` - -AzureRmContext $p.Context ` - -WarningAction SilentlyContinue ` - -ErrorAction Stop ` - | Out-Null - - return $this.GetInfoOrThrow($p.Context) - } -} - -function New-PsObject { - param([hashtable] $property) - - New-Object psobject -Property $property -} - -$staticImages = New-PsObject @{ - Linux = New-PsObject @{ - CentOS = New-PsObject @{ - publisher = "OpenLogic"; - offer = "CentOS"; - sku = "7.3"; - version = "latest"; - }; - CoreOS = New-PsObject @{ - publisher = "CoreOS"; - offer = "CoreOS"; - sku = "Stable"; - version = "latest"; - }; - Debian = New-PsObject @{ - publisher = "credativ"; - offer = "Debian"; - sku = "8"; - version = "latest"; - }; - "openSUSE-Leap" = New-PsObject @{ - publisher = "SUSE"; - offer = "openSUSE-Leap"; - sku = "42.2"; - version = "latest"; - }; - RHEL = New-PsObject @{ - publisher = "RedHat"; - offer = "RHEL"; - sku = "7.3"; - version = "latest"; - }; - SLES = New-PsObject @{ - publisher = "SUSE"; - offer = "SLES"; - sku = "12-SP2"; - version = "latest"; - }; - UbuntuLTS = New-PsObject @{ - publisher = "Canonical"; - offer = "UbuntuServer"; - sku = "16.04-LTS"; - version = "latest"; - }; - }; - Windows = New-PsObject @{ - Win2016Datacenter = New-PsObject @{ - publisher = "MicrosoftWindowsServer"; - offer = "WindowsServer"; - sku = "2016-Datacenter"; - version = "latest"; - }; - Win2012R2Datacenter = New-PsObject @{ - publisher = "MicrosoftWindowsServer"; - offer = "WindowsServer"; - sku = "2012-R2-Datacenter"; - version = "latest"; - }; - Win2012Datacenter = New-PsObject @{ - publisher = "MicrosoftWindowsServer"; - offer = "WindowsServer"; - sku = "2012-Datacenter"; - version = "latest"; - }; - Win2008R2SP1 = New-PsObject @{ - publisher = "MicrosoftWindowsServer"; - offer = "WindowsServer"; - sku = "2008-R2-SP1"; - version = "latest"; - }; - }; -} - -# Images -# an array of @{ Type = ...; Name = ...; Image = ... } -# $images = $jsonImages.outputs.aliases.value.psobject.Properties | ForEach-Object { -$images = $staticImages.psobject.Properties | ForEach-Object { - # e.g. "Linux" - $type = $_.Name - $_.Value.psobject.Properties | ForEach-Object { - New-Object -TypeName psobject -Property @{ - # e.g. "Linux" - Type = $type; - # e.g. "CentOs" - Name = $_.Name; - # e.g. @{ publisher = "OpenLogic"; offer = "CentOS"; sku = "7.3"; version = "latest" } - Image = $_.Value - } - } -} - -function Get-Image([string] $imageName) { - $vmImage = $images | Where-Object { $_.Name -eq $imageName } | Select-Object -First 1 - if (-not $vmImage) { - throw "Unknown image: " + $this.ImageName - } - return $vmImage -} - -Export-ModuleMember -Function New-AzVm - -$locations = $null - -function Get-WordToCompleteList { - param($List, $WordToComplete) - - return $List ` - | Where-Object { $_ -like "$WordToComplete*" } ` - | ForEach-Object { [System.Management.Automation.CompletionResult]::new($_) } -} - -Register-ArgumentCompleter -CommandName New-AzVm -ParameterName Location -ScriptBlock { - param($commandName, $parameterName, $wordToComplete, $commandAst, $fakeBoundParameter) - - if (!$global:locations) { - $global:locations = Get-AzureRmLocation ` - | ForEach-Object { $_.Location } - } - return Get-WordToCompleteList -List $global:locations -WordToComplete $wordToComplete -} - -Register-ArgumentCompleter -CommandName New-AzVm -ParameterName ImageName -ScriptBlock { - param($commandName, $parameterName, $wordToComplete, $commandAst, $fakeBoundParameter) - - $list = $images | ForEach-Object { $_.Name } - return Get-WordToCompleteList -List $list -WordToComplete $wordToComplete -} diff --git a/experiments/Compute.Experiments/AzureRM.Compute.Experiments.test.ps1 b/experiments/Compute.Experiments/AzureRM.Compute.Experiments.test.ps1 deleted file mode 100644 index fc1ad746fcf7..000000000000 --- a/experiments/Compute.Experiments/AzureRM.Compute.Experiments.test.ps1 +++ /dev/null @@ -1,9 +0,0 @@ - -$clientSecret = ConvertTo-SecureString ([Guid]::NewGuid().ToString().Substring(1,10)) -AsPlainText -Force -$pscredentials = New-Object System.Management.Automation.PSCredential("vmadmin", $clientSecret) -New-AzVm -Name myVm1234 -Credential $pscredentials -WhatIf -$vm = New-AzVm -Name myVm1234 -Credential $pscredentials -$vm - -#Cleanup -Remove-AzureRmResourceGroup -ResourceName $vm.Vm.ResourceGroupName -Force \ No newline at end of file diff --git a/experiments/Compute.Experiments/copy-dev.ps1 b/experiments/Compute.Experiments/copy-dev.ps1 deleted file mode 100644 index 05011d312d45..000000000000 --- a/experiments/Compute.Experiments/copy-dev.ps1 +++ /dev/null @@ -1,7 +0,0 @@ -param([string] $Config="Release") - -$outPath = Join-Path $PSScriptRoot -ChildPath "..\..\src\Package\$Config\ResourceManager\AzureResourceManager\AzureRM.Compute.Experiments\" -Write-Host $outPath -Copy-Item -Path $PSScriptRoot -Destination $outPath -Recurse -Exclude "AzureRM.Compute.Experiments.Tests.ps1", "publish-dev.ps1", "copy-dev.ps1" -Force - - diff --git a/experiments/Compute.Experiments/help/AzureRM.Compute.Experiments.md b/experiments/Compute.Experiments/help/AzureRM.Compute.Experiments.md deleted file mode 100644 index c1a421dc17b2..000000000000 --- a/experiments/Compute.Experiments/help/AzureRM.Compute.Experiments.md +++ /dev/null @@ -1,16 +0,0 @@ ---- -Module Name: AzureRM.Compute.Experiments -Module Guid: b5a94030-df85-43fa-b581-54069f88428f -Download Help Link: -Help Version: -Locale: ---- - -# AzureRM.Compute.Experiments Module -## Description -Cmdlets experiments for user interface improvements in Virtual Machine creation. - -## AzureRM.Compute.Experiments Cmdlets -### [New-AzVm](New-AzVm.md) -Creates a virtual machine and all required resources. - diff --git a/experiments/Compute.Experiments/help/New-AzVm.md b/experiments/Compute.Experiments/help/New-AzVm.md deleted file mode 100644 index fb3dca5e579b..000000000000 --- a/experiments/Compute.Experiments/help/New-AzVm.md +++ /dev/null @@ -1,338 +0,0 @@ ---- -external help file: AzureRM.Compute.Experiments-help.xml -Module Name: AzureRM.Compute.Experiments -online version: -schema: 2.0.0 ---- - -# New-AzVm - -## SYNOPSIS -Creates a virtual machine and all required resources. - -## SYNTAX - -``` -New-AzVm [-Name] [-Credential] [[-ResourceGroupName] ] [[-Location] ] - [[-VirtualNetworkName] ] [-AddressPrefix ] [-SubnetName ] - [-SubnetAddressPrefix ] [[-PublicIpAddressName] ] [-DomainNameLabel ] - [-AllocationMethod ] [[-SecurityGroupName] ] [-OpenPorts ] [[-ImageName] ] - [-Size ] [-AzureRmContext ] [-AsJob] [-WhatIf] [-Confirm] [] -``` - -## DESCRIPTION -The cmdlet creates a virtual machine and all required resources in Azure. - -## EXAMPLES - -### Example 1 -``` -PS C:\> New-AzVm -Name MyCoolVM -``` - -Creates a virtual machine with name `MyCoolVM`. - -## PARAMETERS - -### -AddressPrefix -Specifies a range of IP addresses for a virtual network. - -```yaml -Type: String -Parameter Sets: (All) -Aliases: - -Required: False -Position: Named -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -AllocationMethod -Specifies the method with which to allocate the public IP address. The acceptable values for this parameter are: Static or Dynamic. - -```yaml -Type: String -Parameter Sets: (All) -Aliases: - -Required: False -Position: Named -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -AsJob -Specifies the cmdlet executes as a job. - -```yaml -Type: SwitchParameter -Parameter Sets: (All) -Aliases: - -Required: False -Position: Named -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -AzureRmContext -Azure context. - -```yaml -Type: Object -Parameter Sets: (All) -Aliases: - -Required: False -Position: Named -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -Credential - -Specifies the user name and password for the virtual machine as a PSCredential object. - -```yaml -Type: PSCredential -Parameter Sets: (All) -Aliases: - -Required: True -Position: 1 -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -DomainNameLabel - -Specifies the relative DNS name for a public IP address. - -```yaml -Type: String -Parameter Sets: (All) -Aliases: - -Required: False -Position: Named -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -ImageName -A name of virtual machine image. - -```yaml -Type: String -Parameter Sets: (All) -Aliases: - -Required: False -Position: 2 -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -Location -Specifies a location for the virtual machine. - -```yaml -Type: String -Parameter Sets: (All) -Aliases: - -Required: False -Position: 4 -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -Name -A name of a virtual machine. - -```yaml -Type: String -Parameter Sets: (All) -Aliases: - -Required: True -Position: 0 -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -OpenPorts -Ports. - -```yaml -Type: Int32[] -Parameter Sets: (All) -Aliases: - -Required: False -Position: Named -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -PublicIpAddressName -Specifies a name of PublicIPAddress object to assign to a network interface. - -```yaml -Type: String -Parameter Sets: (All) -Aliases: - -Required: False -Position: 6 -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -ResourceGroupName -Specifies the name of a resource group. - -```yaml -Type: String -Parameter Sets: (All) -Aliases: - -Required: False -Position: 3 -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -SecurityGroupName -Specifies a Network Security Group name. - -```yaml -Type: String -Parameter Sets: (All) -Aliases: - -Required: False -Position: 7 -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -Size -Specifies the size for the virtual machine. - -```yaml -Type: String -Parameter Sets: (All) -Aliases: - -Required: False -Position: Named -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -SubnetAddressPrefix -Specifies a range of IP addresses for a subnet configuration. - -```yaml -Type: String -Parameter Sets: (All) -Aliases: - -Required: False -Position: Named -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -SubnetName -Specifies the name of the subnet configuration to create. - -```yaml -Type: String -Parameter Sets: (All) -Aliases: - -Required: False -Position: Named -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -VirtualNetworkName -Specifies a Virtual Network name. - -```yaml -Type: String -Parameter Sets: (All) -Aliases: - -Required: False -Position: 5 -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -Confirm -Prompts you for confirmation before running the cmdlet. - -```yaml -Type: SwitchParameter -Parameter Sets: (All) -Aliases: cf - -Required: False -Position: Named -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -WhatIf -Shows what would happen if the cmdlet runs. The cmdlet is not run. - -```yaml -Type: SwitchParameter -Parameter Sets: (All) -Aliases: wi - -Required: False -Position: Named -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### CommonParameters -This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters (http://go.microsoft.com/fwlink/?LinkID=113216). - -## INPUTS - -### None - -## OUTPUTS - -### System.Object - -## NOTES - -## RELATED LINKS - diff --git a/experiments/Compute.Experiments/publish-dev.ps1 b/experiments/Compute.Experiments/publish-dev.ps1 deleted file mode 100644 index be188be87ef2..000000000000 --- a/experiments/Compute.Experiments/publish-dev.ps1 +++ /dev/null @@ -1,15 +0,0 @@ -$out = "..\build\AzureRM.Compute.Experiments\" -$repository = "sergey" -$dep = @("AzureRM.Resources", "AzureRM.Network", "AzureRM.Compute") -Remove-Item $out -Recurse -mkdir $out -Copy-Item .\AzureRM.Compute.Experiments.psd1 $out -Copy-Item .\AzureRM.Compute.Experiments.psm1 $out -New-ExternalHelp -Path .\help\ -OutputPath $out -# foreach ($d in $dep) { -# Install-Module $d -Repository $repository -# } -Publish-Module -Path $out -Repository $repository -NuGetApiKey somekey -# foreach ($d in $dep) { -# Uninstall-Module $d -# } diff --git a/experiments/Websites.Experiments/AzureRM.Websites.Experiments.Tests.ps1 b/experiments/Websites.Experiments/AzureRM.Websites.Experiments.Tests.ps1 deleted file mode 100644 index 008011ebc2e1..000000000000 --- a/experiments/Websites.Experiments/AzureRM.Websites.Experiments.Tests.ps1 +++ /dev/null @@ -1,1176 +0,0 @@ -# ---------------------------------------------------------------------------------- -# -# 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. -# ---------------------------------------------------------------------------------- - - -InModuleScope AzureRM.Websites.Experiments { - - function Get-AzureRmAppServicePlanMock { - param( - [string]$PlanName, - [string]$GroupName, - [object[]]$Plans - ) - if ($PlanName -and $GroupName){ - return @{Id=$PlanName;Name=$PlanName;ResourceGroup=$GroupName} - } else { - return $Plans - } - } - - function Get-AzureRmResourceGroupMock { - param( - [string]$Name, - [object[]]$Groups - ) - - return $Groups | Where-Object {$_.ResourceGroupName -eq $Name} - } - - Describe "Get-WebAppName "{ - $randomNumber = 1 - $defaultName = "WebApp$randomNumber" - Context "[mock] When name is not provided: " { - Mock Get-Random {return $randomNumber} - Mock Test-NameAvailability {return $true} - - $result = Get-WebAppName -ProvidedParameters @{} - - It "Returns string with defaultName" { - $result | Should BeOfType System.String - $result | Should Be $defaultName - } - } - - Context "[mock] When name is provided and - name is available: " { - $customName = "customName" - Mock Test-NameAvailability {return $true} - - $result = Get-WebAppName -ProvidedParameters @{WebAppName=$customName} - - It "Returns a string with provided name" { - $result | Should BeOfType System.String - $result | Should Be $customName - } - } - - Context "[mock] When name is provided and - name is NOT available: " { - $customName = "customName" - Mock Test-NameAvailability {return $false} - - It "Should throw." { - {$result = Get-WebAppName -ProvidedParameters @{WebAppName=$customName}} | Should Throw - } - } - } - - Describe "Get-ResourceGroupInfo "{ - $webAppName = "MyWebAppName1" - Context "[mock] When a ResourceGroupName is not provided and - WebAppName is not equal to an existing resource group: " { - Mock Test-ResourceGroupExistence {return $false} - - $result = Get-ResourceGroupInfo ` - -ProvidedParameters @{} ` - -WebAppName $webAppName - - It "Returns a hashtable." { - $result | Should BeOfType System.Collections.Hashtable - } - - It "Returns a hashtable with key 'Name' set to same value as webAppName." { - $result.Name| Should Be $webAppName - } - - It "Returns a hashtable with key 'Exists' set to 'False'." { - $result.Exists | Should Be $false - } - } - - Context "[mock] When a ResourceGroupName is not provided and - WebAppName is equal to an existing resource group: " { - Mock Test-ResourceGroupExistence {return $true} - - $result = Get-ResourceGroupInfo ` - -ProvidedParameters @{} ` - -WebAppName $webAppName - - It "Returns a hashtable." { - $result | Should BeOfType System.Collections.Hashtable - } - - It "Returns a hashtable with key 'Name' set to same value as webAppName." { - $result.Name| Should Be $webAppName - } - - It "Returns a hashtable with key 'Exists' set to 'False'." { - $result.Exists | Should Be $true - } - } - - Context "[mock] When a ResourceGroupName is provided and - that name does not already exist: " { - $customName = "customName" - Mock Test-ResourceGroupExistence {return $false} - - $result = Get-ResourceGroupInfo ` - -ProvidedParameters @{ResourceGroupName=$customName} ` - -WebAppName $webAppName - - It "Returns a hashtable." { - $result | Should BeOfType System.Collections.Hashtable - } - - It "Returns a hashtable with key 'Name' set to same value as provided name." { - $result.Name| Should Be $customName - } - - It "Returns a hashtable with key 'Exists' set to 'False'." { - $result.Exists | Should Be $false - } - } - - Context "[mock] When a ResourceGroupName is provided and - that name already exists: " { - $customName = "customName" - Mock Test-ResourceGroupExistence {return $true} - - $result = Get-ResourceGroupInfo ` - -ProvidedParameters @{ResourceGroupName=$customName} ` - -WebAppName $webAppName - - It "Returns a hashtable." { - $result | Should BeOfType System.Collections.Hashtable - } - - It "Returns a hashtable with key 'Name' set to same value as provided name." { - $result.Name| Should Be $customName - } - - It "Returns a hashtable with key 'Exists' set to 'True'." { - $result.Exists | Should Be $true - } - } - } - - - Describe "Get-AppServicePlanInfo" { - $webAppName = "MyWebAppName1" - Context "When no parameters are provided and - there is not a default app service plan: " { - $plan1 = @{Id="plan1";Name="plan1";Sku=@{Tier="Basic"};ResourceGroup="group1"} - $plan2 = @{Id="plan2";Name="plan2";Sku=@{Tier="Basic"};ResourceGroup="group2"} - $plans = @($plan1,$plan2) - $groupName = "group1" - Mock Get-AzureRmAppServicePlan {return $plans} - - $result = Get-AppServicePlanInfo ` - -ProvidedParameters @{} ` - -WebAppName $webAppName ` - -ResourceGroupName $groupName - - It "Returns a hashtable. " { - $result | Should BeOfType System.Collections.Hashtable - } - - It "Returns a hashtable with key 'Name' set to same value as the WebAppName. " { - $result.Name | Should Be $webAppName - } - - It "Returns a hashtable with key 'Exists' set to 'False'. " { - $result.Exists | Should Be $false - } - - It "Returns a hashtable with key 'ResourceGroup' set to ResourceGroupName passed. " { - $result.ResourceGroup | Should Be $groupName - } - - It "Returns a hashtable with key 'IsDefaultPlan' set to 'False'. " { - $result.IsDefaultPlan | Should Be $false - } - } - - Context "When no parameters are provided and - there is a default app service plan: " { - $plan1 = @{Id="plan1";Name="plan1";Sku=@{Tier="Basic"};ResourceGroup="group1"} - $plan2 = @{Id="plan2Id";Name="plan2";Sku=@{Tier="Free"};ResourceGroup="group2"} - $plan3 = @{Id="plan3Id";Name="plan3";Sku=@{Tier="Free"};ResourceGroup="group3"} - $plans = @($plan1,$plan2,$plan3) - $groupName = "group1" - Mock Get-AzureRmAppServicePlan {return $plans} - - $result = Get-AppServicePlanInfo ` - -ProvidedParameters @{} ` - -WebAppName $webAppName ` - -ResourceGroupName $groupName - - It "Returns a hashtable. " { - $result | Should BeOfType System.Collections.Hashtable - } - - It "Returns a hashtable with key 'Name' set to same vaue as the first plan with default characteristics. " { - $result.Name | Should Be $plan2.Name - } - - It "Returns a hashtable with key 'Exists' set 'True'. " { - $result.Exists | Should Be $true - } - - It "Returns a hashtable with key 'ResourceGroup' set to same value as the first default plan's resource group. " { - $result.ResourceGroup | Should Be $plan2.ResourceGroup - } - - It "Returns a hashtable with key 'IsDefaultPlan' set to 'False'. " { - $result.IsDefaultPlan | Should Be $true - } - } - - Context "When an Id is provided and - plan name exists and - group provided matches the provided in the id: " { - $planName = "plan1" - $groupName = "group1" - $planId = "/subscriptions/f30a7701-df2c-4bc7-ba8d-ab11861ca13c/resourceGroups/$groupName/providers/Microsoft.Web/serverfarms/$planName" - $plan1 = @{Id=$planId;Name=$planName;Sku=@{Tier="Basic"};ResourceGroup=$groupName} - $plan2 = @{Id="plan2Id";Name="plan2";Sku=@{Tier="Free"};ResourceGroup="group2"} - $plan3 = @{Id="plan3Id";Name="plan3";Sku=@{Tier="Free"};ResourceGroup="group3"} - $plans = @($plan1,$plan2,$plan3) - Mock Get-AzureRmAppServicePlan {return $plans} - - $result = Get-AppServicePlanInfo ` - -ProvidedParameters @{AppServicePlan=$planId} ` - -WebAppName $webAppName ` - -ResourceGroupName $groupName - - It "Returns a hashtable. " { - $result | Should BeOfType System.Collections.Hashtable - } - - It "Returns a hashtable with key 'Name' set to same vaue as the plan wiht matching ID. " { - $result.Name | Should Be $planName - } - - It "Returns a hashtable with key 'Exists' set 'True'. " { - $result.Exists | Should Be $true - } - - It "Returns a hashtable with key 'ResourceGroup' set to same resource group found in the ID. " { - $result.ResourceGroup | Should Be $groupName - } - - It "Returns a hashtable with key 'IsDefaultPlan' set to 'False'. " { - $result.IsDefaultPlan | Should Be $false - } - } - - Context "When an Id is provided and - the Id does not belong to any existent plan: " { - $planName = "plan1" - $groupName = "group1" - $planId = "/subscriptions/f30a7701-df2c-4bc7-ba8d-ab11861ca13c/resourceGroups/$groupName/providers/Microsoft.Web/serverfarms/$planName" - $plan2 = @{Id="plan2Id";Name="plan2";Sku=@{Tier="Free"};ResourceGroup="group2"} - $plan3 = @{Id="plan3Id";Name="plan3";Sku=@{Tier="Free"};ResourceGroup="group3"} - $plans = @($plan2,$plan3) - Mock Get-AzureRmAppServicePlan {return $plans} - - It "Should throw. " { - { - $result = Get-AppServicePlanInfo ` - -ProvidedParameters @{AppServicePlan=$planId} ` - -WebAppName $webAppName ` - -ResourceGroupName $nonMatchingGroupName - } | Should Throw - } - } - - Context "When a plan name is provided and - the plan name does not exist: " { - $planName = "customName" - $groupName = "customGroup" - $plan1 = @{Id="plan1Id";Name="plan1";Sku=@{Tier="Free"};ResourceGroup="group1"} - $plan2 = @{Id="plan2Id";Name="plan2";Sku=@{Tier="Free"};ResourceGroup="group2"} - $plans = @($plan1,$plan2) - Mock Get-AzureRmAppServicePlan {return $plans} - - $result = Get-AppServicePlanInfo ` - -ProvidedParameters @{AppServicePlan=$planName} ` - -WebAppName $webAppName ` - -ResourceGroupName $groupName - - It "Returns a hashtable. " { - $result | Should BeOfType System.Collections.Hashtable - } - - It "Returns a hashtable with key 'Name' set to same name provided. " { - $result.Name | Should Be $planName - } - - It "Returns a hashtable with key 'Exists' set 'False'. " { - $result.Exists | Should Be $false - } - - It "Returns a hashtable with key 'ResourceGroup' set to ResourceGroupName passed. " { - $result.ResourceGroup | Should Be $groupName - } - - It "Returns a hashtable with key 'IsDefaultPlan' set to 'False'. " { - $result.IsDefaultPlan | Should Be $false - } - } - - Context "When a plan name is provided and - plan name exists and - there are various plans with the same name and - a Resource Group matching ResourceGroupName passed contains that plan name : " { - $existingPlanName = "existingPlan" - $groupName = "existingGroup" - $plan1 = @{Id="plan1Id";Name=$existingPlanName;Sku=@{Tier="Free"};ResourceGroup="group1"} - $plan2 = @{Id="plan2Id";Name=$existingPlanName;Sku=@{Tier="Free"};ResourceGroup=$groupName} - $plan3 = @{Id="plan3Id";Name="plan3";Sku=@{Tier="Free"};ResourceGroup="group3"} - $plans = @($plan1,$plan2,$plan3) - Mock Get-AzureRmAppServicePlan {return $plans} - - $result = Get-AppServicePlanInfo ` - -ProvidedParameters @{AppServicePlan=$existingPlanName} ` - -WebAppName $webAppName ` - -ResourceGroupName $groupName - - It "Returns a hashtable. " { - $result | Should BeOfType System.Collections.Hashtable - } - - It "Returns a hashtable with key 'Name' set to same name provided. " { - $result.Name | Should Be $existingPlanName - } - - It "Returns a hashtable with key 'Exists' set to 'True'. " { - $result.Exists | Should Be $true - } - - It "Returns a hashtable with key 'ResourceGroup' set to passed ResourceGroupName. " { - $result.ResourceGroup | Should Be $groupName - } - - It "Returns a hashtable with key 'IsDefaultPlan' set to 'False'. " { - $result.IsDefaultPlan | Should Be $false - } - } - - Context "When a plan name is provided and - plan name exists and - there are various plans with the same name and - a there is not Resource Group matching ResourceGroupName passed which contains that plan name : " { - $existingPlanName = "customPlan" - $groupName = "customGroup" - $plan1 = @{Id="plan1Id";Name=$existingPlanName;Sku=@{Tier="Free"};ResourceGroup="group1"} - $plan2 = @{Id="plan2Id";Name=$existingPlanName;Sku=@{Tier="Free"};ResourceGroup="group2"} - $plan3 = @{Id="plan3Id";Name="plan3";Sku=@{Tier="Free"};ResourceGroup="group3"} - $plans = @($plan1,$plan2,$plan3) - Mock Get-AzureRmAppServicePlan {return $plans} - - It "Should Throw. " { - { - $result = Get-AppServicePlanInfo ` - -ProvidedParameters @{AppServicePlan=$existingPlanName} ` - -WebAppName $webAppName ` - -ResourceGroupName $groupName - } | Should Throw - } - } - - Context "When a plan name is provided and - plan name exists and - there is one with that same name and - a there is not Resource Group matching ResourceGroupName passed which contains that plan name : " { - $existingPlanName = "customPlan" - $existingPlanGroup = "customGroup" - $groupName = "passedGroup" - $plan1 = @{Id="plan1Id";Name=$existingPlanName;Sku=@{Tier="Free"};ResourceGroup=$existingPlanGroup} - $plan2 = @{Id="plan2Id";Name="plan2";Sku=@{Tier="Free"};ResourceGroup="group2"} - $plan3 = @{Id="plan3Id";Name="plan3";Sku=@{Tier="Free"};ResourceGroup="group3"} - $plans = @($plan1,$plan2,$plan3) - Mock Get-AzureRmAppServicePlan {return $plans} - - $result = Get-AppServicePlanInfo ` - -ProvidedParameters @{AppServicePlan=$existingPlanName} ` - -WebAppName $webAppName ` - -ResourceGroupName $groupName - - It "Returns a hashtable. " { - $result | Should BeOfType System.Collections.Hashtable - } - - It "Returns a hashtable with key 'Name' set to same name provided. " { - $result.Name | Should Be $existingPlanName - } - - It "Returns a hashtable with key 'Exists' set to 'True'. " { - $result.Exists | Should Be $true - } - - It "Returns a hashtable with key 'ResourceGroup' set to passed ResourceGroupName. " { - $result.ResourceGroup | Should Be $existingPlanGroup - } - - It "Returns a hashtable with key 'IsDefaultPlan' set to 'False'. " { - $result.IsDefaultPlan | Should Be $false - } - - } - } - - Describe "Get-AppLocation" { - $defaultLocation = "West Europe" - Mock Get-DefaultLocation {return $defaultLocation} - Context "When a location is not provided and - ResourceGroupName passed does not exist."{ - $groupName = "customGroup" - $resourceGroupExists = $false - - $result = Get-AppLocation -ProvidedParameters @{} -ResourceGroupName $groupName -ResourceGroupExists $resourceGroupExists - - It "Returns a string with default location. " { - $result | Should BeOfType System.String - $result | Should Be $defaultLocation - } - } - - Context "When a location is not provided and - ResourceGroupName passed exists."{ - $groupName = "customGroup" - $groupLocation = "customGroupLocation" - $group1 = @{ResourceGroupName=$groupName;Location=$groupLocation} - $group2 = @{ResourceGroupName="group2";Location="loc2"} - $groups = @($group1,$group2) - $resourceGroupExists = $true - Mock Get-AzureRmResourceGroup {return $groups | Where-Object {$_.ResourceGroupName -eq $Name}} - - $result = Get-AppLocation -ProvidedParameters @{} -ResourceGroupName $groupName -ResourceGroupExists $resourceGroupExists - - It "Returns a string with default location. " { - $result | Should BeOfType System.String - $result | Should Be $groupLocation - } - } - - Context "When a location is provided."{ - $providedLocation = "customLocation" - - $result = Get-AppLocation -ProvidedParameters @{Location=$providedLocation} - - It "Returns a string with the provided location. " { - $result | Should BeOfType System.String - $result | Should Be $providedLocation - } - } - } - - Describe "New-AzWebAppJustDoIt"{ - $randomNumber = 1 - $defaultName = "WebApp$randomNumber" - $defaultLocation = "West Europe" - Mock Get-Random {return $randomNumber} - Mock Get-DefaultLocation {return $defaultLocation} - $validLocations = @("loc1","loc2","loc3") - Mock Get-AzureRmResourceProvider{return @(@{ProviderNamespace="Microsoft.Web";Locations=$validLocations})} - Mock Get-Context {} - Mock Get-WebSitesClient {} - Mock Get-ResourceManagementClient {} - Context "[mock] When no parameters are provided and - there is not default plan: " { - $plan1 = @{Id="plan1";Name="plan1";Sku=@{Tier="Basic"};ResourceGroup="group1"} - $plan2 = @{Id="plan2Id";Name="plan2";Sku=@{Tier="Basic"};ResourceGroup="group2"} - $plans = @($plan1,$plan2) - Mock Test-NameAvailability {return $true} - Mock Test-ResourceGroupExistence {return $false} - Mock Get-AzureRmAppServicePlan {return Get-AzureRmAppServicePlanMock $Name $ResourceGroupName $plans} - Mock New-AzureRmResourceGroup {return @{ResourceGroupName=$Name;Location=$Location}} - Mock New-AzureRmAppServicePlan {return @{Id=$Name;Name=$Name;Location=$Location;Sku=@{Tier=$Tier};ResourcerGroupName=$ResourceGroupName}} - Mock New-AzureRmWebApp {return @{Name=$Name;ResourceGroupName=$ResourceGroupName;AppServicePlan=$AppServicePlan;Location=$Location}} - - $result = New-AzWebAppJustDoIt - - It "Returns Site with default name." { - $result.Name | Should be $defaultName - } - - It "Returns Site with a NEW ResourceGroup with same name as the webapp." { - $result.ResourceGroupName | Should be $defaultName - $result.ResourceGroupName | Should be $result.Name - } - - It "Returns Site with default location." { - $result.Location | Should be $defaultLocation - } - - It "Returns Site with a NEW AppServicePlan with same name as the webapp." { - $result.AppServicePlan | Should be $defaultName - $result.AppServicePlan | Should be $result.Name - } - } - - Context "[mock] When name is provided and - there is not default plan: " { - $plan1 = @{Id="plan1";Name="plan1";Sku=@{Tier="Basic"};ResourceGroup="group1"} - $plan2 = @{Id="plan2Id";Name="plan2";Sku=@{Tier="Basic"};ResourceGroup="group2"} - $plans = @($plan1,$plan2) - $customName = "customName" - Mock Test-NameAvailability {return $true} - Mock Test-ResourceGroupExistence {return $false} - Mock Get-AzureRmAppServicePlan {return Get-AzureRmAppServicePlanMock $Name $ResourceGroupName $appPlans} - Mock New-AzureRmResourceGroup {return @{ResourceGroupName=$Name;Location=$Location}} - Mock New-AzureRmAppServicePlan {return @{Id=$Name;Name=$Name;Location=$Location;Sku=@{Tier=$Tier};ResourcerGroupName=$ResourceGroupName}} - Mock New-AzureRmWebApp {return @{Name=$Name;ResourceGroupName=$ResourceGroupName;AppServicePlan=$AppServicePlan;Location=$Location}} - - $result = New-AzWebAppJustDoIt -WebAppName $customName - - It "Returns Site with provided name." { - $result.Name | Should be $customName - } - - It "Returns Site with a NEW ResourceGroup with same name as the webapp." { - $result.ResourceGroupName | Should be $customName - } - - It "Returns Site with default location." { - $result.Location | Should be $defaultLocation - } - - It "Returns Site with a NEW AppServicePlan with same name as the webapp." { - $result.AppServicePlan | Should be $customName - } - } - - Context "[mock] When no parameters are provided and - there is one default plan: " { - $defaultPlanName = "defaultPlan" - $plan1 = @{Id="plan1";Name="plan1";Sku=@{Tier="Basic"};ResourceGroup="group1"} - $plan2 = @{Id="$defaultPlanName";Name=$defaultPlanName;Sku=@{Tier="Free"};ResourceGroup="group2"} - $plans = @($plan1,$plan2) - Mock Test-NameAvailability {return $true} - Mock Test-ResourceGroupExistence {return $false} - Mock Get-AzureRmAppServicePlan {return Get-AzureRmAppServicePlanMock $Name $ResourceGroupName $plans} - Mock New-AzureRmResourceGroup {return @{ResourceGroupName=$Name;Location=$Location}} - Mock New-AzureRmWebApp {return @{Name=$Name;ResourceGroupName=$ResourceGroupName;AppServicePlan=$AppServicePlan;Location=$Location}} - - $result = New-AzWebAppJustDoIt - - It "Returns Site with default name." { - $result.Name | Should be $defaultName - } - - It "Returns Site with a NEW ResourceGroup with same name as the webapp." { - $result.ResourceGroupName | Should be $defaultName - $result.ResourceGroupName | Should be $result.Name - } - - It "Returns Site with default Location." { - $result.Location | Should be $defaultLocation - } - - It "Returns Site with the only EXISTING default plan." { - $result.AppServicePlan | Should be $defaultPlanName - } - } - - Context "[mock] When no parameters are provided and - there is multiple default plans: " { - $defaultPlanName1 = "defaultPlan1" - $defaultPlanName2 = "defaultPlan2" - $plan1 = @{Id="plan1";Name="plan1";Sku=@{Tier="Basic"};ResourceGroup="group1"} - $plan2 = @{Id="$defaultPlanName1";Name=$defaultPlanName1;Sku=@{Tier="Free"};ResourceGroup="group2"} - $plan3 = @{Id="$defaultPlanName2";Name=$defaultPlanName2;Sku=@{Tier="Free"};ResourceGroup="group3"} - $plans = @($plan1,$plan2,$plan3) - Mock Test-NameAvailability {return $true} - Mock Test-ResourceGroupExistence {return $false} - Mock Get-AzureRmAppServicePlan {return Get-AzureRmAppServicePlanMock $Name $ResourceGroupName $plans} - Mock New-AzureRmResourceGroup {return @{ResourceGroupName=$Name;Location=$Location}} - Mock New-AzureRmWebApp {return @{Name=$Name;ResourceGroupName=$ResourceGroupName;AppServicePlan=$AppServicePlan;Location=$Location}} - - $result = New-AzWebAppJustDoIt - - It "Returns Site with default name." { - $result.Name | Should be $defaultName - } - - It "Returns Site with a NEW ResourceGroup with same name as the webapp." { - $result.ResourceGroupName | Should be $defaultName - $result.ResourceGroupName | Should be $result.Name - } - - It "Returns Site with default Location." { - $result.Location | Should be $defaultLocation - } - - It "Returns Site with the first EXISTING default plan." { - $result.AppServicePlan | Should be $defaultPlanName1 - } - } - - Context "[mock] When group name is provided and - group with provided name exists and - default plan does not exist: " { - $plan1 = @{Id="plan1";Name="plan1";Sku=@{Tier="Basic"};ResourceGroup="group1"} - $plan2 = @{Id="plan2";Name="plan2";Sku=@{Tier="Basic"};ResourceGroup="group2"} - $plans = @($plan1,$plan2) - $existingGroupName = "existingGroupName" - $existingGroupLocation = "existingGroupLocation" - $group1 = @{ResourceGroupName=$existingGroupName;Location=$existingGroupLocation} - $group2 = @{ResourceGroupName="rg2";Location="loc2"} - $group3 = @{ResourceGroupName="rg3";Location="loc3"} - $groups = @($group1, $group2, $group3) - Mock Test-NameAvailability {return $true} - Mock Test-ResourceGroupExistence {return $true} - Mock Get-AzureRmAppServicePlan {return Get-AzureRmAppServicePlanMock $Name $ResourceGroupName $plans} - Mock Get-AzureRmResourceGroup {return Get-AzureRmResourceGroupMock $Name $groups} - Mock New-AzureRmAppServicePlan {return @{Id=$Name;Name=$Name;Location=$Location;Sku=@{Tier=$Tier};ResourcerGroupName=$ResourceGroupName}} - Mock New-AzureRmWebApp {return @{Name=$Name;ResourceGroupName=$ResourceGroupName;AppServicePlan=$AppServicePlan;Location=$Location}} - - $result = New-AzWebAppJustDoIt -ResourceGroupName $existingGroupName - - It "Returns Site with default name." { - $result.Name | Should be $defaultName - } - - It "Returns Site with EXISTING group with provided ResourceGroupName." { - $result.ResourceGroupName | Should be $existingGroupName - } - - It "Returns Site with the SAME Location as the existing resource group - that matches the provided ResourceGroupName." { - $result.Location | Should be $existingGroupLocation - } - - It "Returns Site with NEW AppServicePlan with the same name as the webapp." { - $result.AppServicePlan | Should be $defaultName - $result.AppServicePlan | Should be $result.Name - } - } - - Context "[mock] When group name is provided and - group with provided name does not exist and - default plan does not exist: " { - $plan1 = @{Id="plan1";Name="plan1";Sku=@{Tier="Basic"};ResourceGroup="group1"} - $plan2 = @{Id="plan2";Name="plan2";Sku=@{Tier="Basic"};ResourceGroup="group2"} - $plans = @($plan1,$plan2) - $providedGroupName = "providedGroupName" - $group1 = @{ResourceGroupName="rg1";Location="loc1"} - $group2 = @{ResourceGroupName="rg2";Location="loc2"} - $group3 = @{ResourceGroupName="rg3";Location="loc3"} - $groups = @($group1, $group2, $group3) - Mock Test-NameAvailability {return $true} - Mock Test-ResourceGroupExistence {return $false} - Mock Get-AzureRmAppServicePlan {return Get-AzureRmAppServicePlanMock $Name $ResourceGroupName $plans} - Mock Get-AzureRmResourceGroup {return Get-AzureRmResourceGroupMock $Name $groups} - Mock New-AzureRmResourceGroup {return @{ResourceGroupName=$Name;Location=$Location}} - Mock New-AzureRmAppServicePlan {return @{Id=$Name;Name=$Name;Location=$Location;Sku=@{Tier=$Tier};ResourcerGroupName=$ResourceGroupName}} - Mock New-AzureRmWebApp {return @{Name=$Name;ResourceGroupName=$ResourceGroupName;AppServicePlan=$AppServicePlan;Location=$Location}} - - $result = New-AzWebAppJustDoIt -ResourceGroupName $providedGroupName - - It "Returns Site with default name." { - $result.Name | Should be $defaultName - } - - It "Returns Site with NEW group with provided ResourceGroupName." { - $result.ResourceGroupName | Should be $providedGroupName - } - - It "Returns Site with the default Location." { - $result.Location | Should be $defaultLocation - } - - It "Returns Site with NEW AppServicePlan with the same name as the webapp." { - $result.AppServicePlan | Should be $defaultName - $result.AppServicePlan | Should be $result.Name - } - } - - Context "[mock] When plan name is provided and - plan with provided name does not exist: " { - $providedPlanName = "ProvidedPlanName" - $plan1 = @{Id="plan1";Name="plan1";Sku=@{Tier="Basic"};ResourceGroup="group1"} - $plan2 = @{Id="plan2";Name="plan2";Sku=@{Tier="Basic"};ResourceGroup="group2"} - $plans = @($plan1,$plan2) - $group1 = @{ResourceGroupName="rg1";Location="loc1"} - $group2 = @{ResourceGroupName="rg2";Location="loc2"} - $group3 = @{ResourceGroupName="rg3";Location="loc3"} - $groups = @($group1, $group2, $group3) - Mock Test-NameAvailability {return $true} - Mock Test-ResourceGroupExistence {return $false} - Mock Get-AzureRmAppServicePlan {return Get-AzureRmAppServicePlanMock $Name $ResourceGroupName $plans} - Mock Get-AzureRmResourceGroup {return Get-AzureRmResourceGroupMock $Name $groups} - Mock New-AzureRmResourceGroup {return @{ResourceGroupName=$Name;Location=$Location}} - Mock New-AzureRmAppServicePlan {return @{Id=$Name;Name=$Name;Location=$Location;Sku=@{Tier=$Tier};ResourcerGroupName=$ResourceGroupName}} - Mock New-AzureRmWebApp {return @{Name=$Name;ResourceGroupName=$ResourceGroupName;AppServicePlan=$AppServicePlan;Location=$Location}} - - $result = New-AzWebAppJustDoIt -AppServicePlan $providedPlanName - - It "Returns Site with default name." { - $result.Name | Should be $defaultName - } - - It "Returns Site with NEW group with same name as the webapp." { - $result.ResourceGroupName | Should Be $defaultName - $result.ResourceGroupName | Should Be $result.Name - } - - It "Returns Site with the default Location." { - $result.Location | Should be $defaultLocation - } - - It "Returns Site with NEW AppServicePlan with the same name as the webapp." { - $result.AppServicePlan | Should be $providedPlanName - } - } - - - Context "[mock] When plan name is provided and - one plan with provided name exist: " { - $existingPlanName = "ExistingPlanName" - $existingPlanGroup = "ExistingPlanGroup" - $plan1 = @{Id=$existingPlanName;Name=$existingPlanName;Sku=@{Tier="Basic"};ResourceGroup=$existingPlanGroup} - $plan2 = @{Id="plan2";Name="plan2";Sku=@{Tier="Basic"};ResourceGroup="group2"} - $plans = @($plan1,$plan2) - $group1 = @{ResourceGroupName="rg1";Location="loc1"} - $group2 = @{ResourceGroupName="rg2";Location="loc2"} - $group3 = @{ResourceGroupName="rg3";Location="loc3"} - $groups = @($group1, $group2, $group3) - Mock Test-NameAvailability {return $true} - Mock Test-ResourceGroupExistence {return $false} - Mock Get-AzureRmAppServicePlan {return Get-AzureRmAppServicePlanMock $Name $ResourceGroupName $plans} - Mock Get-AzureRmResourceGroup {return Get-AzureRmResourceGroupMock $Name $groups} - Mock New-AzureRmResourceGroup {return @{ResourceGroupName=$Name;Location=$Location}} - Mock New-AzureRmWebApp {return @{Name=$Name;ResourceGroupName=$ResourceGroupName;AppServicePlan=$AppServicePlan;Location=$Location}} - - $result = New-AzWebAppJustDoIt -AppServicePlan $existingPlanName - - It "Returns Site with default name." { - $result.Name | Should be $defaultName - } - - It "Returns Site with NEW group with same name as the webapp." { - $result.ResourceGroupName | Should Be $defaultName - $result.ResourceGroupName | Should Be $result.Name - } - - It "Returns Site with the default Location." { - $result.Location | Should be $defaultLocation - } - - It "Returns Site with EXISTING AppServicePlan name." { - $result.AppServicePlan | Should be $existingPlanName - } - } - - Context "[mock] When plan name is provided and - multiple plans with provided name exist: " { - $existingPlanName = "ExistingPlanName" - $existingPlanGroup = "ExistingPlanGroup" - $plan1 = @{Id="plan1";Name=$existingPlanName;Sku=@{Tier="Basic"};ResourceGroup="group1"} - $plan2 = @{Id="plan2";Name=$existingPlanName;Sku=@{Tier="Basic"};ResourceGroup="group2"} - $plans = @($plan1,$plan2) - $group1 = @{ResourceGroupName="rg1";Location="loc1"} - $group2 = @{ResourceGroupName="rg2";Location="loc2"} - $group3 = @{ResourceGroupName="rg3";Location="loc3"} - $groups = @($group1, $group2, $group3) - Mock Test-NameAvailability {return $true} - Mock Test-ResourceGroupExistence {return $false} - Mock Get-AzureRmAppServicePlan {return Get-AzureRmAppServicePlanMock $Name $ResourceGroupName $plans} - Mock Get-AzureRmResourceGroup {return Get-AzureRmResourceGroupMock $Name $groups} - Mock New-AzureRmResourceGroup {return @{ResourceGroupName=$Name;Location=$Location}} - Mock New-AzureRmAppServicePlan {return @{Id=$Name;Name=$Name;Location=$Location;Sku=@{Tier=$Tier};ResourcerGroupName=$ResourceGroupName}} - Mock New-AzureRmWebApp {return @{Name=$Name;ResourceGroupName=$ResourceGroupName;AppServicePlan=$AppServicePlan;Location=$Location}} - - - - It "Should throw." { - {$result = New-AzWebAppJustDoIt -AppServicePlan $existingPlanName} | Should Throw - } - } - - - Context "[mock] When plan name and group name are provided and - no plan nor group with those names exist: " { - $providedPlanName = "PlanName" - $providedGroupName = "GroupNAme" - $plan1 = @{Id="plan1";Name="plan1";Sku=@{Tier="Basic"};ResourceGroup="group1"} - $plan2 = @{Id="plan2";Name="plan2";Sku=@{Tier="Basic"};ResourceGroup="group2"} - $plans = @($plan1,$plan2) - $group1 = @{ResourceGroupName="rg1";Location="loc1"} - $group2 = @{ResourceGroupName="rg2";Location="loc2"} - $group3 = @{ResourceGroupName="rg3";Location="loc3"} - $groups = @($group1, $group2, $group3) - Mock Test-NameAvailability {return $true} - Mock Test-ResourceGroupExistence {return $false} - Mock Get-AzureRmAppServicePlan {return Get-AzureRmAppServicePlanMock $Name $ResourceGroupName $plans} - Mock Get-AzureRmResourceGroup {return Get-AzureRmResourceGroupMock $Name $groups} - Mock New-AzureRmResourceGroup {return @{ResourceGroupName=$Name;Location=$Location}} - Mock New-AzureRmAppServicePlan {return @{Id=$Name;Name=$Name;Location=$Location;Sku=@{Tier=$Tier};ResourcerGroupName=$ResourceGroupName}} - Mock New-AzureRmWebApp {return @{Name=$Name;ResourceGroupName=$ResourceGroupName;AppServicePlan=$AppServicePlan;Location=$Location}} - - $result = New-AzWebAppJustDoIt -AppServicePlan $providedPlanName -ResourceGroupName $providedGroupName - - It "Returns Site with DEFAULT name." { - $result.Name | Should be $defaultName - } - - It "Returns Site with NEW group with same name provided." { - $result.ResourceGroupName | Should Be $providedGroupName - } - - It "Returns Site with the DEFAULT Location." { - $result.Location | Should be $defaultLocation - } - - It "Returns Site with EXISTING AppServicePlan name." { - $result.AppServicePlan | Should Be $providedPlanName - } - } - - Context "[mock] When plan name and group name are provided and - no group with that name exist and - plan with that name exist: " { - $existingPlanName = "ExistingPlanName" - $providedGroupName = "GroupNAme" - $plan1 = @{Id=$existingPlanName;Name=$existingPlanName;Sku=@{Tier="Basic"};ResourceGroup="group1"} - $plan2 = @{Id="plan2";Name="plan2";Sku=@{Tier="Basic"};ResourceGroup="group2"} - $plans = @($plan1,$plan2) - $group1 = @{ResourceGroupName="rg1";Location="loc1"} - $group2 = @{ResourceGroupName="rg2";Location="loc2"} - $group3 = @{ResourceGroupName="rg3";Location="loc3"} - $groups = @($group1, $group2, $group3) - Mock Test-NameAvailability {return $true} - Mock Test-ResourceGroupExistence {return $false} - Mock Get-AzureRmAppServicePlan {return Get-AzureRmAppServicePlanMock $Name $ResourceGroupName $plans} - Mock Get-AzureRmResourceGroup {return Get-AzureRmResourceGroupMock $Name $groups} - Mock New-AzureRmResourceGroup {return @{ResourceGroupName=$Name;Location=$Location}} - Mock New-AzureRmWebApp {return @{Name=$Name;ResourceGroupName=$ResourceGroupName;AppServicePlan=$AppServicePlan;Location=$Location}} - - $result = New-AzWebAppJustDoIt -AppServicePlan $existingPlanName -ResourceGroupName $providedGroupName - - It "Returns Site with DEFAULT name." { - $result.Name | Should be $defaultName - } - - It "Returns Site with NEW group with same name provided." { - $result.ResourceGroupName | Should Be $providedGroupName - } - - It "Returns Site with the DEFAULT Location." { - $result.Location | Should be $defaultLocation - } - - It "Returns Site with EXISTING AppServicePlan name." { - $result.AppServicePlan | Should Be $existingPlanName - } - } - - Context "[mock] When plan name and group name are provided and - no group with that name exist and - multiple plans with that name exist: " { - $existingPlanName = "ExistingPlanName" - $providedGroupName = "GroupNAme" - $plan1 = @{Id="plan1";Name=$existingPlanName;Sku=@{Tier="Basic"};ResourceGroup="group1"} - $plan2 = @{Id="plan2";Name=$existingPlanName;Sku=@{Tier="Basic"};ResourceGroup="group2"} - $plans = @($plan1,$plan2) - $group1 = @{ResourceGroupName="rg1";Location="loc1"} - $group2 = @{ResourceGroupName="rg2";Location="loc2"} - $group3 = @{ResourceGroupName="rg3";Location="loc3"} - $groups = @($group1, $group2, $group3) - Mock Test-NameAvailability {return $true} - Mock Test-ResourceGroupExistence {return $false} - Mock Get-AzureRmAppServicePlan {return Get-AzureRmAppServicePlanMock $Name $ResourceGroupName $plans} - Mock Get-AzureRmResourceGroup {return Get-AzureRmResourceGroupMock $Name $groups} - - It "Should throw." { - {$result = New-AzWebAppJustDoIt -AppServicePlan $existingPlanName -ResourceGroupName $providedGroupName} | Should Throw "There are various App Service Plans with that name" - } - } - - Context "[mock] When plan name and group name are provided and - group with that name exists - plan with that name exist and belongs to that group: " { - $existingPlanName = "ExistingPlanName" - $existingGroupName = "GroupNAme" - $existingGroupLocation = "locationgroup" - $plan1 = @{Id=$existingPlanName;Name=$existingPlanName;Sku=@{Tier="Basic"};ResourceGroup=$existingGroupName} - $plan2 = @{Id="plan2";Name="plan2";Sku=@{Tier="Basic"};ResourceGroup="group2"} - $plans = @($plan1,$plan2) - $group1 = @{ResourceGroupName="rg1";Location="loc1"} - $group2 = @{ResourceGroupName=$existingGroupName;Location=$existingGroupLocation} - $group3 = @{ResourceGroupName="rg3";Location="loc3"} - $groups = @($group1, $group2, $group3) - Mock Test-NameAvailability {return $true} - Mock Test-ResourceGroupExistence {return $true} - Mock Get-AzureRmAppServicePlan {return Get-AzureRmAppServicePlanMock $Name $ResourceGroupName $plans} - Mock Get-AzureRmResourceGroup {return Get-AzureRmResourceGroupMock $Name $groups} - Mock New-AzureRmWebApp {return @{Name=$Name;ResourceGroupName=$ResourceGroupName;AppServicePlan=$AppServicePlan;Location=$Location}} - - $result = New-AzWebAppJustDoIt -AppServicePlan $existingPlanName -ResourceGroupName $existingGroupName - - It "Returns Site with DEFAULT name." { - $result.Name | Should be $defaultName - } - - It "Returns Site with EXISTING group with same name provided." { - $result.ResourceGroupName | Should Be $existingGroupName - } - - It "Returns Site with the location of EXISTING Location." { - $result.Location | Should be $existingGroupLocation - } - - It "Returns Site with EXISTING AppServicePlan name." { - $result.AppServicePlan | Should Be $existingPlanName - } - } - - Context "[mock] When plan name and group name are provided and - group with that name exists - plan with that name exist and belongs to another group: " { - $existingPlanName = "ExistingPlanName" - $existingPlanGroup = "ExistingPlanGroup" - $existingGroupName = "GroupNAme" - $existingGroupLocation = "locationgroup" - $plan1 = @{Id=$existingPlanName;Name=$existingPlanName;Sku=@{Tier="Basic"};ResourceGroup=$existingPlanGroup} - $plan2 = @{Id="plan2";Name="plan2";Sku=@{Tier="Basic"};ResourceGroup=$existingGroupName} - $plans = @($plan1,$plan2) - $group1 = @{ResourceGroupName="rg1";Location="loc1"} - $group2 = @{ResourceGroupName=$existingGroupName;Location=$existingGroupLocation} - $group3 = @{ResourceGroupName="rg3";Location="loc3"} - $groups = @($group1, $group2, $group3) - Mock Test-NameAvailability {return $true} - Mock Test-ResourceGroupExistence {return $true} - Mock Get-AzureRmAppServicePlan {return Get-AzureRmAppServicePlanMock $Name $ResourceGroupName $plans} - Mock Get-AzureRmResourceGroup {return Get-AzureRmResourceGroupMock $Name $groups} - Mock New-AzureRmWebApp {return @{Name=$Name;ResourceGroupName=$ResourceGroupName;AppServicePlan=$AppServicePlan;Location=$Location}} - - $result = New-AzWebAppJustDoIt -AppServicePlan $existingPlanName -ResourceGroupName $existingGroupName - - It "Returns Site with DEFAULT name." { - $result.Name | Should be $defaultName - } - - It "Returns Site with EXISTING group with same name provided." { - $result.ResourceGroupName | Should Be $existingGroupName - } - - It "Returns Site with the location of EXISTING Location." { - $result.Location | Should be $existingGroupLocation - } - - It "Returns Site with EXISTING AppServicePlan name." { - $result.AppServicePlan | Should Be $existingPlanName - } - } - - Context "[mock] When plan name and group name are provided and - group with that name exists - multiple plans with that name and - one belongs to the existing group: " { - $existingPlanName = "ExistingPlanName" - $existingPlanGroup = "ExistingPlanGroup" - $existingPlanGroupLocation = "locationgroup" - $plan1 = @{Id=$existingPlanName;Name=$existingPlanName;Sku=@{Tier="Basic"};ResourceGroup=$existingPlanGroup} - $plan2 = @{Id="plan2";Name="plan2";Sku=@{Tier="Basic"};ResourceGroup="group2"} - $plans = @($plan1,$plan2) - $group1 = @{ResourceGroupName="rg1";Location="loc1"} - $group2 = @{ResourceGroupName=$existingPlanGroup ;Location=$existingPlanGroupLocation} - $group3 = @{ResourceGroupName="rg3";Location="loc3"} - $groups = @($group1, $group2, $group3) - Mock Test-NameAvailability {return $true} - Mock Test-ResourceGroupExistence {return $true} - Mock Get-AzureRmAppServicePlan {return Get-AzureRmAppServicePlanMock $Name $ResourceGroupName $plans} - Mock Get-AzureRmResourceGroup {return Get-AzureRmResourceGroupMock $Name $groups} - Mock New-AzureRmWebApp {return @{Name=$Name;ResourceGroupName=$ResourceGroupName;AppServicePlan=$AppServicePlan;Location=$Location}} - - $result = New-AzWebAppJustDoIt -AppServicePlan $existingPlanName -ResourceGroupName $existingPlanGroup - - It "Returns Site with DEFAULT name." { - $result.Name | Should be $defaultName - } - - It "Returns Site with EXISTING group with same name provided." { - $result.ResourceGroupName | Should Be $existingPlanGroup - } - - It "Returns Site with the location of EXISTING Location." { - $result.Location | Should be $existingPlanGroupLocation - } - - It "Returns Site with EXISTING AppServicePlan name which belongs to the existing group." { - $result.AppServicePlan | Should Be $existingPlanName - } - } - - Context "[mock] When plan name and group name are provided and - group with that name exists and - plan with that name does not exist, and there is - a default plan: " { - $defaultPlanName = "DefaultPlanName" - $customPlan = "customPlan" - $existingGroup = "exisitingGroup" - $existingGroupLocation = "locationgroup" - $plan1 = @{Id="plan1";Name="plan2";Sku=@{Tier="Free"};ResourceGroup="group1"} - $plan2 = @{Id=$defaultPlanName;Name=$defaultPlanName;Sku=@{Tier="Basic"};ResourceGroup="group2"} - $plans = @($plan1,$plan2) - $group1 = @{ResourceGroupName="rg1";Location="loc1"} - $group2 = @{ResourceGroupName=$existingGroup ;Location=$existingGroupLocation} - $group3 = @{ResourceGroupName="rg3";Location="loc3"} - $groups = @($group1, $group2, $group3) - Mock Test-NameAvailability {return $true} - Mock Test-ResourceGroupExistence {return $true} - Mock Get-AzureRmAppServicePlan {return Get-AzureRmAppServicePlanMock $Name $ResourceGroupName $plans} - Mock Get-AzureRmResourceGroup {return Get-AzureRmResourceGroupMock $Name $groups} - Mock New-AzureRmAppServicePlan {return @{Id=$Name;Name=$Name;Location=$Location;Sku=@{Tier=$Tier};ResourcerGroupName=$ResourceGroupName}} - Mock New-AzureRmWebApp {return @{Name=$Name;ResourceGroupName=$ResourceGroupName;AppServicePlan=$AppServicePlan;Location=$Location}} - - $result = New-AzWebAppJustDoIt -AppServicePlan $customPlan -ResourceGroupName $existingGroup - - It "Returns Site with DEFAULT name." { - $result.Name | Should be $defaultName - } - - It "Returns Site with EXISTING group with same name provided." { - $result.ResourceGroupName | Should Be $existingGroup - } - - It "Returns Site with the location of EXISTING Location." { - $result.Location | Should be $existingGroupLocation - } - - It "Returns Site with EXISTING AppServicePlan name which belongs to the existing group." { - $result.AppServicePlan | Should Be $customPlan - } - } - - Context "[mock] When plan ID and group name are provided and - group with that name does not exist and - plan with that ID exist: " { - $existingPlanName = "existingPlan" - $existingPlanGroup = "existingPlanGroup" - $groupExistence = $false - $existingPlanId = "/subscriptions/f30a7701-df2c-1bc2-ba9d-pb11861cr13c/resourceGroups/$existingPlanGroup/providers/Microsoft.Web/serverfarms/$existingPlanName" - $providedGroupName = "ProvidedGroupName" - $plan1 = @{Id="plan1";Name="plan2";Sku=@{Tier="Free"};ResourceGroup="group1"} - $plan2 = @{Id=$existingPlanId;Name=$existingPlanName;Sku=@{Tier="Basic"};ResourceGroup=$existingPlanGroup} - $plans = @($plan1,$plan2) - $group1 = @{ResourceGroupName="rg1";Location="loc1"} - $group2 = @{ResourceGroupName=$existingPlanGroup ;Location="loc2"} - $group3 = @{ResourceGroupName="rg3";Location="loc3"} - $groups = @($group1, $group2, $group3) - Mock Test-NameAvailability {return $true} - Mock Test-ResourceGroupExistence {return $groupExistence} - Mock Get-AzureRmAppServicePlan {return Get-AzureRmAppServicePlanMock $Name $ResourceGroupName $plans} - Mock Get-AzureRmResourceGroup {return Get-AzureRmResourceGroupMock $Name $groups} - Mock New-AzureRmResourceGroup {return @{ResourceGroupName=$Name;Location=$Location}} - Mock New-AzureRmWebApp {return @{Name=$Name;ResourceGroupName=$ResourceGroupName;AppServicePlan=$AppServicePlan;Location=$Location}} - - $result = New-AzWebAppJustDoIt -AppServicePlan $existingPlanId -ResourceGroupName $providedGroupName - - It "Returns Site with DEFAULT name." { - $result.Name | Should be $defaultName - } - - It "Returns Site with NEW group with same name as the app." { - $result.ResourceGroupName | Should be $providedGroupName - } - - It "Returns Site with the location of DEFAULT Location." { - $result.Location | Should be $defaultLocation - } - - It "Returns Site with EXISTING AppServicePlan name." { - $result.AppServicePlan | Should Be $existingPlanName - } - } - - Context "[mock] When plan ID and group name are provided and - group with that name exists and - plan with that ID exist: " { - $existingPlanName = "existingPlan" - $existingPlanGroup = "existingPlanGroup" - $existingPlanId = "/subscriptions/f30a7701-df2c-1bc2-ba9d-pb11861cr13c/resourceGroups/$existingPlanGroup/providers/Microsoft.Web/serverfarms/$existingPlanName" - $groupExistence = $true - $plan1 = @{Id="plan1";Name="plan2";Sku=@{Tier="Free"};ResourceGroup="group1"} - $plan2 = @{Id=$existingPlanId;Name=$existingPlanName;Sku=@{Tier="Basic"};ResourceGroup=$existingPlanGroup} - $plans = @($plan1,$plan2) - $groupLocation = "groupLocation" - $group1 = @{ResourceGroupName="rg1";Location="loc1"} - $group2 = @{ResourceGroupName=$existingPlanGroup ;Location=$groupLocation } - $group3 = @{ResourceGroupName="rg3";Location="loc3"} - $groups = @($group1, $group2, $group3) - Mock Test-NameAvailability {return $true} - Mock Test-ResourceGroupExistence {return $groupExistence} - Mock Get-AzureRmAppServicePlan {return Get-AzureRmAppServicePlanMock $Name $ResourceGroupName $plans} - Mock Get-AzureRmResourceGroup {return Get-AzureRmResourceGroupMock $Name $groups} - Mock New-AzureRmWebApp {return @{Name=$Name;ResourceGroupName=$ResourceGroupName;AppServicePlan=$AppServicePlan;Location=$Location}} - - $result = New-AzWebAppJustDoIt -AppServicePlan $existingPlanId -ResourceGroupName $existingPlanGroup - - It "Returns Site with DEFAULT name." { - $result.Name | Should Be $defaultName - } - - It "Returns Site with NEW group with same name as the app." { - $result.ResourceGroupName | Should Be $existingPlanGroup - } - - It "Returns Site with the location of DEFAULT Location." { - $result.Location | Should Be $groupLocation - } - - It "Returns Site with EXISTING AppServicePlan name." { - $result.AppServicePlan | Should Be $existingPlanName - } - } - - Context "[mock] When plan ID and group name are provided and - group with that name exists and - plan with that ID DOES NOT exist: " { - $providedPlanName = "ProvidedPlanName" - $providedPlanGroup = "ProvidedPlanGroup" - $providedPlanId = "/subscriptions/f30a7701-df2c-1bc2-ba9d-pb11861cr13c/resourceGroups/$providedPlanName/providers/Microsoft.Web/serverfarms/$providedPlanGroup" - $groupExistence = $true - $plan1 = @{Id="plan1";Name="plan1";Sku=@{Tier="Free"};ResourceGroup="group1"} - $plan2 = @{Id="plan1";Name="plan2";Sku=@{Tier="Basic"};ResourceGroup="group2"} - $plans = @($plan1,$plan2) - $existingGroup = "Existing Group" - $groupLocation = "groupLocation" - $group1 = @{ResourceGroupName="rg1";Location="loc1"} - $group2 = @{ResourceGroupName=$existingGroup ;Location=$groupLocation } - $group3 = @{ResourceGroupName="rg3";Location="loc3"} - $groups = @($group1, $group2, $group3) - Mock Test-NameAvailability {return $true} - Mock Test-ResourceGroupExistence {return $groupExistence} - Mock Get-AzureRmAppServicePlan {return Get-AzureRmAppServicePlanMock $Name $ResourceGroupName $plans} - Mock Get-AzureRmResourceGroup {return Get-AzureRmResourceGroupMock $Name $groups} - Mock New-AzureRmWebApp {return @{Name=$Name;ResourceGroupName=$ResourceGroupName;AppServicePlan=$AppServicePlan;Location=$Location}} - - It "Should Throw." { - {$result = New-AzWebAppJustDoIt -AppServicePlan $providedPlanId -ResourceGroupName $existingGroup} | Should Throw "The app service plan with the id provided does not exist" - } - } - - Context "[mock] When NON-VALID LOCATION is provided: " { - $nonValidLocation = "customLocation" - - It "Should throw." { - {$result = New-AzWebAppJustDoIt -ResourceGroupName $existingGroup.ResourceGroupName -Location $nonValidLocation} | Should Throw - } - } - } -} diff --git a/experiments/Websites.Experiments/AzureRM.Websites.Experiments.format.ps1xml b/experiments/Websites.Experiments/AzureRM.Websites.Experiments.format.ps1xml deleted file mode 100644 index 4fae04944e6a..000000000000 --- a/experiments/Websites.Experiments/AzureRM.Websites.Experiments.format.ps1xml +++ /dev/null @@ -1,44 +0,0 @@ - - - - - Microsoft.Azure.Management.WebSites.Models.Site - - Microsoft.Azure.Management.WebSites.Models.Site - - - - - - - SiteName - - - ResourceGroup - - - - ($_.ServerFarmId.split('/'))[($_.ServerFarmId.split('/')).Count - 1] - - - Location - - - - DefaultHostName - - - - ($_.EnabledHostNames[1]) - - - - Learn how to deploy the files for your web app to Azure App Service following this link https://docs.microsoft.com/en-us/azure/app-service-web/web-sites-deploy - - - - - - - - diff --git a/experiments/Websites.Experiments/AzureRM.Websites.Experiments.psd1 b/experiments/Websites.Experiments/AzureRM.Websites.Experiments.psd1 deleted file mode 100644 index a3d850ea9e2660ddd01e26f212b8956f0226d206..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 8684 zcmeI2S#MiK7>4H>iT_|J7j6-Co9+T3)k;VksVz~Gwp?%%FA1hzf|E2YsDB-JpZWZC zW{!`YI3)-n6dj*!miOD2lRy7h3txsW!dhsA7hw{5;VcY8Uw5N$5XNB;4s~}DPW9wa z@2BxiKCT(s;Wy2iYTT~YXoWYr>S)eDvzXfo--q|%Sl3fM8|ggOo0HI-?d>bt z@OymX==S3N1JS|WBkh%VWqj!f!C2U*!dxA3sCUNK15p4CT|G&3p6l*3{H%HW4m4t3 z0`9AykxPc=WF{}ugOSFY4s;@)>&7<%dp-#_!p%am z+hJ4B&%^=S>r^{)kM{qnb6+bW(Si0i-Nh<+lFKU54)>mhSHadbIuFC$a8I)zipT77 zE8N%px_HUe1N}YH)nkq7#H)^Wc&IzZ@^oG2M>?C$xP00|2L{u>W%6J~Iofbt-mc1> zu|4DYIC8=eyo>zlT@p{Z#!JZ$-(XT|UTE>BGkK$#^Vp7s3U6~H?qIKYFtaxIKgpjh zmLdqND;eKz$bN5XUH2WUc&L`&LHsgEzp!p%U%OrXD zcNlfID~j#?fp)^Xps~lAJJIT<%kE*9Y4V~yjSm|UvvIZ|4v&Spp`)*zhT4fe&vn<) z`9RNjiYGT)MRw4Q?cqC*be*CJ*UV_h_KhdZw1`sj1ue!}M_Os5@o;Y%*EGLX^5;z) zjh3Fr-FM;@Gxnq{SUZxz(vRXuc#3531%r5X8NSu6TJHlN)cC+;4OhXAN3fW^I_@=5 zTZjGGY|VtsG~oIrah=rEOXMmv)p^oZc&VthFOF_WZ_K})i;vUrc4eKyYwUl@4X|T0 z*0s{JEus__^-jBCX=tkFZTLBKxlXzb#Xv0Ut^5Q&5B<-hEzy3g6+cK_Cr*lO0>)y^aRnPm?}Cw6+K^HHR3s%!E~%QPE`_8Z~3GE=;D;ulvJ zS@FM%<7>iil+<&#)Y%=;N{)$4$u`N`$xORZgUG6g50N0~>`UWlXKqom9V%|?rf9^}Ww4X(&Y(R?xzX!Wd-s9@Qg>;92+c%t!G zhxvG7A-o!EwqNv>nnej177o?4)f2-nyZnO=(GTpl@LVQDsu*}ihQIGqQ5&8Wf z?z2o6kn(|a*Q^|G`FF~*9*s-2DO!H2$zNMpZqtg@D}Ky!CaUDi*3B)^MUK*})G=j+ z>J=yYc0;RE;jKqIP8NhmuN)-s#kz?iRqn-- z-IThquc$;%v@XB!Ke|c8r*}afEDGHRFTrA7drd~(6(NVSj-&JMc zRz1I7J(6blN?O7!pV^icfP+5HRZ;wRE!(QnW!y1MD7jeAdot)!3pSNQY{-9*)s%Ut zN0ik(tjly$t94^mU#@ytT+gKu=AA7*Szc9sBS2T^VRu!7TP;g{TK`=j#XLutN1n8s z`@ND&>3xYN&qA(_WGlv#zG`l#xgG_%-5~ZUES~g4H9cCF6bPtY{ob?E>x}7T#ZTTs zv_e|Qy&>69CxX)Q2GH`QVN*{GJGJSFa!KyY6Xi0bBFVcdtXygVcf=4z`kLv>1Yg7I z`!{AaB~KG7lR)~OTH6_I; zpW)}_*suZ9b?f4%KI1$}s_aSlMKqAP)ysk1tg7>IpNEs`nYz_1(>y;oOw+6nXx|l9 z<>vNm%~kNx{~!mn_(o3+--ZuMbxD24$fe%O%Y-pa!4dG6`qkP6Zk3N3NPX7X;ij*_} diff --git a/experiments/Websites.Experiments/AzureRM.Websites.Experiments.psm1 b/experiments/Websites.Experiments/AzureRM.Websites.Experiments.psm1 deleted file mode 100644 index cf31c26585d6..000000000000 --- a/experiments/Websites.Experiments/AzureRM.Websites.Experiments.psm1 +++ /dev/null @@ -1,1055 +0,0 @@ -# ---------------------------------------------------------------------------------- -# -# 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. -# ---------------------------------------------------------------------------------- - -function New-AzWebAppJustDoIt -{ - [CmdletBinding()] - [OutputType([Microsoft.Azure.Management.WebSites.Models.Site])] - param( - [string][Parameter(Mandatory=$false)][alias("Name")]$WebAppName, - [string][Parameter(Mandatory=$false)][alias("Group")]$ResourceGroupName, - [string][Parameter(Mandatory=$false)][alias("Plan")]$AppServicePlan - ) - DynamicParam{ - #Set the dynamic parameters' name - $ParamName_location = 'Location' - # Create the collection of attributes - $AttributeCollection = New-Object System.Collections.ObjectModel.Collection[System.Attribute] - # Create and set the parameters' attributes - $ParameterAttribute = New-Object System.Management.Automation.ParameterAttribute - $ParameterAttribute.Mandatory = $false - # Add the attributes to the attributes collection - $AttributeCollection.Add($ParameterAttribute) - # Create the dictionary - $RuntimeParameterDictionary = New-Object System.Management.Automation.RuntimeDefinedParameterDictionary - #Generate and set the ValidateSet - $providerNamespace = "Microsoft.Web" - try - { - $availableLocations = $(Get-AzureRmResourceProvider | Where-Object {$_.ProviderNamespace -eq $providerNamespace}).Locations - } - catch - { - throw $_ - } - $ValidateSetAttribute = New-Object System.Management.Automation.ValidateSetAttribute($availableLocations) - # Add the ValidateSet to the attributes collection - $AttributeCollection.Add($ValidateSetAttribute) - # Create and return the dynamic parameter - $RuntimeParameter = New-Object System.Management.Automation.RuntimeDefinedParameter($ParamName_location, [string], $AttributeCollection) - $RuntimeParameterDictionary.Add($ParamName_location, $RuntimeParameter) - - return $RuntimeParameterDictionary - } - - BEGIN { - $context = Get-Context - $webSitesClient = Get-WebSitesClient $context - $resourceManagementClient = Get-ResourceManagementClient $context - } - - PROCESS { - $mainActivity = "Create Azure Web App" - [string]$Location = $PSBoundParameters[$ParamName_location] - Write-Progress ` - -Activity "Some Activity." ` - -CurrentOperation "Getting App Name information." - [string]$appName = Get-WebAppName $PSBoundParameters $webSitesClient - Write-Progress ` - -Activity $mainActivity ` - -CurrentOperation "Getting Resource Group information." - $operationNumber = 2 - [hashtable]$groupInfo = Get-ResourceGroupInfo $PSBoundParameters $appName $resourceManagementClient - Write-Progress ` - -Activity $mainActivity ` - -CurrentOperation "Getting App Service Plan information." - $operationNumber = 3 - [hashtable]$appPlanInfo = Get-AppServicePlanInfo $PSBoundParameters $appName $groupInfo.Name - Write-Progress ` - -Activity $mainActivity ` - -CurrentOperation "Getting App Location information." - $operationNumber++ - [string]$appLocation = Get-AppLocation $PSBoundParameters $groupInfo.Name $groupInfo.Exists $availableLocations - if ($groupInfo.Exists) { - $appGroup = Get-AzureRmResourceGroup ` - -Name $groupInfo.Name - $message = "Using resource group '$($appGroup.ResourceGroupName)' in location '$($appGroup.Location)'." - Write-Information -MessageData $message -InformationAction Continue - } else { - $appGroup = New-AzureRmResourceGroup ` - -Name $groupInfo.Name ` - -Location $appLocation - $message = "Created resource group '$($appGroup.ResourceGroupName)' in location '$($appGroup.Location)'." - Write-Information -MessageData $message -InformationAction Continue - } - - $operationNumber = 4 - if ($appPlanInfo.Exists) { - $appPlan = Get-AzureRmAppServicePlan ` - -Name $appPlanInfo.Name ` - -ResourceGroupName $appPlanInfo.ResourceGroup - $message = "Using app service plan '$($appPlan.Name)' in location '$($appPlan.Location)'." - Write-Information -MessageData $message -InformationAction Continue - } else { - $defaultTier = "Free" - $appPlan = New-AzureRmAppServicePlan ` - -Name $appPlanInfo.Name ` - -Location $appLocation ` - -Tier $defaultTier ` - -ResourceGroupName $appPlanInfo.ResourceGroup - $message = "Created app service plan '$($appPlan.Name)' in location '$($appPlan.Location)' with Tier '$($appPlan.Sku.Tier)'." - Write-Information -MessageData $message -InformationAction Continue - } - - $webapp = New-AzureRmWebApp ` - -Name $appName ` - -AppServicePlan $appPlan.Id ` - -ResourceGroupName $appGroup.ResourceGroupName ` - -Location $appLocation - - Write-Output $webapp - } - - END {} -} - -<# -.ExternalHelp AzureRM.Websites.Experiments-help.xml -#> -function New-AzWebApp -{ - [CmdletBinding(SupportsShouldProcess=$true)] - [OutputType([Microsoft.Azure.Management.WebSites.Models.Site])] - param( - [string][Parameter(Mandatory=$false)][alias("Name")]$WebAppName, - [string][Parameter(Mandatory=$false)][alias("Group")]$ResourceGroupName, - [string][Parameter(Mandatory=$false)][alias("Plan")]$AppServicePlan, - [switch][Parameter(Mandatory=$false)]$Auto, - [switch][Parameter(Mandatory=$false)]$AddRemote, - [string][Parameter(Mandatory=$false)]$GitRepositoryPath - ) - DynamicParam{ - #Set the dynamic parameters' name - $ParamName_location = 'Location' - # Create the collection of attributes - $AttributeCollection = New-Object System.Collections.ObjectModel.Collection[System.Attribute] - # Create and set the parameters' attributes - $ParameterAttribute = New-Object System.Management.Automation.ParameterAttribute - $ParameterAttribute.Mandatory = $false - # Add the attributes to the attributes collection - $AttributeCollection.Add($ParameterAttribute) - # Create the dictionary - $RuntimeParameterDictionary = New-Object System.Management.Automation.RuntimeDefinedParameterDictionary - #Generate and set the ValidateSet - $providerNamespace = "Microsoft.Web" - try - { - $availableLocations = $(Get-AzureRmResourceProvider | Where-Object {$_.ProviderNamespace -eq $providerNamespace}).Locations - } - catch - { - throw $_ - } - $ValidateSetAttribute = New-Object System.Management.Automation.ValidateSetAttribute($availableLocations) - # Add the ValidateSet to the attributes collection - $AttributeCollection.Add($ValidateSetAttribute) - # Create and return the dynamic parameter - $RuntimeParameter = New-Object System.Management.Automation.RuntimeDefinedParameter($ParamName_location, [string], $AttributeCollection) - $RuntimeParameterDictionary.Add($ParamName_location, $RuntimeParameter) - - return $RuntimeParameterDictionary - } - - BEGIN { - $context = Get-Context - $webSitesClient = Get-WebSitesClient $context - $resourceManagementClient = Get-ResourceManagementClient $context - } - - PROCESS { - #Validate Parameters - if (-not $PSBoundParameters.ContainsKey('Auto')) { - $parametersNotProvided = @() - if(-not $PSBoundParameters.ContainsKey('WebAppName')){ - $parametersNotProvided += 'WebAppName' - } - - if(-not $PSBoundParameters.ContainsKey('ResourceGroupName')){ - $parametersNotProvided += 'ResourceGroupName' - } - - if(-not $PSBoundParameters.ContainsKey('AppServicePlan')){ - $parametersNotProvided += 'AppServicePlan' - } - - if(-not $PSBoundParameters.ContainsKey('Location')){ - $parametersNotProvided += 'Location' - } - - $message = "The following parameters were not provided: " - $message += $($parametersNotProvided -join ',') + " ." - $message += "You can provide -Auto switch to use Smart Defaults." - $exception = New-Object -TypeName System.Exception -ArgumentList $message - throw $exception - } - - $mainActivity = "Create Azure Web App" - [string]$Location = $PSBoundParameters[$ParamName_location] - Write-Progress ` - -Activity $mainActivity ` - -CurrentOperation "Getting App Name information." - [string]$appName = Get-WebAppName ` - -ProvidedParameters $PSBoundParameters ` - -WebSitesClient $webSitesClient - if ($PSCmdlet.ShouldProcess($appName, "Create an Azure Web App")) { - Write-Progress ` - -Activity $mainActivity ` - -CurrentOperation "Getting Resource Group information." - [hashtable]$groupInfo = Get-ResourceGroupInfo ` - -ProvidedParameters $PSBoundParameters ` - -WebAppName $appName ` - -ResourceManagementClient $resourceManagementClient - Write-Progress ` - -Activity $mainActivity ` - -CurrentOperation "Getting App Service Plan information." - [hashtable]$appPlanInfo = Get-AppServicePlanInfo ` - -ProvidedParameters $PSBoundParameters ` - -WebAppName $appName ` - -ResourceGroupName $groupInfo.Name - Write-Progress ` - -Activity $mainActivity ` - -CurrentOperation "Getting App Location information." - [string]$appLocation = Get-AppLocation ` - -ProvidedParameters $PSBoundParameters ` - -ResourceGroupName $groupInfo.Name` - -ResourceGroupExists $groupInfo.Exists ` - -AvailableLocations $availableLocations - if ($groupInfo.Exists) { - $appGroup = Get-AzureRmResourceGroup ` - -Name $groupInfo.Name - $message = "Using resource group '$($appGroup.ResourceGroupName)' in location '$($appGroup.Location)'." - Write-Information -MessageData $message -InformationAction Continue - } else { - $appGroup = New-AzureRmResourceGroup ` - -Name $groupInfo.Name ` - -Location $appLocation - $message = "Created resource group '$($appGroup.ResourceGroupName)' in location '$($appGroup.Location)'." - Write-Information -MessageData $message -InformationAction Continue - } - - if ($appPlanInfo.Exists) { - $appPlan = Get-AzureRmAppServicePlan ` - -Name $appPlanInfo.Name ` - -ResourceGroupName $appPlanInfo.ResourceGroup - $message = "Using app service plan '$($appPlan.Name)' in location '$($appPlan.Location)' with Tier '$($appPlan.Sku.Tier)'." - Write-Information -MessageData $message -InformationAction Continue - } else { - $defaultTier = "Free" - $appPlan = New-AzureRmAppServicePlan ` - -Name $appPlanInfo.Name ` - -Location $appLocation ` - -Tier $defaultTier ` - -ResourceGroupName $appPlanInfo.ResourceGroup - $message = "Created app service plan '$($appPlan.Name)' in location '$($appPlan.Location)' with Tier '$($appPlan.Sku.Tier)'." - Write-Information -MessageData $message -InformationAction Continue - } - - $webapp = New-AzureRmWebApp ` - -Name $appName ` - -AppServicePlan $appPlan.Id ` - -ResourceGroupName $appGroup.ResourceGroupName ` - -Location $appLocation - - Write-Output $webapp - - if (($PSBoundParameters.ContainsKey('AddRemote') -or $PSBoundParameters.ContainsKey('Auto')) -and $webapp) { - Add-Remote -ProvidedParameters $PSBoundParameters -WebApp $webapp -GitRepositoryPath $GitRepositoryPath - } - } - } - - END {} -} - -function Add-Remote -{ - param( - [hashtable][Parameter()]$ProvidedParameters, - [Microsoft.Azure.Management.WebSites.Models.Site][Parameter()]$WebApp, - [string][Parameter()] $GitRepositoryPath - ) - [bool]$repoDetected = $true - [bool]$repoAdded = $true - $OriginalErrorActionPreference = $ErrorActionPreference - - if(-Not $ProvidedParameters.ContainsKey('GitRepositoryPath')){ - $GitRepositoryPath = (Get-Location).Path - } - - try - { - $ErrorActionPreference = 'Stop' - git -C $GitRepositoryPath status | Out-Null - } - catch - { - $repoDetected = $false - } - finally - { - $ErrorActionPreference = $OriginalErrorActionPreference - } - - if ($repoDetected) { - $message = "A git repository has been detected. " - try - { - $ErrorActionPreference = 'Stop' - # Get app-level deployment credentials - $xml = [xml](Get-AzureRmWebAppPublishingProfile -Name $WebApp.Name -ResourceGroupName $WebApp.ResourceGroup -OutputFile null) - $username = [System.Uri]::EscapeDataString($xml.SelectNodes("//publishProfile[@publishMethod=`"MSDeploy`"]/@userName").value) - $password = [System.Uri]::EscapeDataString($xml.SelectNodes("//publishProfile[@publishMethod=`"MSDeploy`"]/@userPWD").value) - $remoteName = "azure" - $url = ("https://$username" + ':' + "$password@$($WebApp.EnabledHostNames[1])") - # Add the Azure remote to a local Git respository - $command = "git -C $GitRepositoryPath remote add $remoteName $url" - Invoke-Expression -Command $command | Out-Null - if ($gitOutPut) { - $repoAdded = $false - } - } - catch - { - $repoAdded = $false - } - finally - { - $ErrorActionPreference = $OriginalErrorActionPreference - } - - if ($repoAdded) { - $message += "Added remote '$($remoteName)'. Push your code by running the command 'git push $($remoteName) master.' " - } else { - $message += "However, remote '$($remoteName)' could not be added. " - } - - Write-Information $message -InformationAction Continue - } -} - -function Get-WebAppName -{ - param( - [hashtable][Parameter()]$ProvidedParameters, - [Microsoft.Azure.Commands.Websites.Experiments.CustomWebSiteManagementClient][Parameter()]$WebSitesClient - ) - [string]$name = "" - [bool]$nameIsAvailable = $false - - if ($ProvidedParameters.ContainsKey('WebAppName')) { - $name = $ProvidedParameters.WebAppName - $nameIsAvailable = Test-NameAvailability $name $WebSitesClient - if (-not $NameIsAvailable) { - $message = "Website with given name '$name' already exists." - $exception = New-Object -TypeName System.Exception -ArgumentList $message - throw $exception - } - } else { - for ($i = 0; $i -le 2; $i++) { - $name ="WebApp$(Get-Random -max 1000000)" - $nameIsAvailable = Test-NameAvailability $name $WebSitesClient - if ($NameIsAvailable) { - break - } - } - } - return $name -} - -function Test-NameAvailability -{ - param( - [string][Parameter()]$WebAppName, - [Microsoft.Azure.Commands.Websites.Experiments.CustomWebSiteManagementClient][Parameter()]$WebSitesClient - ) - [string]$resourceType = "Site" - return $WebSitesClient.CheckNameAvailabilityWithHttpMessagesAsync($WebAppName, $resourceType).Result.Body.NameAvailable -} - -function Get-ResourceGroupInfo -{ - param( - [hashtable][Parameter()]$ProvidedParameters, - [string][Parameter(Mandatory=$false)]$WebAppName, - [Microsoft.Azure.Management.ResourceManager.ResourceManagementClient][Parameter()]$ResourceManagementClient - ) - [hashtable]$resourceGroupInfo = @{Name="";Exists=$false} - $defaultName = $WebAppName - - if ($ProvidedParameters.ContainsKey('ResourceGroupName')) { - $resourceGroupInfo.Name = $ProvidedParameters.ResourceGroupName - } else { - $resourceGroupInfo.Name = $defaultName - } - - $resourceGroupInfo.Exists = Test-ResourceGroupExistence $resourceGroupInfo.Name $ResourceManagementClient - - return $resourceGroupInfo -} - -function Test-ResourceGroupExistence -{ - param( - [string][Parameter()]$ResourceGroupName, - [Microsoft.Azure.Management.ResourceManager.ResourceManagementClient][Parameter()]$ResourceManagementClient - ) - return $ResourceManagementClient.ResourceGroups.CheckExistenceWithHttpMessagesAsync($ResourceGroupName).Result.Body -} - -function Get-AppServicePlanInfo -{ - param( - [hashtable][Parameter()]$ProvidedParameters, - [string][Parameter()]$WebAppName, - [string][Parameter()]$ResourceGroupName - ) - [hashtable]$appServicePlanInfo = @{Name="";ResourceGroup="";IsDefaultPlan=$false;Exists=$false} - [object[]]$appServicePlans = Get-AzureRmAppServicePlan - $defaultName = $WebAppName - - if ($ProvidedParameters.ContainsKey('AppServicePlan')) { - $regexp = '/subscriptions/[-A-Za-z0-9]+/resourceGroups/[-\w\._\(\)]+/providers/Microsoft.Web/serverfarms/[-\w\._\(\)]+$' - $idWasProvided = $ProvidedParameters.AppServicePlan -imatch $regexp - if ($idWasProvided) { - $parsedId = $ProvidedParameters.AppServicePlan.split('/') - $appServicePlanInfo.Name = $parsedId[$parsedId.Length - 1] - $appServicePlanInfo.ResourceGroup = $parsedId[4] - $existingPlan = $appServicePlans | Where-Object {$_.Id -eq $ProvidedParameters.AppServicePlan} - if (-not $existingPlan) { - $message = "The app service plan with the id provided does not exist." - $exception = New-Object -TypeName System.Exception -ArgumentList $message - throw $exception - } - } else { - $appServicePlanInfo.Name = $ProvidedParameters.AppServicePlan - } - $appServicePlanInfo.IsDefaultPlan = $false - } else { - $existentDefaultPlan = Get-DefaultAppServicePlan $AppServicePlans - if ($existentDefaultPlan) { - $appServicePlanInfo.Name = $existentDefaultPlan.Name - $appServicePlanInfo.ResourceGroup = $existentDefaultPlan.ResourceGroup - $appServicePlanInfo.IsDefaultPlan = $true - $appServicePlanInfo.Exists = $true - } else { - $appServicePlanInfo.Name = $defaultName - $appServicePlanInfo.IsDefaultPlan = $false - } - } - - if (-not $appServicePlanInfo.IsDefaultPlan) { - [object[]]$appServicePlansWithProvidedName = $appServicePlans | Where-Object {$_.Name -eq $appServicePlanInfo.Name} - if ($appServicePlansWithProvidedName) { - $appServicePlanInfo.Exists = $true - $appServicePlanWithProvidedNameAndGroup = $appServicePlansWithProvidedName | Where-Object {$_.ResourceGroup -eq $ResourceGroupName} - if ($appServicePlanWithProvidedNameAndGroup) { - $appServicePlanInfo.ResourceGroup = $appServicePlanWithProvidedNameAndGroup.ResourceGroup - } else { - if ($appServicePlansWithProvidedName.Count -gt 1) { - $message = "There are various App Service Plans with that name. An existing Resource Group name should be provided." - $exception = New-Object -TypeName System.Exception -ArgumentList $message - throw $exception - } else { - $appServicePlanInfo.ResourceGroup = $appServicePlansWithProvidedName.ResourceGroup - } - } - } else { - $appServicePlanInfo.Exists = $false - $appServicePlanInfo.ResourceGroup = $ResourceGroupName - } - } - - return $appServicePlanInfo -} - -function Get-DefaultAppServicePlan -{ - param( - [object[]][Parameter()]$AppServicePlans - ) - [object[]]$appServicePlanMatches = $AppServicePlans | Where-Object {$_.Sku.Tier -eq "Free"} - if($appServicePlanMatches){ - return $appServicePlanMatches[0] - } else { - return $null - } -} - -function Get-AppLocation -{ - param( - [hashtable][Parameter()]$ProvidedParameters, - [string][Parameter()]$ResourceGroupName, - [bool][Parameter()]$ResourceGroupExists, - [string[]][Parameter()]$AvailableLocations - ) - [string]$location = "" - - if ($ProvidedParameters.ContainsKey('Location')) { - $location = $ProvidedParameters.Location - } else { - if ($ResourceGroupExists) { - $location = $(Get-AzureRmResourceGroup -Name $ResourceGroupName).Location - } else { - $location = Get-DefaultLocation $AvailableLocations - } - } - return $location -} - -function Get-DefaultLocation -{ - param( - [string[]][Parameter()]$AvailableLocations - ) - # TODO: figure out a way to get a 'Smart Default Location' - return $AvailableLocations[0] -} - -function Get-Context -{ - return [Microsoft.Azure.Commands.Common.Authentication.Abstractions.AzureRmProfileProvider]::Instance.Profile.DefaultContext -} - -function Get-ResourceManagementClient -{ - param( - [Microsoft.Azure.Commands.Common.Authentication.Abstractions.IAzureContext] $Context - ) - $factory = [Microsoft.Azure.Commands.Common.Authentication.AzureSession]::Instance.ClientFactory - [System.Type[]]$types = [Microsoft.Azure.Commands.Common.Authentication.Abstractions.IAzureContext], [string] - $resourceManagementClient = [Microsoft.Azure.Management.ResourceManager.ResourceManagementClient] - $method = [Microsoft.Azure.Commands.Common.Authentication.IClientFactory].GetMethod("CreateArmClient", $types) - - $closedMethod = $method.MakeGenericMethod($resourceManagementClient) - $arguments = $Context, [Microsoft.Azure.Commands.Common.Authentication.Abstractions.AzureEnvironment+Endpoint]::ResourceManager - $client = $closedMethod.Invoke($factory, $arguments) - - return $client -} - -function Get-WebSitesClient -{ - param( - [Microsoft.Azure.Commands.Common.Authentication.Abstractions.IAzureContext] $Context - ) - $factory = [Microsoft.Azure.Commands.Common.Authentication.AzureSession]::Instance.ClientFactory - [System.Type[]]$types = [Microsoft.Azure.Commands.Common.Authentication.Abstractions.IAzureContext], [string] - $webSitesClient = [Microsoft.Azure.Commands.Websites.Experiments.CustomWebSiteManagementClient] - $method = [Microsoft.Azure.Commands.Common.Authentication.IClientFactory].GetMethod("CreateArmClient", $types) - - $closedMethod = $method.MakeGenericMethod($webSitesClient) - $arguments = $context, [Microsoft.Azure.Commands.Common.Authentication.Abstractions.AzureEnvironment+Endpoint]::ResourceManager - $client = $closedMethod.Invoke($factory, $arguments) - - return $client -} - -<# -.ExternalHelp AzureRM.Websites.Experiments-help.xml -#> -function New-AzWebAppGrayParam -{ - [CmdletBinding(SupportsShouldProcess=$true)] - [OutputType([Microsoft.Azure.Management.WebSites.Models.Site])] - param( - [string][Parameter(Mandatory=$false)][alias("Name")]$WebAppName, - [string][Parameter(Mandatory=$false)][alias("Group")]$ResourceGroupName, - [string][Parameter(Mandatory=$false)][alias("Plan")]$AppServicePlan, - [switch][Parameter(Mandatory=$false)]$Auto, - [switch][Parameter(Mandatory=$false)]$AddRemote, - [string][Parameter(Mandatory=$false)]$GitRepositoryPath - ) - DynamicParam{ - #Set the dynamic parameters' name - $ParamName_location = 'Location' - # Create the collection of attributes - $AttributeCollection = New-Object System.Collections.ObjectModel.Collection[System.Attribute] - # Create and set the parameters' attributes - $ParameterAttribute = New-Object System.Management.Automation.ParameterAttribute - if ($PSBoundParameters.ContainsKey('Auto')) { - $ParameterAttribute.Mandatory = $false - } else { - $ParameterAttribute.Mandatory = $true - } - # Add the attributes to the attributes collection - $AttributeCollection.Add($ParameterAttribute) - # Create the dictionary - $RuntimeParameterDictionary = New-Object System.Management.Automation.RuntimeDefinedParameterDictionary - #Generate and set the ValidateSet - $providerNamespace = "Microsoft.Web" - try - { - $availableLocations = $(Get-AzureRmResourceProvider | Where-Object {$_.ProviderNamespace -eq $providerNamespace}).Locations - } - catch - { - throw $_ - } - $ValidateSetAttribute = New-Object System.Management.Automation.ValidateSetAttribute($availableLocations) - # Add the ValidateSet to the attributes collection - $AttributeCollection.Add($ValidateSetAttribute) - # Create and return the dynamic parameter - $RuntimeParameter = New-Object System.Management.Automation.RuntimeDefinedParameter($ParamName_location, [string], $AttributeCollection) - $RuntimeParameterDictionary.Add($ParamName_location, $RuntimeParameter) - - return $RuntimeParameterDictionary - } - - BEGIN { - $context = Get-Context - $webSitesClient = Get-WebSitesClient $context - $resourceManagementClient = Get-ResourceManagementClient $context - } - - PROCESS { - $mainActivity = "Create Azure Web App" - [string]$Location = $PSBoundParameters[$ParamName_location] - Write-Progress ` - -Activity $mainActivity ` - -CurrentOperation "Getting App Name information." - [string]$appName = Get-WebAppNameGrayParam $PSBoundParameters $webSitesClient - if ($PSCmdlet.ShouldProcess($appName, "Create an Azure Web App")) { - - Write-Progress ` - -Activity $mainActivity ` - -CurrentOperation "Getting Resource Group information." - [hashtable]$groupInfo = Get-ResourceGroupInfoGrayParam $PSBoundParameters $appName $resourceManagementClient - Write-Progress ` - -Activity $mainActivity ` - -CurrentOperation "Getting App Service Plan information." - [hashtable]$appPlanInfo = Get-AppServicePlanInfoGrayParam $PSBoundParameters $appName $groupInfo.Name - Write-Progress ` - -Activity $mainActivity ` - -CurrentOperation "Getting App Location information." - [string]$appLocation = Get-LocationGrayParam $PSBoundParameters $groupInfo.Name $groupInfo.Exists $availableLocations - if ($groupInfo.Exists) { - $appGroup = Get-AzureRmResourceGroup ` - -Name $groupInfo.Name - $message = "Using resource group '$($appGroup.ResourceGroupName)' in location '$($appGroup.Location)'." - Write-Information -MessageData $message -InformationAction Continue - } else { - $appGroup = New-AzureRmResourceGroup ` - -Name $groupInfo.Name ` - -Location $appLocation - $message = "Created resource group '$($appGroup.ResourceGroupName)' in location '$($appGroup.Location)'." - Write-Information -MessageData $message -InformationAction Continue - } - - if ($appPlanInfo.Exists) { - $appPlan = Get-AzureRmAppServicePlan ` - -Name $appPlanInfo.Name ` - -ResourceGroupName $appPlanInfo.ResourceGroup - $message = "Using app service plan '$($appPlan.Name)' in location '$($appPlan.Location)' with Tier '$($appPlan.Sku.Tier)'." - Write-Information -MessageData $message -InformationAction Continue - } else { - $defaultTier = "Free" - $appPlan = New-AzureRmAppServicePlan ` - -Name $appPlanInfo.Name ` - -Location $appLocation ` - -Tier $defaultTier ` - -ResourceGroupName $appPlanInfo.ResourceGroup - $message = "Created app service plan '$($appPlan.Name)' in location '$($appPlan.Location)' with Tier '$($appPlan.Sku.Tier)'." - Write-Information -MessageData $message -InformationAction Continue - } - - $webapp = New-AzureRmWebApp ` - -Name $appName ` - -AppServicePlan $appPlan.Id ` - -ResourceGroupName $appGroup.ResourceGroupName ` - -Location $appLocation - - Write-Output $webapp - - Add-RemoteGrayParam -ProvidedParameters $PSBoundParameters -WebApp $webapp -GitRepositoryPath $GitRepositoryPath - } - } - - END {} -} - -function Add-RemoteGrayParam -{ - param( - [hashtable][Parameter()]$ProvidedParameters, - [Microsoft.Azure.Management.WebSites.Models.Site][Parameter()]$WebApp, - [string][Parameter()] $GitRepositoryPath - ) - [bool]$repoDetected = $true - [bool]$repoAdded = $true - $OriginalErrorActionPreference = $ErrorActionPreference - - if(-Not $ProvidedParameters.ContainsKey('GitRepositoryPath')){ - $GitRepositoryPath = (Get-Location).Path - } - - try - { - $ErrorActionPreference = 'Stop' - git -C $GitRepositoryPath status | Out-Null - } - catch - { - $repoDetected = $false - } - finally - { - $ErrorActionPreference = $OriginalErrorActionPreference - } - - if ($repoDetected) { - $message = "A git repository has been detected. " - try - { - $ErrorActionPreference = 'Stop' - - # Get app-level deployment credentials - $xml = [xml](Get-AzureRmWebAppPublishingProfile -Name $WebApp.Name -ResourceGroupName $WebApp.ResourceGroup -OutputFile null) - $username = $xml.SelectNodes("//publishProfile[@publishMethod=`"MSDeploy`"]/@userName").value - $password = $xml.SelectNodes("//publishProfile[@publishMethod=`"MSDeploy`"]/@userPWD").value - - # Add remote azure - $remoteName = "azure" - if ($ProvidedParameters.ContainsKey('Auto') -or $ProvidedParameters.ContainsKey('AddRemote')){ - Write-Information $message -InformationAction Continue - } else { - $title = $message - $message = "Would you like to add this webapp as a remote named '$remoteName'?" - $yes = New-Object System.Management.Automation.Host.ChoiceDescription "&Yes", ` - "Adds this webapp as a remote named '$remoteName'" - $no = New-Object System.Management.Automation.Host.ChoiceDescription "&No", ` - "No action is taken" - $options = [System.Management.Automation.Host.ChoiceDescription[]]($no, $yes) - $result = $host.ui.PromptForChoice($title, $message, $options, 0) - } - - if ($result -eq 1 -or $ProvidedParameters.ContainsKey('AddRemote') -or $ProvidedParameters.ContainsKey('Auto')) { - # Add the Azure remote to a local Git respository - $command = "git -C $GitRepositoryPath remote add $remoteName 'https://${username}:$password@$($WebApp.EnabledHostNames[0])'" + " 2> $gitOutput" - Invoke-Expression -Command $command | Out-Null - - } - - if ($gitOutPut) { - $repoAdded = $false - } - } - catch - { - $repoAdded = $false - } - finally - { - $ErrorActionPreference = $OriginalErrorActionPreference - } - - if ($repoAdded) { - $message = "Added remote '$($remoteName)'. Push your code by running the command 'git push $($remoteName) master.' " - } else { - $message = "Remote '$($remoteName)' could not be added. " - } - - Write-Information $message -InformationAction Continue - } -} - -function Get-WebAppNameGrayParam -{ - param( - [hashtable][Parameter()]$ProvidedParameters, - [Microsoft.Azure.Commands.Websites.Experiments.CustomWebSiteManagementClient][Parameter()]$WebSitesClient - ) - [string]$name = "" - [bool]$nameIsAvailable = $false - - if ($ProvidedParameters.ContainsKey('WebAppName')) { - $name = $ProvidedParameters.WebAppName - $nameIsAvailable = Test-NameAvailability $name $WebSitesClient - if (-not $NameIsAvailable) { - $message = "Website with given name '$name' already exists." - $exception = New-Object -TypeName System.Exception -ArgumentList $message - throw $exception - } - } else { - for ($i = 0; $i -le 2; $i++) { - $defaultName ="WebApp$(Get-Random -max 1000000)" - $nameIsAvailable = Test-NameAvailability $defaultName $WebSitesClient - if ($NameIsAvailable) { - break - } - } - - if ($ProvidedParameters.ContainsKey('Auto')) { - $name = $defaultName - } else { - $name = Get-WebAppNameFromUser $defaultName - } - } - - return $name -} - -function Get-WebAppNameFromUser -{ - param( - [string][Parameter()]$DefaultName - ) - - $selection = Read-Host "Enter a name for you WebApp or leave blank for default($defaultName)" - if ($selection) { - $nameIsAvailable = Test-NameAvailability $selection $WebSitesClient - if (-not $NameIsAvailable) { - $message = "Website with given name '$selection' already exists." - $exception = New-Object -TypeName System.Exception -ArgumentList $message - throw $exception - } else { - $name = $selection - } - } else { - $name = $DefaultName - } - - return $name -} - - -function Get-ResourceGroupInfoGrayParam -{ - param( - [hashtable][Parameter()]$ProvidedParameters, - [string][Parameter(Mandatory=$false)]$WebAppName, - [Microsoft.Azure.Management.ResourceManager.ResourceManagementClient][Parameter()]$ResourceManagementClient - ) - [hashtable]$resourceGroupInfo = @{Name="";Exists=$false} - $defaultName = $WebAppName - - if ($ProvidedParameters.ContainsKey('ResourceGroupName')) { - $resourceGroupInfo.Name = $ProvidedParameters.ResourceGroupName - } else { - if ($ProvidedParameters.ContainsKey('Auto')) { - $resourceGroupInfo.Name = $defaultName - } else { - $resourceGroupInfo.Name = Get-ResourceGroupNameFromUser $defaultName - } - - } - - $resourceGroupInfo.Exists = Test-ResourceGroupExistence $resourceGroupInfo.Name $ResourceManagementClient - - return $resourceGroupInfo -} - -function Get-ResourceGroupNameFromUser -{ - param( - [string][Parameter()]$DefaultName - ) - [object[]]$resourceGroups = Get-AzureRmResourceGroup - Write-Host "Resource Group options: " - Write-Host "[Default] $DefaultName" - for ($i = 1; $i -le $resourceGroups.Count; $i++) { - Write-Host "[$i] $($resourceGroups[$i-1].ResourceGroupName)" - } - - $selection = Read-Host "Enter your selection or a new resource group name (leave blank for default)" - if ($selection) { - if ($selection -match '^\d+$' -and $selection -le $resourceGroups.Count -and $selection -gt 0) { - $name = $resourceGroups[$selection - 1].ResourceGroupName - } else { - $name = $selection - } - } else { - $name = $DefaultName - } - - return $name -} - -function Get-AppServicePlanInfoGrayParam -{ - param( - [hashtable][Parameter()]$ProvidedParameters, - [string][Parameter()]$WebAppName, - [string][Parameter()]$ResourceGroupName - ) - [hashtable]$appServicePlanInfo = @{Name="";ResourceGroup="";IsDefaultPlan=$false;Exists=$false} - [object[]]$appServicePlans = Get-AzureRmAppServicePlan - $defaultName = $WebAppName - - if ($ProvidedParameters.ContainsKey('AppServicePlan')) { - $regexp = '/subscriptions/[-A-Za-z0-9]+/resourceGroups/[-\w\._\(\)]+/providers/Microsoft.Web/serverfarms/[-\w\._\(\)]+$' - $idWasProvided = $ProvidedParameters.AppServicePlan -imatch $regexp - if ($idWasProvided) { - $parsedId = $ProvidedParameters.AppServicePlan.split('/') - $appServicePlanInfo.Name = $parsedId[$parsedId.Length - 1] - $appServicePlanInfo.ResourceGroup = $parsedId[4] - $existingPlan = $appServicePlans | Where-Object {$_.Id -eq $ProvidedParameters.AppServicePlan} - if (-not $existingPlan) { - $message = "The app service plan with the id provided does not exist." - $exception = New-Object -TypeName System.Exception -ArgumentList $message - throw $exception - } - } else { - $appServicePlanInfo.Name = $ProvidedParameters.AppServicePlan - } - $appServicePlanInfo.IsDefaultPlan = $false - } else { - if($ProvidedParameters.ContainsKey('Auto')){ - $existentDefaultPlan = Get-DefaultAppServicePlan $appServicePlans - if ($existentDefaultPlan) { - $appServicePlanInfo.Name = $existentDefaultPlan.Name - $appServicePlanInfo.ResourceGroup = $existentDefaultPlan.ResourceGroup - $appServicePlanInfo.IsDefaultPlan = $true - $appServicePlanInfo.Exists = $true - } else { - $appServicePlanInfo.Name = $defaultName - $appServicePlanInfo.IsDefaultPlan = $false - } - } else { - $appServicePlanInfo = Get-AppServicePlanInfoFromUser $appServicePlans $defaultName - } - } - - if (-not $appServicePlanInfo.IsDefaultPlan) { - [object[]]$appServicePlansWithProvidedName = $appServicePlans | Where-Object {$_.Name -eq $appServicePlanInfo.Name} - if ($appServicePlansWithProvidedName) { - $appServicePlanInfo.Exists = $true - $appServicePlanWithProvidedNameAndGroup = $appServicePlansWithProvidedName | Where-Object {$_.ResourceGroup -eq $ResourceGroupName} - if ($appServicePlanWithProvidedNameAndGroup) { - $appServicePlanInfo.ResourceGroup = $appServicePlanWithProvidedNameAndGroup.ResourceGroup - } else { - if ($appServicePlansWithProvidedName.Count -gt 1) { - $message = "There are various App Service Plans with that name. An existing Resource Group name should be provided." - $exception = New-Object -TypeName System.Exception -ArgumentList $message - throw $exception - } else { - $appServicePlanInfo.ResourceGroup = $appServicePlansWithProvidedName.ResourceGroup - } - } - } else { - $appServicePlanInfo.Exists = $false - $appServicePlanInfo.ResourceGroup = $ResourceGroupName - } - } - - return $appServicePlanInfo -} - -function Get-AppServicePlanInfoFromUser -{ - param( - [object[]]$Plans, - [string]$DefaultName - ) - [hashtable]$appServicePlanInfo = @{Name="";ResourceGroup="";IsDefaultPlan=$false;Exists=$false} - $existentDefaultPlan = Get-DefaultAppServicePlan $Plans - - Write-Host "Plan options:" - if ($existentDefaultPlan) { - Write-Host "[Default] $($existentDefaultPlan.Name) {Tier=$($existentDefaultPlan.Sku.Tier);Location=$($existentDefaultPlan.Location)}" - } else { - Write-Host "[Default] $($defaultName) {Tier=Free}" - } - - for ($i = 1; $i -le $Plans.Count; $i++) { - Write-Host "[$i] $($Plans[$i-1].Name) {Tier=$($Plans[$i-1].Sku.Tier);Location=$($Plans[$i-1].Location)}" - } - - $selection = Read-Host "Enter your selection (leave blank for default)" - if ($selection) { - if ($selection -match '^\d+$' -and $selection -le $Plans.Count -and $selection -gt 0) { - $appServicePlanInfo.Name = $Plans[$selection - 1].Name - $appServicePlanInfo.IsDefaultPlan = $false - } else { - $appServicePlanInfo.Name = $selection - $appServicePlanInfo.IsDefaultPlan = $false - } - } else { - if ($existentDefaultPlan) { - $appServicePlanInfo.Name = $existentDefaultPlan.Name - $appServicePlanInfo.ResourceGroup = $existentDefaultPlan.ResourceGroup - $appServicePlanInfo.IsDefaultPlan = $true - $appServicePlanInfo.Exists = $true - } else { - $appServicePlanInfo.Name = $defaultName - $appServicePlanInfo.IsDefaultPlan = $false - } - } - - return $appServicePlanInfo - } - -function Get-LocationGrayParam -{ - param( - [hashtable][Parameter()]$ProvidedParameters, - [string][Parameter()]$ResourceGroupName, - [bool][Parameter()]$ResourceGroupExists, - [string[]][Parameter()]$AvailableLocations - ) - [string]$location = "" - - if ($ProvidedParameters.ContainsKey('Location')) { - $location = $ProvidedParameters.Location - } else { - if ($ResourceGroupExists) { - $location = $(Get-AzureRmResourceGroup -Name $ResourceGroupName).Location - } else { - $location = Get-DefaultLocation $AvailableLocations - } - } - - return $location -} - -function Get-LocationFromUser -{ - param( - [string][Parameter()]$DefaultLocation, - [string[]][Parameter()]$AvailableLocations - ) - Write-Host "WebApp Location options: " - Write-Host "[Default] $DefaultLocation" - for ($i = 1; $i -le $AvailableLocations.Count; $i++) { - Write-Host "[$i] $($AvailableLocations[$i-1])" - } - - $selection = Read-Host "Enter your selection (leave blank for default)" - if ($selection) { - if ($selection -match '^\d+$' -and $selection -le $AvailableLocations.Count -and $selection -gt 0) { - $location = $AvailableLocations[$selection - 1] - } else { - $location = $selection - } - } else { - $location = $DefaultLocation - } - - return $location -} - - -Export-ModuleMember -Cmdlet New-AzWebApp -Export-ModuleMember -Cmdlet New-AzWebAppGrayParam - diff --git a/experiments/Websites.Experiments/CustomWebSiteManagementClient.cs b/experiments/Websites.Experiments/CustomWebSiteManagementClient.cs deleted file mode 100644 index 1554de5aa4ba..000000000000 --- a/experiments/Websites.Experiments/CustomWebSiteManagementClient.cs +++ /dev/null @@ -1,510 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for -// license information. -// -// Code generated by Microsoft (R) AutoRest Code Generator 1.0.0.0 -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. - -using System.Net.Http.Headers; -using Microsoft.Rest; -using Microsoft.Rest.Azure; -using Microsoft.Rest.Serialization; -using Microsoft.Azure.Commands.Websites.Models; -using System.Collections.Generic; -using System.Linq; -using System.Net; -using System.Net.Http; -using System.Threading; -using System.Threading.Tasks; -using Newtonsoft.Json; - -namespace Microsoft.Azure.Commands.Websites.Experiments -{ - public partial class CustomWebSiteManagementClient : ServiceClient, IAzureClient - { - /// - /// The base URI of the service. - /// - public System.Uri BaseUri { get; set; } - - /// - /// Gets or sets json serialization settings. - /// - public JsonSerializerSettings SerializationSettings { get; private set; } - - /// - /// Gets or sets json deserialization settings. - /// - public JsonSerializerSettings DeserializationSettings { get; private set; } - - /// - /// Credentials needed for the client to connect to Azure. - /// - public ServiceClientCredentials Credentials { get; private set; } - - /// - /// Your Azure subscription ID. This is a GUID-formatted string (e.g. - /// 00000000-0000-0000-0000-000000000000). - /// - public string SubscriptionId { get; set; } - - /// - /// Gets or sets the preferred language for the response. - /// - public string AcceptLanguage { get; set; } - - /// - /// Gets or sets the retry timeout in seconds for Long Running Operations. - /// Default value is 30. - /// - public int? LongRunningOperationRetryTimeout { get; set; } - - /// - /// When set to true a unique x-ms-client-request-id value is generated and - /// included in each request. Default is true. - /// - public bool? GenerateClientRequestId { get; set; } - - /// - /// Initializes a new instance of the CustomWebSiteManagementClient class. - /// - /// - /// Optional. The delegating handlers to add to the http client pipeline. - /// - protected CustomWebSiteManagementClient(params DelegatingHandler[] handlers) : base(handlers) - { - Initialize(); - } - - /// - /// Initializes a new instance of the CustomWebSiteManagementClient class. - /// - /// - /// Optional. The http client handler used to handle http transport. - /// - /// - /// Optional. The delegating handlers to add to the http client pipeline. - /// - protected CustomWebSiteManagementClient(HttpClientHandler rootHandler, params DelegatingHandler[] handlers) : base(rootHandler, handlers) - { - Initialize(); - } - - /// - /// Initializes a new instance of the CustomWebSiteManagementClient class. - /// - /// - /// Optional. The base URI of the service. - /// - /// - /// Optional. The delegating handlers to add to the http client pipeline. - /// - /// - /// Thrown when a required parameter is null - /// - protected CustomWebSiteManagementClient(System.Uri baseUri, params DelegatingHandler[] handlers) : this(handlers) - { - if (baseUri == null) - { - throw new System.ArgumentNullException("baseUri"); - } - BaseUri = baseUri; - } - - /// - /// Initializes a new instance of the CustomWebSiteManagementClient class. - /// - /// - /// Optional. The base URI of the service. - /// - /// - /// Optional. The http client handler used to handle http transport. - /// - /// - /// Optional. The delegating handlers to add to the http client pipeline. - /// - /// - /// Thrown when a required parameter is null - /// - protected CustomWebSiteManagementClient(System.Uri baseUri, HttpClientHandler rootHandler, params DelegatingHandler[] handlers) : this(rootHandler, handlers) - { - if (baseUri == null) - { - throw new System.ArgumentNullException("baseUri"); - } - BaseUri = baseUri; - } - - /// - /// Initializes a new instance of the CustomWebSiteManagementClient class. - /// - /// - /// Required. Credentials needed for the client to connect to Azure. - /// - /// - /// Optional. The delegating handlers to add to the http client pipeline. - /// - /// - /// Thrown when a required parameter is null - /// - public CustomWebSiteManagementClient(ServiceClientCredentials credentials, params DelegatingHandler[] handlers) : this(handlers) - { - if (credentials == null) - { - throw new System.ArgumentNullException("credentials"); - } - Credentials = credentials; - if (Credentials != null) - { - Credentials.InitializeServiceClient(this); - } - } - - /// - /// Initializes a new instance of the CustomWebSiteManagementClient class. - /// - /// - /// Required. Credentials needed for the client to connect to Azure. - /// - /// - /// Optional. The http client handler used to handle http transport. - /// - /// - /// Optional. The delegating handlers to add to the http client pipeline. - /// - /// - /// Thrown when a required parameter is null - /// - public CustomWebSiteManagementClient(ServiceClientCredentials credentials, HttpClientHandler rootHandler, params DelegatingHandler[] handlers) : this(rootHandler, handlers) - { - if (credentials == null) - { - throw new System.ArgumentNullException("credentials"); - } - Credentials = credentials; - if (Credentials != null) - { - Credentials.InitializeServiceClient(this); - } - } - - /// - /// Initializes a new instance of the CustomWebSiteManagementClient class. - /// - /// - /// Optional. The base URI of the service. - /// - /// - /// Required. Credentials needed for the client to connect to Azure. - /// - /// - /// Optional. The delegating handlers to add to the http client pipeline. - /// - /// - /// Thrown when a required parameter is null - /// - public CustomWebSiteManagementClient(System.Uri baseUri, ServiceClientCredentials credentials, params DelegatingHandler[] handlers) : this(handlers) - { - if (baseUri == null) - { - throw new System.ArgumentNullException("baseUri"); - } - if (credentials == null) - { - throw new System.ArgumentNullException("credentials"); - } - BaseUri = baseUri; - Credentials = credentials; - if (Credentials != null) - { - Credentials.InitializeServiceClient(this); - } - } - - /// - /// Initializes a new instance of the CustomWebSiteManagementClient class. - /// - /// - /// Optional. The base URI of the service. - /// - /// - /// Required. Credentials needed for the client to connect to Azure. - /// - /// - /// Optional. The http client handler used to handle http transport. - /// - /// - /// Optional. The delegating handlers to add to the http client pipeline. - /// - /// - /// Thrown when a required parameter is null - /// - public CustomWebSiteManagementClient(System.Uri baseUri, ServiceClientCredentials credentials, HttpClientHandler rootHandler, params DelegatingHandler[] handlers) : this(rootHandler, handlers) - { - if (baseUri == null) - { - throw new System.ArgumentNullException("baseUri"); - } - if (credentials == null) - { - throw new System.ArgumentNullException("credentials"); - } - BaseUri = baseUri; - Credentials = credentials; - if (Credentials != null) - { - Credentials.InitializeServiceClient(this); - } - } - - /// - /// Initializes client properties. - /// - private void Initialize() - { - this.HttpClient.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); - BaseUri = new System.Uri("https://management.azure.com"); - AcceptLanguage = "en-US"; - LongRunningOperationRetryTimeout = 30; - GenerateClientRequestId = true; - SerializationSettings = new JsonSerializerSettings - { - Formatting = Newtonsoft.Json.Formatting.Indented, - DateFormatHandling = Newtonsoft.Json.DateFormatHandling.IsoDateFormat, - DateTimeZoneHandling = Newtonsoft.Json.DateTimeZoneHandling.Utc, - NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore, - ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Serialize, - ContractResolver = new ReadOnlyJsonContractResolver(), - Converters = new System.Collections.Generic.List - { - new Iso8601TimeSpanConverter() - } - }; - SerializationSettings.Converters.Add(new TransformationJsonConverter()); - DeserializationSettings = new JsonSerializerSettings - { - DateFormatHandling = Newtonsoft.Json.DateFormatHandling.IsoDateFormat, - DateTimeZoneHandling = Newtonsoft.Json.DateTimeZoneHandling.Utc, - NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore, - ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Serialize, - ContractResolver = new ReadOnlyJsonContractResolver(), - Converters = new System.Collections.Generic.List - { - new Iso8601TimeSpanConverter() - } - }; - DeserializationSettings.Converters.Add(new TransformationJsonConverter()); - DeserializationSettings.Converters.Add(new CloudErrorJsonConverter()); - } - - /// - /// Check if a resource name is available. - /// - /// - /// Check if a resource name is available. - /// - /// - /// Resource name to verify. - /// - /// - /// Resource type used for verification. Possible values include: 'Site', - /// 'Slot', 'HostingEnvironment' - /// - /// - /// Is fully qualified domain name. - /// - /// - /// Headers that will be added to request. - /// - /// - /// The cancellation token. - /// - /// - /// Thrown when the operation returned an invalid status code - /// - /// - /// Thrown when unable to deserialize the response - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// Thrown when a required parameter is null - /// - /// - /// A response object containing the response body and response headers. - /// - public async Task> CheckNameAvailabilityWithHttpMessagesAsync(string name, string type, bool? isFqdn = default(bool?), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) - { - if (SubscriptionId == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.SubscriptionId"); - } - if (name == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "name"); - } - if (type == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "type"); - } - string apiVersion = "2016-03-01"; - ResourceNameAvailabilityRequest request = new ResourceNameAvailabilityRequest(); - if (name != null || type != null || isFqdn != null) - { - request.Name = name; - request.Type = type; - request.IsFqdn = isFqdn; - } - // Tracing - bool _shouldTrace = ServiceClientTracing.IsEnabled; - string _invocationId = null; - if (_shouldTrace) - { - _invocationId = ServiceClientTracing.NextInvocationId.ToString(); - Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("apiVersion", apiVersion); - tracingParameters.Add("request", request); - tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "CheckNameAvailability", tracingParameters); - } - // Construct URL - var _baseUrl = BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/providers/Microsoft.Web/checknameavailability").ToString(); - _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(SubscriptionId)); - List _queryParameters = new List(); - if (apiVersion != null) - { - _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(apiVersion))); - } - if (_queryParameters.Count > 0) - { - _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); - } - // Create HTTP transport objects - var _httpRequest = new System.Net.Http.HttpRequestMessage(); - System.Net.Http.HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new System.Net.Http.HttpMethod("POST"); - _httpRequest.RequestUri = new System.Uri(_url); - // Set Headers - if (GenerateClientRequestId != null && GenerateClientRequestId.Value) - { - _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); - } - if (AcceptLanguage != null) - { - if (_httpRequest.Headers.Contains("accept-language")) - { - _httpRequest.Headers.Remove("accept-language"); - } - _httpRequest.Headers.TryAddWithoutValidation("accept-language", AcceptLanguage); - } - if (customHeaders != null) - { - foreach (var _header in customHeaders) - { - if (_httpRequest.Headers.Contains(_header.Key)) - { - _httpRequest.Headers.Remove(_header.Key); - } - _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); - } - } - - // Serialize Request - string _requestContent = null; - if (request != null) - { - _requestContent = SafeJsonConvert.SerializeObject(request, SerializationSettings); - _httpRequest.Content = new System.Net.Http.StringContent(_requestContent, System.Text.Encoding.UTF8); - _httpRequest.Content.Headers.ContentType = MediaTypeHeaderValue.Parse("application/json; charset=utf-8"); - } - // Set Credentials - if (Credentials != null) - { - cancellationToken.ThrowIfCancellationRequested(); - await Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - } - // Send Request - if (_shouldTrace) - { - ServiceClientTracing.SendRequest(_invocationId, _httpRequest); - } - cancellationToken.ThrowIfCancellationRequested(); - _httpResponse = await HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); - if (_shouldTrace) - { - ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); - } - HttpStatusCode _statusCode = _httpResponse.StatusCode; - cancellationToken.ThrowIfCancellationRequested(); - string _responseContent = null; - if ((int)_statusCode != 200) - { - var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); - try - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - CloudError _errorBody = SafeJsonConvert.DeserializeObject(_responseContent, DeserializationSettings); - if (_errorBody != null) - { - ex = new CloudException(_errorBody.Message); - ex.Body = _errorBody; - } - } - catch (JsonException) - { - // Ignore the exception - } - ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); - ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - if (_shouldTrace) - { - ServiceClientTracing.Error(_invocationId, ex); - } - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw ex; - } - // Create Result - var _result = new AzureOperationResponse(); - _result.Request = _httpRequest; - _result.Response = _httpResponse; - if (_httpResponse.Headers.Contains("x-ms-request-id")) - { - _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); - } - // Deserialize Response - if ((int)_statusCode == 200) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = SafeJsonConvert.DeserializeObject(_responseContent, DeserializationSettings); - } - catch (JsonException ex) - { - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); - } - } - if (_shouldTrace) - { - ServiceClientTracing.Exit(_invocationId, _result); - } - return _result; - } - } -} diff --git a/experiments/Websites.Experiments/MSSharedLibKey.snk b/experiments/Websites.Experiments/MSSharedLibKey.snk deleted file mode 100644 index 695f1b38774e839e5b90059bfb7f32df1dff4223..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 160 zcmV;R0AK$ABme*efB*oL000060ssI2Bme+XQ$aBR1ONa50098C{E+7Ye`kjtcRG*W zi8#m|)B?I?xgZ^2Sw5D;l4TxtPwG;3)3^j?qDHjEteSTF{rM+4WI`v zCD?tsZ^;k+S&r1&HRMb=j738S=;J$tCKNrc$@P|lZ - - - - Debug - AnyCPU - {870244A0-0703-4D43-AF20-58E9F2C6C63E} - Library - Properties - Microsoft.Azure.Commands.Websites.Experiments - Microsoft.Azure.Commands.Websites.Experiments - v4.5.2 - 512 - - - true - full - false - ..\..\src\Package\Debug\ResourceManager\AzureResourceManager\AzureRM.Websites.Experiments\ - DEBUG;TRACE - prompt - 4 - - - pdbonly - true - ..\..\src\Package\Release\ResourceManager\AzureResourceManager\AzureRM.Websites.Experiments\ - TRACE; SIGN - prompt - 4 - true - MSSharedLibKey.snk - true - - - - packages\Microsoft.Rest.ClientRuntime.2.3.9\lib\net452\Microsoft.Rest.ClientRuntime.dll - - - packages\Microsoft.Rest.ClientRuntime.Azure.3.3.9\lib\net452\Microsoft.Rest.ClientRuntime.Azure.dll - - - packages\Newtonsoft.Json.6.0.8\lib\net45\Newtonsoft.Json.dll - - - - - - - - - - - - - - - - - - - PreserveNewest - - - Always - - - PreserveNewest - - - PreserveNewest - - - PreserveNewest - - - PreserveNewest - - - - - PreserveNewest - - - - - - - - Always - - - - \ No newline at end of file diff --git a/experiments/Websites.Experiments/Microsoft.Azure.Commands.Websites.Experiments.sln b/experiments/Websites.Experiments/Microsoft.Azure.Commands.Websites.Experiments.sln deleted file mode 100644 index 85269d81eff6..000000000000 --- a/experiments/Websites.Experiments/Microsoft.Azure.Commands.Websites.Experiments.sln +++ /dev/null @@ -1,22 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 14 -VisualStudioVersion = 14.0.25420.1 -MinimumVisualStudioVersion = 10.0.40219.1 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Microsoft.Azure.Commands.Websites.Experiments", "Microsoft.Azure.Commands.Websites.Experiments.csproj", "{870244A0-0703-4D43-AF20-58E9F2C6C63E}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Any CPU = Debug|Any CPU - Release|Any CPU = Release|Any CPU - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {870244A0-0703-4D43-AF20-58E9F2C6C63E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {870244A0-0703-4D43-AF20-58E9F2C6C63E}.Debug|Any CPU.Build.0 = Debug|Any CPU - {870244A0-0703-4D43-AF20-58E9F2C6C63E}.Release|Any CPU.ActiveCfg = Release|Any CPU - {870244A0-0703-4D43-AF20-58E9F2C6C63E}.Release|Any CPU.Build.0 = Release|Any CPU - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal diff --git a/experiments/Websites.Experiments/Models/ResourceNameAvailability.cs b/experiments/Websites.Experiments/Models/ResourceNameAvailability.cs deleted file mode 100644 index d32860c63a0f..000000000000 --- a/experiments/Websites.Experiments/Models/ResourceNameAvailability.cs +++ /dev/null @@ -1,78 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for -// license information. -// -// Code generated by Microsoft (R) AutoRest Code Generator 1.0.0.0 -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. - -using Newtonsoft.Json; - -namespace Microsoft.Azure.Commands.Websites.Models -{ - /// - /// Information regarding availbility of a resource name. - /// - public partial class ResourceNameAvailability - { - /// - /// Initializes a new instance of the ResourceNameAvailability class. - /// - public ResourceNameAvailability() { } - - /// - /// Initializes a new instance of the ResourceNameAvailability class. - /// - /// <code>true</code> indicates - /// name is valid and available. <code>false</code> - /// indicates the name is invalid, unavailable, or both. - /// <code>Invalid</code> indicates the - /// name provided does not match Azure App Service naming requirements. - /// <code>AlreadyExists</code> indicates that the name is - /// already in use and is therefore unavailable. Possible values - /// include: 'Invalid', 'AlreadyExists' - /// If reason == invalid, provide the user with - /// the reason why the given name is invalid, and provide the resource - /// naming requirements so that the user can select a valid name. If - /// reason == AlreadyExists, explain that resource name is already in - /// use, and direct them to select a different name. - public ResourceNameAvailability(bool? nameAvailable = default(bool?), string reason = default(string), string message = default(string)) - { - NameAvailable = nameAvailable; - Reason = reason; - Message = message; - } - - /// - /// Gets or sets &lt;code&gt;true&lt;/code&gt; - /// indicates name is valid and available. - /// &lt;code&gt;false&lt;/code&gt; indicates the name - /// is invalid, unavailable, or both. - /// - [JsonProperty(PropertyName = "nameAvailable")] - public bool? NameAvailable { get; set; } - - /// - /// Gets or sets &lt;code&gt;Invalid&lt;/code&gt; - /// indicates the name provided does not match Azure App Service naming - /// requirements. - /// &lt;code&gt;AlreadyExists&lt;/code&gt; indicates - /// that the name is already in use and is therefore unavailable. - /// Possible values include: 'Invalid', 'AlreadyExists' - /// - [JsonProperty(PropertyName = "reason")] - public string Reason { get; set; } - - /// - /// Gets or sets if reason == invalid, provide the user with the reason - /// why the given name is invalid, and provide the resource naming - /// requirements so that the user can select a valid name. If reason == - /// AlreadyExists, explain that resource name is already in use, and - /// direct them to select a different name. - /// - [JsonProperty(PropertyName = "message")] - public string Message { get; set; } - - } -} - diff --git a/experiments/Websites.Experiments/Models/ResourceNameAvailabilityRequest.cs b/experiments/Websites.Experiments/Models/ResourceNameAvailabilityRequest.cs deleted file mode 100644 index e8815bcd0ffb..000000000000 --- a/experiments/Websites.Experiments/Models/ResourceNameAvailabilityRequest.cs +++ /dev/null @@ -1,78 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for -// license information. -// -// Code generated by Microsoft (R) AutoRest Code Generator 1.0.0.0 -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. - -using Microsoft.Rest; -using Newtonsoft.Json; - -namespace Microsoft.Azure.Commands.Websites.Models -{ - /// - /// Resource name availability request content. - /// - public partial class ResourceNameAvailabilityRequest - { - /// - /// Initializes a new instance of the ResourceNameAvailabilityRequest - /// class. - /// - public ResourceNameAvailabilityRequest() { } - - /// - /// Initializes a new instance of the ResourceNameAvailabilityRequest - /// class. - /// - /// Resource name to verify. - /// Resource type used for verification. Possible - /// values include: 'Site', 'Slot', 'HostingEnvironment' - /// Is fully qualified domain name. - public ResourceNameAvailabilityRequest(string name, string type, bool? isFqdn = default(bool?)) - { - Name = name; - Type = type; - IsFqdn = isFqdn; - } - - /// - /// Gets or sets resource name to verify. - /// - [JsonProperty(PropertyName = "name")] - public string Name { get; set; } - - /// - /// Gets or sets resource type used for verification. Possible values - /// include: 'Site', 'Slot', 'HostingEnvironment' - /// - [JsonProperty(PropertyName = "type")] - public string Type { get; set; } - - /// - /// Gets or sets is fully qualified domain name. - /// - [JsonProperty(PropertyName = "isFqdn")] - public bool? IsFqdn { get; set; } - - /// - /// Validate the object. - /// - /// - /// Thrown if validation fails - /// - public virtual void Validate() - { - if (Name == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "Name"); - } - if (Type == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "Type"); - } - } - } -} - diff --git a/experiments/Websites.Experiments/Properties/AssemblyInfo.cs b/experiments/Websites.Experiments/Properties/AssemblyInfo.cs deleted file mode 100644 index fc401feae3db..000000000000 --- a/experiments/Websites.Experiments/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,36 +0,0 @@ -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -[assembly: AssemblyTitle("Microsoft.Azure.Commands.Websites.Experiments")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("Microsoft.Azure.Commands.Websites.Experiments")] -[assembly: AssemblyCopyright("Copyright © 2017")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. -[assembly: ComVisible(false)] - -// The following GUID is for the ID of the typelib if this project is exposed to COM -[assembly: Guid("870244a0-0703-4d43-af20-58e9f2c6c63e")] - -// Version information for an assembly consists of the following four values: -// -// Major Version -// Minor Version -// Build Number -// Revision -// -// You can specify all the values or you can default the Build and Revision Numbers -// by using the '*' as shown below: -// [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.0.0.0")] -[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/experiments/Websites.Experiments/Run-UnitTests.ps1 b/experiments/Websites.Experiments/Run-UnitTests.ps1 deleted file mode 100644 index 68debcdb8413..000000000000 --- a/experiments/Websites.Experiments/Run-UnitTests.ps1 +++ /dev/null @@ -1,5 +0,0 @@ -#Requires -Modules AzureRM.Websites.Experiments, Pester - -$defaults = [System.IO.Path]::GetDirectoryName($PSCommandPath) -Set-Location $defaults -Invoke-Pester -EnableExit \ No newline at end of file diff --git a/experiments/Websites.Experiments/help/AzureRM.Websites.Experiments-help.xml b/experiments/Websites.Experiments/help/AzureRM.Websites.Experiments-help.xml deleted file mode 100644 index 9f3cad6cbbbe..000000000000 --- a/experiments/Websites.Experiments/help/AzureRM.Websites.Experiments-help.xml +++ /dev/null @@ -1,410 +0,0 @@ - - - - -New-AzWebApp -New -AzWebApp -Create a new Azure AppService website and attach it to a git repository. - - - -Create a new Azure AppService website and attach it to a git repository. - - -New-AzWebApp -WebAppName -The name of the Website. The website will automatically use this value as the subdomain for the created website. - - -String -String - -None - -ResourceGroupName -The name of the resource group for the Website. - - -String -String - -None - -AppServicePlan -The name or id of the AppService Plan to use with this WebApp. - - -String -String - -None - -GitRepositoryPath -The path to a github repository where remotes should be added. - - -String -String - -None - -AddRemote -Add a remote to local github repo. - - -SwitchParameter - -False - -Auto -Accept default values for all settings not provided, withotu prompting. - - -SwitchParameter - -False - -Location -{{Fill Location Description}} - - -String -String - -None - -Confirm -Prompts you for confirmation before running the cmdlet. - - -SwitchParameter - -False - -WhatIf -Shows what would happen if the cmdlet runs. The cmdlet is not run. - - -SwitchParameter - -False - - - -AddRemote -Add a remote to local github repo. - - -SwitchParameter -SwitchParameter - -False - -AppServicePlan -The name or id of the AppService Plan to use with this WebApp. - - -String -String - -None - -Auto -Accept default values for all settings not provided, withotu prompting. - - -SwitchParameter -SwitchParameter - -False - -GitRepositoryPath -The path to a github repository where remotes should be added. - - -String -String - -None - -Location -{{Fill Location Description}} - - -String -String - -None - -ResourceGroupName -The name of the resource group for the Website. - - -String -String - -None - -WebAppName -The name of the Website. The website will automatically use this value as the subdomain for the created website. - - -String -String - -None - -Confirm -Prompts you for confirmation before running the cmdlet. - - -SwitchParameter -SwitchParameter - -False - -WhatIf -Shows what would happen if the cmdlet runs. The cmdlet is not run. - - -SwitchParameter -SwitchParameter - -False - - -None - - - - - - -Microsoft.Azure.Management.WebSites.Models.Site - -Details about the created website, including URL and github repo url. - - - - - - - - -Example 1: Create a website with prompts for settings -PS C:\> New-AzWebApp contosoWebApp -Creates a web application. The user will be prompted for the appservice to use and other settings. - - - -Example 2: Create a website with default settings -PS C:\> New-AzWebApp contosoWebApp -Auto -Creates a web application using default settings. - - - - - - - -New-AzWebAppGrayParam -New -AzWebAppGrayParam -Create an Azure Website using Azure App Service. - - - -Create an Azure Website using Azure App Service. This cmdlet uses the 'Gray Parameter' experience, which will prompt the user with default values for parameters that are not provided. Using -Auto indicates that further prompting for defaults should not occur. - - -New-AzWebAppGrayParam -WebAppName -The name of the website. - - -String -String - -None - -ResourceGroupName -The name of the resource group to create the website in. - - -String -String - -None - -AppServicePlan -The AppService Plan to use for thsi website. If not provided, the website will create an app service plan, or join an existing free AppService plan. - - -String -String - -None - -GitRepositoryPath -The path to a github repository containingg the application for the website. A remote for pushign to the website will be added to this repository. - - -String -String - -None - -AddRemote -Add a remote github repository to the given github repo. - - -SwitchParameter - -False - -Auto -Skip parameter prompting for remaining parameters. - - -SwitchParameter - -False - -Location -{{Fill Location Description}} - - -String -String - -None - -Confirm -Prompts you for confirmation before running the cmdlet. - - -SwitchParameter - -False - -WhatIf -Shows what would happen if the cmdlet runs. The cmdlet is not run. - - -SwitchParameter - -False - - - -AddRemote -Add a remote github repository to the given github repo. - - -SwitchParameter -SwitchParameter - -False - -AppServicePlan -The AppService Plan to use for thsi website. If not provided, the website will create an app service plan, or join an existing free AppService plan. - - -String -String - -None - -Auto -Skip parameter prompting for remaining parameters. - - -SwitchParameter -SwitchParameter - -False - -GitRepositoryPath -The path to a github repository containingg the application for the website. A remote for pushign to the website will be added to this repository. - - -String -String - -None - -Location -{{Fill Location Description}} - - -String -String - -None - -ResourceGroupName -The name of the resource group to create the website in. - - -String -String - -None - -WebAppName -The name of the website. - - -String -String - -None - -Confirm -Prompts you for confirmation before running the cmdlet. - - -SwitchParameter -SwitchParameter - -False - -WhatIf -Shows what would happen if the cmdlet runs. The cmdlet is not run. - - -SwitchParameter -SwitchParameter - -False - - -None - - - - - - -Microsoft.Azure.Management.WebSites.Models.Site - -Details about the created website, including its URL. - - - - - - - - -Example 1 -PS C:\> New-AzWebAppGrayParam -Location "East US" -Create a web application with detailed prompts for parameter values that are not provided, including simple defaults. - - - - - - - diff --git a/experiments/Websites.Experiments/help/New-AzWebApp.md b/experiments/Websites.Experiments/help/New-AzWebApp.md deleted file mode 100644 index 445098a589f4..000000000000 --- a/experiments/Websites.Experiments/help/New-AzWebApp.md +++ /dev/null @@ -1,190 +0,0 @@ ---- -external help file: AzureRM.Websites.Experiments-help.xml -online version: -schema: 2.0.0 ---- - -# New-AzWebApp - -## SYNOPSIS -Create a new Azure AppService website and attach it to a git repository. - -## SYNTAX - -``` -New-AzWebApp [[-WebAppName] ] [[-ResourceGroupName] ] [[-AppServicePlan] ] [-Auto] - [-AddRemote] [[-GitRepositoryPath] ] [-WhatIf] [-Confirm] [-Location ] [] -``` - -## DESCRIPTION -Create a new Azure AppService website and attach it to a git repository. - -## EXAMPLES - -### Example 1: Create a website with prompts for settings -``` -PS C:\> New-AzWebApp contosoWebApp -``` - -Creates a web application. The user will be prompted for the appservice to use and other settings. - -### Example 2: Create a website with default settings -``` -PS C:\> New-AzWebApp contosoWebApp -Auto -``` - -Creates a web application using default settings. - -## PARAMETERS - -### -AddRemote -Add a remote to local github repo. - -```yaml -Type: SwitchParameter -Parameter Sets: (All) -Aliases: - -Required: False -Position: Named -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -AppServicePlan -The name or id of the AppService Plan to use with this WebApp. - -```yaml -Type: String -Parameter Sets: (All) -Aliases: Plan - -Required: False -Position: 2 -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -Auto -Accept default values for all settings not provided, withotu prompting. - -```yaml -Type: SwitchParameter -Parameter Sets: (All) -Aliases: - -Required: False -Position: Named -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -GitRepositoryPath -The path to a github repository where remotes should be added. - -```yaml -Type: String -Parameter Sets: (All) -Aliases: - -Required: False -Position: 3 -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -Location -{{Fill Location Description}} - -```yaml -Type: String -Parameter Sets: (All) -Aliases: - -Required: False -Position: Named -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -ResourceGroupName -The name of the resource group for the Website. - -```yaml -Type: String -Parameter Sets: (All) -Aliases: Group - -Required: False -Position: 1 -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -WebAppName -The name of the Website. The website will automatically use this value as the subdomain for the created website. - -```yaml -Type: String -Parameter Sets: (All) -Aliases: Name - -Required: False -Position: 0 -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -Confirm -Prompts you for confirmation before running the cmdlet. - -```yaml -Type: SwitchParameter -Parameter Sets: (All) -Aliases: cf - -Required: False -Position: Named -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -WhatIf -Shows what would happen if the cmdlet runs. The cmdlet is not run. - -```yaml -Type: SwitchParameter -Parameter Sets: (All) -Aliases: wi - -Required: False -Position: Named -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### CommonParameters -This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters (http://go.microsoft.com/fwlink/?LinkID=113216). - -## INPUTS - -### None - -## OUTPUTS - -### Microsoft.Azure.Management.WebSites.Models.Site -Details about the created website, including URL and github repo url. - -## NOTES - -## RELATED LINKS - diff --git a/experiments/Websites.Experiments/help/New-AzWebAppGrayParam.md b/experiments/Websites.Experiments/help/New-AzWebAppGrayParam.md deleted file mode 100644 index b10ab175b04e..000000000000 --- a/experiments/Websites.Experiments/help/New-AzWebAppGrayParam.md +++ /dev/null @@ -1,185 +0,0 @@ ---- -external help file: AzureRM.Websites.Experiments-help.xml -online version: -schema: 2.0.0 ---- - -# New-AzWebAppGrayParam - -## SYNOPSIS -Create an Azure Website using Azure App Service. - -## SYNTAX - -``` -New-AzWebAppGrayParam [[-WebAppName] ] [[-ResourceGroupName] ] [[-AppServicePlan] ] - [-Auto] [-AddRemote] [[-GitRepositoryPath] ] [-WhatIf] [-Confirm] -Location - [] -``` - -## DESCRIPTION -Create an Azure Website using Azure App Service. This cmdlet uses the 'Gray Parameter' experience, which will prompt the user with default -values for parameters that are not provided. Using -Auto indicates that further prompting for defaults should not occur. - -## EXAMPLES - -### Example 1 -``` -PS C:\> New-AzWebAppGrayParam -Location "East US" -``` - -Create a web application with detailed prompts for parameter values that are not provided, including simple defaults. - -## PARAMETERS - -### -AddRemote -Add a remote github repository to the given github repo. - -```yaml -Type: SwitchParameter -Parameter Sets: (All) -Aliases: - -Required: False -Position: Named -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -AppServicePlan -The AppService Plan to use for thsi website. If not provided, the website will create an app service plan, or join an existing free AppService plan. - -```yaml -Type: String -Parameter Sets: (All) -Aliases: Plan - -Required: False -Position: 2 -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -Auto -Skip parameter prompting for remaining parameters. - -```yaml -Type: SwitchParameter -Parameter Sets: (All) -Aliases: - -Required: False -Position: Named -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -GitRepositoryPath -The path to a github repository containingg the application for the website. A remote for pushign to the website will be added to this repository. - -```yaml -Type: String -Parameter Sets: (All) -Aliases: - -Required: False -Position: 3 -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -Location -{{Fill Location Description}} - -```yaml -Type: String -Parameter Sets: (All) -Aliases: - -Required: True -Position: Named -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -ResourceGroupName -The name of the resource group to create the website in. - -```yaml -Type: String -Parameter Sets: (All) -Aliases: Group - -Required: False -Position: 1 -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -WebAppName -The name of the website. - -```yaml -Type: String -Parameter Sets: (All) -Aliases: Name - -Required: False -Position: 0 -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -Confirm -Prompts you for confirmation before running the cmdlet. - -```yaml -Type: SwitchParameter -Parameter Sets: (All) -Aliases: cf - -Required: False -Position: Named -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -WhatIf -Shows what would happen if the cmdlet runs. The cmdlet is not run. - -```yaml -Type: SwitchParameter -Parameter Sets: (All) -Aliases: wi - -Required: False -Position: Named -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### CommonParameters -This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters (http://go.microsoft.com/fwlink/?LinkID=113216). - -## INPUTS - -### None - -## OUTPUTS - -### Microsoft.Azure.Management.WebSites.Models.Site -Details about the created website, including its URL. - -## NOTES - -## RELATED LINKS - diff --git a/experiments/Websites.Experiments/packages.config b/experiments/Websites.Experiments/packages.config deleted file mode 100644 index d0a5c6543553..000000000000 --- a/experiments/Websites.Experiments/packages.config +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file