From c65f39479ed3e882eb3659b98615584e6f0b2169 Mon Sep 17 00:00:00 2001 From: Tai-Yi Wu Date: Tue, 24 Apr 2018 15:12:03 -0700 Subject: [PATCH 01/10] Enable gateway --- .../ScenarioTests/AsTests.cs | 8 ++++ .../ScenarioTests/AsTests.ps1 | 27 +++++++++++ .../Commands.AnalysisServices.csproj | 1 + .../NewAzureRmAnalysisServicesServer.cs | 23 +++++++++- .../SetAzureRmAnalysisServicesServer.cs | 35 +++++++++++++- .../Models/AnalysisServicesClient.cs | 46 ++++++++++++++++--- .../Models/AzureAnalysisServicesServer.cs | 20 ++++---- .../Models/ServerGateway.cs | 28 +++++++++++ .../Models/ServerSku.cs | 15 +++--- 9 files changed, 175 insertions(+), 28 deletions(-) create mode 100644 src/ResourceManager/AnalysisServices/Commands.AnalysisServices/Models/ServerGateway.cs diff --git a/src/ResourceManager/AnalysisServices/Commands.AnalysisServices.Test/ScenarioTests/AsTests.cs b/src/ResourceManager/AnalysisServices/Commands.AnalysisServices.Test/ScenarioTests/AsTests.cs index 353dd6e70b2e..b367ad93b8b2 100644 --- a/src/ResourceManager/AnalysisServices/Commands.AnalysisServices.Test/ScenarioTests/AsTests.cs +++ b/src/ResourceManager/AnalysisServices/Commands.AnalysisServices.Test/ScenarioTests/AsTests.cs @@ -93,5 +93,13 @@ public void TestAnalysisServicesServerLoginWithSPN() { NewInstance.RunPsTest("Test-AnalysisServicesServerLoginWithSPN"); } + + [Fact] + [Trait(Category.RunType, Category.LiveOnly)] + public void TestAnalysisServicesServerGateway() + { + NewInstance.RunPsTest("Test-AnalysisServicesServerGateway"); + } + } } diff --git a/src/ResourceManager/AnalysisServices/Commands.AnalysisServices.Test/ScenarioTests/AsTests.ps1 b/src/ResourceManager/AnalysisServices/Commands.AnalysisServices.Test/ScenarioTests/AsTests.ps1 index d55f8f28c3a5..aa7b6dee625d 100644 --- a/src/ResourceManager/AnalysisServices/Commands.AnalysisServices.Test/ScenarioTests/AsTests.ps1 +++ b/src/ResourceManager/AnalysisServices/Commands.AnalysisServices.Test/ScenarioTests/AsTests.ps1 @@ -611,4 +611,31 @@ function Test-AnalysisServicesServerLoginWithSPN { } +} + +<# +.SYNOPSIS +Tests Analysis Services server lifecycle Failure scenarios (Create, Update, Get, Delete). +#> +function Test-AnalysisServicesServerGateway +{ + try + { + + # Updating server + $tagsToUpdate = @{"TestTag" = "TestUpdate"} + #$serverUpdated = Set-AzureRmAnalysisServicesServer -ResourceGroupName $resourceGroupName -Name $serverName -Tag $tagsToUpdate -GatewayName 'azsdktest' -GatewayResourceGroupName 'TestRG' -GatewaySubscriptionId 'ba59a556-5034-4bbb-80b4-4c37cf1083e9' -PassThru + $serverUpdated = Set-AzureRmAnalysisServicesServer -ResourceGroupName 'TestRG' -Name 'azsdktest0309' -Tag $tagsToUpdate -DisassociateGateway -PassThru + Assert-NotNull $serverUpdated.Tag "Tag do not exists" + Assert-NotNull $serverUpdated.Tag["TestTag"] "The updated tag 'TestTag' does not exist" + Assert-AreEqual $serverUpdated.AsAdministrators.Count 2 + Assert-AreEqual 1 $serverUpdated.Sku.Capacity + + } + finally + { + # cleanup the resource group that was used in case it still exists. This is a best effort task, we ignore failures here. + Invoke-HandledCmdlet -Command {Remove-AzureRmAnalysisServicesServer -ResourceGroupName $resourceGroupName -Name $serverName -ErrorAction SilentlyContinue} -IgnoreFailures + Invoke-HandledCmdlet -Command {Remove-AzureRmResourceGroup -Name $resourceGroupName -ErrorAction SilentlyContinue} -IgnoreFailures + } } \ No newline at end of file diff --git a/src/ResourceManager/AnalysisServices/Commands.AnalysisServices/Commands.AnalysisServices.csproj b/src/ResourceManager/AnalysisServices/Commands.AnalysisServices/Commands.AnalysisServices.csproj index 60350bfec7ec..f6e1ce8206b9 100644 --- a/src/ResourceManager/AnalysisServices/Commands.AnalysisServices/Commands.AnalysisServices.csproj +++ b/src/ResourceManager/AnalysisServices/Commands.AnalysisServices/Commands.AnalysisServices.csproj @@ -56,6 +56,7 @@ + diff --git a/src/ResourceManager/AnalysisServices/Commands.AnalysisServices/Commands/NewAzureRmAnalysisServicesServer.cs b/src/ResourceManager/AnalysisServices/Commands.AnalysisServices/Commands/NewAzureRmAnalysisServicesServer.cs index ace8f62f4fdb..de92852a3920 100644 --- a/src/ResourceManager/AnalysisServices/Commands.AnalysisServices/Commands/NewAzureRmAnalysisServicesServer.cs +++ b/src/ResourceManager/AnalysisServices/Commands.AnalysisServices/Commands/NewAzureRmAnalysisServicesServer.cs @@ -82,7 +82,19 @@ public class NewAnalysisServicesServer : AnalysisServicesCmdletBase HelpMessage = "Firewall configuration")] public PsAzureAnalysisServicesFirewallConfig FirewallConfig { get; set; } - public override void ExecuteCmdlet() + [Parameter(ValueFromPipelineByPropertyName = true, Mandatory = false, + HelpMessage = "Gateway resource name")] + public string GatewayName { get; set; } + + [Parameter(ValueFromPipelineByPropertyName = true, Mandatory = false, + HelpMessage = "Gateway resource group name")] + public string GatewayResourceGroupName { get; set; } + + [Parameter(ValueFromPipelineByPropertyName = true, Mandatory = false, + HelpMessage = "Gateway subscription Id")] + public string GatewaySubscriptionId { get; set; } + + public override void ExecuteCmdlet() { if (ShouldProcess(Name, Resources.CreateNewAnalysisServicesServer)) { @@ -144,7 +156,14 @@ public override void ExecuteCmdlet() ReadonlyReplicaCount = 0; } - var createdServer = AnalysisServicesClient.CreateOrUpdateServer(ResourceGroupName, Name, Location, Sku, Tag, Administrator, null, BackupBlobContainerUri, ReadonlyReplicaCount, DefaultConnectionMode, setting); + if (string.IsNullOrEmpty(GatewayResourceGroupName)) + { + GatewayResourceGroupName = ResourceGroupName; + } + + string gatewayId = AnalysisServicesClient.GetGatewayResourceId(GatewayName, GatewayResourceGroupName, GatewaySubscriptionId); + + var createdServer = AnalysisServicesClient.CreateOrUpdateServer(ResourceGroupName, Name, Location, Sku, Tag, Administrator, null, BackupBlobContainerUri, ReadonlyReplicaCount, DefaultConnectionMode, setting, gatewayId); WriteObject(AzureAnalysisServicesServer.FromAnalysisServicesServer(createdServer)); } } diff --git a/src/ResourceManager/AnalysisServices/Commands.AnalysisServices/Commands/SetAzureRmAnalysisServicesServer.cs b/src/ResourceManager/AnalysisServices/Commands.AnalysisServices/Commands/SetAzureRmAnalysisServicesServer.cs index 56b8103f1891..f502cb54c79a 100644 --- a/src/ResourceManager/AnalysisServices/Commands.AnalysisServices/Commands/SetAzureRmAnalysisServicesServer.cs +++ b/src/ResourceManager/AnalysisServices/Commands.AnalysisServices/Commands/SetAzureRmAnalysisServicesServer.cs @@ -88,7 +88,23 @@ public int ReadonlyReplicaCount HelpMessage = "Firewall configuration")] public PsAzureAnalysisServicesFirewallConfig FirewallConfig { get; set; } - public override void ExecuteCmdlet() + [Parameter(ValueFromPipelineByPropertyName = true, Mandatory = false, + HelpMessage = "Gateway resource name")] + public string GatewayName { get; set; } + + [Parameter(ValueFromPipelineByPropertyName = true, Mandatory = false, + HelpMessage = "Gateway resource group name")] + public string GatewayResourceGroupName { get; set; } + + [Parameter(ValueFromPipelineByPropertyName = true, Mandatory = false, + HelpMessage = "Gateway subscription Id")] + public string GatewaySubscriptionId { get; set; } + + [Parameter(ValueFromPipelineByPropertyName = true, Mandatory = false, + HelpMessage = "Disassociate current gateway")] + public SwitchParameter DisassociateGateway { get; set; } + + public override void ExecuteCmdlet() { if (string.IsNullOrEmpty(Name)) { @@ -147,7 +163,22 @@ public override void ExecuteCmdlet() ReadonlyReplicaCount = -1; } - AnalysisServicesServer updatedServer = AnalysisServicesClient.CreateOrUpdateServer(ResourceGroupName, Name, location, Sku, Tag, Administrator, currentServer, BackupBlobContainerUri, ReadonlyReplicaCount, DefaultConnectionMode, setting); + if (string.IsNullOrEmpty(GatewayResourceGroupName)) + { + GatewayResourceGroupName = ResourceGroupName; + } + + string gatewayResourceId = null; + if (DisassociateGateway.IsPresent) + { + gatewayResourceId = "-"; + } + else + { + gatewayResourceId = AnalysisServicesClient.GetGatewayResourceId(GatewayName, GatewayResourceGroupName, GatewaySubscriptionId); + } + + AnalysisServicesServer updatedServer = AnalysisServicesClient.CreateOrUpdateServer(ResourceGroupName, Name, location, Sku, Tag, Administrator, currentServer, BackupBlobContainerUri, ReadonlyReplicaCount, DefaultConnectionMode, setting, gatewayResourceId); if(PassThru.IsPresent) { diff --git a/src/ResourceManager/AnalysisServices/Commands.AnalysisServices/Models/AnalysisServicesClient.cs b/src/ResourceManager/AnalysisServices/Commands.AnalysisServices/Models/AnalysisServicesClient.cs index 3640de291895..8e203a50a028 100644 --- a/src/ResourceManager/AnalysisServices/Commands.AnalysisServices/Models/AnalysisServicesClient.cs +++ b/src/ResourceManager/AnalysisServices/Commands.AnalysisServices/Models/AnalysisServicesClient.cs @@ -33,6 +33,7 @@ public class AnalysisServicesClient private readonly AnalysisServicesManagementClient _client; private readonly Guid _subscriptionId; private readonly string _currentUser; + public const string gatewayResourceIdFormat = "/subscriptions/{0}/resourceGroups/{1}/providers/Microsoft.Web/connectionGateways/{2}"; public AnalysisServicesClient(IAzureContext context) { @@ -65,7 +66,8 @@ public AnalysisServicesServer CreateOrUpdateServer( string backupBlobContainerUri = null, int ReadonlyReplicaCount = 0, string DefaultConnectionMode = null, - IPv4FirewallSettings setting = null) + IPv4FirewallSettings setting = null, + string gatewayId = null) { if (string.IsNullOrEmpty(resourceGroupName)) { @@ -87,7 +89,17 @@ public AnalysisServicesServer CreateOrUpdateServer( } } - AnalysisServicesServer newOrUpdatedServer = null; + GatewayDetails gatewayDetails = null; + if (gatewayId == "-") + { + gatewayDetails = new GatewayDetails("", "", ""); + } + else + { + gatewayDetails = new GatewayDetails(gatewayId); + } + + AnalysisServicesServer newOrUpdatedServer = null; if (existingServer != null) { var updateParameters = new AnalysisServicesServerUpdateParameters() @@ -121,6 +133,11 @@ public AnalysisServicesServer CreateOrUpdateServer( updateParameters.IpV4FirewallSettings = setting; } + if (gatewayId != null && gatewayId != "-") + { + updateParameters.GatewayDetails = gatewayDetails; + } + newOrUpdatedServer = _client.Servers.Update(resourceGroupName, serverName, updateParameters); } else @@ -142,8 +159,9 @@ public AnalysisServicesServer CreateOrUpdateServer( Sku = GetResourceSkuFromName(skuName, ReadonlyReplicaCount + 1), Tags = tags, QuerypoolConnectionMode = connectionMode, - IpV4FirewallSettings = setting - }); + IpV4FirewallSettings = setting, + GatewayDetails = gatewayDetails + }); } return newOrUpdatedServer; @@ -263,6 +281,22 @@ public void ResumeServer(string resourceGroupName, string serverName) _client.Servers.Resume(resourceGroupName, serverName); } - #endregion - } + public string GetGatewayResourceId(string gatewayName, string resourceGroupName, string subscriptionId) + { + string resourcdId = null; + if (!string.IsNullOrEmpty(gatewayName)) + { + if (string.IsNullOrEmpty(subscriptionId)) + { + subscriptionId = _client.SubscriptionId; + } + + resourcdId = string.Format(gatewayResourceIdFormat, subscriptionId, resourceGroupName, gatewayName); + } + + return resourcdId; + } + + #endregion + } } \ No newline at end of file diff --git a/src/ResourceManager/AnalysisServices/Commands.AnalysisServices/Models/AzureAnalysisServicesServer.cs b/src/ResourceManager/AnalysisServices/Commands.AnalysisServices/Models/AzureAnalysisServicesServer.cs index 7e3c6ac5cbaa..96fa40803837 100644 --- a/src/ResourceManager/AnalysisServices/Commands.AnalysisServices/Models/AzureAnalysisServicesServer.cs +++ b/src/ResourceManager/AnalysisServices/Commands.AnalysisServices/Models/AzureAnalysisServicesServer.cs @@ -47,7 +47,9 @@ public class AzureAnalysisServicesServer public PsAzureAnalysisServicesFirewallConfig FirewallConfig { get; set; } - internal static AzureAnalysisServicesServerDetail FromAnalysisServicesServer(AnalysisServicesServer server) + public ServerGateway GatewayInfo { get; set; } + + internal static AzureAnalysisServicesServer FromAnalysisServicesServer(AnalysisServicesServer server) { if (server == null) { @@ -77,7 +79,7 @@ internal static AzureAnalysisServicesServerDetail FromAnalysisServicesServer(Ana config = new PsAzureAnalysisServicesFirewallConfig(enablePowerBIService, rules); } - return new AzureAnalysisServicesServerDetail() + return new AzureAnalysisServicesServer() { AsAdministrators = server.AsAdministrators == null ? new List() @@ -89,29 +91,25 @@ internal static AzureAnalysisServicesServerDetail FromAnalysisServicesServer(Ana ProvisioningState = server.ProvisioningState, Id = server.Id, ServerFullName = server.ServerFullName, - Sku = server.Sku != null ? ServerSku.FromResourceSku(server.Sku) : new Dictionary(), + Sku = server.Sku != null ? ServerSku.FromResourceSku(server.Sku) : new ServerSku(), Tag = server.Tags != null ? new Dictionary(server.Tags) : new Dictionary(), BackupBlobContainerUri = server.BackupBlobContainerUri == null ? String.Empty : server.BackupBlobContainerUri, DefaultConnectionMode = server.QuerypoolConnectionMode.ToString(), - FirewallConfig = config + FirewallConfig = config, + GatewayInfo = server.GatewayDetails != null ? ServerGateway.FromResourceGateway(server.GatewayDetails) : null }; } - internal static List FromAnalysisServicesServerCollection(List list) + internal static List FromAnalysisServicesServerCollection(List list) { if (list == null) { return null; } - var listAzureAnalysisServicesServer = new List(); + var listAzureAnalysisServicesServer = new List(); list.ForEach(server => listAzureAnalysisServicesServer.Add(FromAnalysisServicesServer(server))); return listAzureAnalysisServicesServer; } } - - public class AzureAnalysisServicesServerDetail : AzureAnalysisServicesServer - { - public new System.Collections.Generic.IDictionary Sku { get; set; } - } } diff --git a/src/ResourceManager/AnalysisServices/Commands.AnalysisServices/Models/ServerGateway.cs b/src/ResourceManager/AnalysisServices/Commands.AnalysisServices/Models/ServerGateway.cs new file mode 100644 index 000000000000..adcaab91a433 --- /dev/null +++ b/src/ResourceManager/AnalysisServices/Commands.AnalysisServices/Models/ServerGateway.cs @@ -0,0 +1,28 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Microsoft.Azure.Management.Analysis.Models; + +namespace Microsoft.Azure.Commands.AnalysisServices.Models +{ + public class ServerGateway + { + public string GatewayResourceId { get; set; } + + public string GatewayObjectId { get; set; } + + public string DmtsClusterUri { get; set; } + + internal static ServerGateway FromResourceGateway(GatewayDetails resourceGateway) + { + return new ServerGateway() + { + GatewayResourceId = resourceGateway.GatewayResourceId, + GatewayObjectId = resourceGateway.GatewayObjectId != null ? resourceGateway.GatewayObjectId : null, + DmtsClusterUri = resourceGateway.DmtsClusterUri != null ? resourceGateway.DmtsClusterUri : null + }; + } + } +} diff --git a/src/ResourceManager/AnalysisServices/Commands.AnalysisServices/Models/ServerSku.cs b/src/ResourceManager/AnalysisServices/Commands.AnalysisServices/Models/ServerSku.cs index ee45c8f6c4ae..371a60b6e8d7 100644 --- a/src/ResourceManager/AnalysisServices/Commands.AnalysisServices/Models/ServerSku.cs +++ b/src/ResourceManager/AnalysisServices/Commands.AnalysisServices/Models/ServerSku.cs @@ -15,13 +15,14 @@ public class ServerSku public int Capacity { get; set; } - internal static Dictionary FromResourceSku(ResourceSku resourceSku) - { - Dictionary sku = new Dictionary(); - sku["Name"] = resourceSku.Name; - sku["Tier"] = resourceSku.Tier; - sku["Capacity"] = resourceSku.Capacity == null ? "1" : resourceSku.Capacity.Value.ToString(); - return sku; + internal static ServerSku FromResourceSku(ResourceSku resourceSku) + { + return new ServerSku() + { + Name = resourceSku.Name, + Tier = resourceSku.Tier, + Capacity = resourceSku.Capacity == null ? 1 : resourceSku.Capacity.Value + }; } } } From f578d454f12738e25657bcd79f2a072df7e10e1f Mon Sep 17 00:00:00 2001 From: Tai-Yi Wu Date: Tue, 24 Apr 2018 17:06:02 -0700 Subject: [PATCH 02/10] Fix indent and disassociate gateway --- .../NewAzureRmAnalysisServicesServer.cs | 32 +++++----- .../SetAzureRmAnalysisServicesServer.cs | 32 +++++----- .../Models/AnalysisServicesClient.cs | 60 +++++++++---------- .../Models/ServerGateway.cs | 16 ++--- 4 files changed, 70 insertions(+), 70 deletions(-) diff --git a/src/ResourceManager/AnalysisServices/Commands.AnalysisServices/Commands/NewAzureRmAnalysisServicesServer.cs b/src/ResourceManager/AnalysisServices/Commands.AnalysisServices/Commands/NewAzureRmAnalysisServicesServer.cs index de92852a3920..170ae596c7f1 100644 --- a/src/ResourceManager/AnalysisServices/Commands.AnalysisServices/Commands/NewAzureRmAnalysisServicesServer.cs +++ b/src/ResourceManager/AnalysisServices/Commands.AnalysisServices/Commands/NewAzureRmAnalysisServicesServer.cs @@ -82,19 +82,19 @@ public class NewAnalysisServicesServer : AnalysisServicesCmdletBase HelpMessage = "Firewall configuration")] public PsAzureAnalysisServicesFirewallConfig FirewallConfig { get; set; } - [Parameter(ValueFromPipelineByPropertyName = true, Mandatory = false, - HelpMessage = "Gateway resource name")] - public string GatewayName { get; set; } + [Parameter(ValueFromPipelineByPropertyName = true, Mandatory = false, + HelpMessage = "Gateway resource name")] + public string GatewayName { get; set; } - [Parameter(ValueFromPipelineByPropertyName = true, Mandatory = false, - HelpMessage = "Gateway resource group name")] - public string GatewayResourceGroupName { get; set; } + [Parameter(ValueFromPipelineByPropertyName = true, Mandatory = false, + HelpMessage = "Gateway resource group name")] + public string GatewayResourceGroupName { get; set; } - [Parameter(ValueFromPipelineByPropertyName = true, Mandatory = false, - HelpMessage = "Gateway subscription Id")] - public string GatewaySubscriptionId { get; set; } + [Parameter(ValueFromPipelineByPropertyName = true, Mandatory = false, + HelpMessage = "Gateway subscription Id")] + public string GatewaySubscriptionId { get; set; } - public override void ExecuteCmdlet() + public override void ExecuteCmdlet() { if (ShouldProcess(Name, Resources.CreateNewAnalysisServicesServer)) { @@ -156,14 +156,14 @@ public override void ExecuteCmdlet() ReadonlyReplicaCount = 0; } - if (string.IsNullOrEmpty(GatewayResourceGroupName)) - { - GatewayResourceGroupName = ResourceGroupName; - } + if (string.IsNullOrEmpty(GatewayResourceGroupName)) + { + GatewayResourceGroupName = ResourceGroupName; + } - string gatewayId = AnalysisServicesClient.GetGatewayResourceId(GatewayName, GatewayResourceGroupName, GatewaySubscriptionId); + string gatewayId = AnalysisServicesClient.GetGatewayResourceId(GatewayName, GatewayResourceGroupName, GatewaySubscriptionId); - var createdServer = AnalysisServicesClient.CreateOrUpdateServer(ResourceGroupName, Name, Location, Sku, Tag, Administrator, null, BackupBlobContainerUri, ReadonlyReplicaCount, DefaultConnectionMode, setting, gatewayId); + var createdServer = AnalysisServicesClient.CreateOrUpdateServer(ResourceGroupName, Name, Location, Sku, Tag, Administrator, null, BackupBlobContainerUri, ReadonlyReplicaCount, DefaultConnectionMode, setting, gatewayId); WriteObject(AzureAnalysisServicesServer.FromAnalysisServicesServer(createdServer)); } } diff --git a/src/ResourceManager/AnalysisServices/Commands.AnalysisServices/Commands/SetAzureRmAnalysisServicesServer.cs b/src/ResourceManager/AnalysisServices/Commands.AnalysisServices/Commands/SetAzureRmAnalysisServicesServer.cs index f502cb54c79a..86f3892a544e 100644 --- a/src/ResourceManager/AnalysisServices/Commands.AnalysisServices/Commands/SetAzureRmAnalysisServicesServer.cs +++ b/src/ResourceManager/AnalysisServices/Commands.AnalysisServices/Commands/SetAzureRmAnalysisServicesServer.cs @@ -163,22 +163,22 @@ public override void ExecuteCmdlet() ReadonlyReplicaCount = -1; } - if (string.IsNullOrEmpty(GatewayResourceGroupName)) - { - GatewayResourceGroupName = ResourceGroupName; - } - - string gatewayResourceId = null; - if (DisassociateGateway.IsPresent) - { - gatewayResourceId = "-"; - } - else - { - gatewayResourceId = AnalysisServicesClient.GetGatewayResourceId(GatewayName, GatewayResourceGroupName, GatewaySubscriptionId); - } - - AnalysisServicesServer updatedServer = AnalysisServicesClient.CreateOrUpdateServer(ResourceGroupName, Name, location, Sku, Tag, Administrator, currentServer, BackupBlobContainerUri, ReadonlyReplicaCount, DefaultConnectionMode, setting, gatewayResourceId); + if (string.IsNullOrEmpty(GatewayResourceGroupName)) + { + GatewayResourceGroupName = ResourceGroupName; + } + + string gatewayResourceId = null; + if (DisassociateGateway.IsPresent) + { + gatewayResourceId = "-"; + } + else + { + gatewayResourceId = AnalysisServicesClient.GetGatewayResourceId(GatewayName, GatewayResourceGroupName, GatewaySubscriptionId); + } + + AnalysisServicesServer updatedServer = AnalysisServicesClient.CreateOrUpdateServer(ResourceGroupName, Name, location, Sku, Tag, Administrator, currentServer, BackupBlobContainerUri, ReadonlyReplicaCount, DefaultConnectionMode, setting, gatewayResourceId); if(PassThru.IsPresent) { diff --git a/src/ResourceManager/AnalysisServices/Commands.AnalysisServices/Models/AnalysisServicesClient.cs b/src/ResourceManager/AnalysisServices/Commands.AnalysisServices/Models/AnalysisServicesClient.cs index 8e203a50a028..b4fd12089fd4 100644 --- a/src/ResourceManager/AnalysisServices/Commands.AnalysisServices/Models/AnalysisServicesClient.cs +++ b/src/ResourceManager/AnalysisServices/Commands.AnalysisServices/Models/AnalysisServicesClient.cs @@ -67,7 +67,7 @@ public AnalysisServicesServer CreateOrUpdateServer( int ReadonlyReplicaCount = 0, string DefaultConnectionMode = null, IPv4FirewallSettings setting = null, - string gatewayId = null) + string gatewayId = null) { if (string.IsNullOrEmpty(resourceGroupName)) { @@ -89,17 +89,17 @@ public AnalysisServicesServer CreateOrUpdateServer( } } - GatewayDetails gatewayDetails = null; - if (gatewayId == "-") - { - gatewayDetails = new GatewayDetails("", "", ""); - } - else - { - gatewayDetails = new GatewayDetails(gatewayId); - } - - AnalysisServicesServer newOrUpdatedServer = null; + GatewayDetails gatewayDetails = null; + if (gatewayId == "-") + { + gatewayDetails = new GatewayDetails(); + } + else + { + gatewayDetails = new GatewayDetails(gatewayId); + } + + AnalysisServicesServer newOrUpdatedServer = null; if (existingServer != null) { var updateParameters = new AnalysisServicesServerUpdateParameters() @@ -133,7 +133,7 @@ public AnalysisServicesServer CreateOrUpdateServer( updateParameters.IpV4FirewallSettings = setting; } - if (gatewayId != null && gatewayId != "-") + if (gatewayId != null) { updateParameters.GatewayDetails = gatewayDetails; } @@ -160,8 +160,8 @@ public AnalysisServicesServer CreateOrUpdateServer( Tags = tags, QuerypoolConnectionMode = connectionMode, IpV4FirewallSettings = setting, - GatewayDetails = gatewayDetails - }); + GatewayDetails = gatewayDetails + }); } return newOrUpdatedServer; @@ -281,22 +281,22 @@ public void ResumeServer(string resourceGroupName, string serverName) _client.Servers.Resume(resourceGroupName, serverName); } - public string GetGatewayResourceId(string gatewayName, string resourceGroupName, string subscriptionId) - { - string resourcdId = null; - if (!string.IsNullOrEmpty(gatewayName)) - { - if (string.IsNullOrEmpty(subscriptionId)) - { - subscriptionId = _client.SubscriptionId; - } + public string GetGatewayResourceId(string gatewayName, string resourceGroupName, string subscriptionId) + { + string resourcdId = null; + if (!string.IsNullOrEmpty(gatewayName)) + { + if (string.IsNullOrEmpty(subscriptionId)) + { + subscriptionId = _client.SubscriptionId; + } - resourcdId = string.Format(gatewayResourceIdFormat, subscriptionId, resourceGroupName, gatewayName); - } + resourcdId = string.Format(gatewayResourceIdFormat, subscriptionId, resourceGroupName, gatewayName); + } - return resourcdId; - } + return resourcdId; + } - #endregion - } + #endregion + } } \ No newline at end of file diff --git a/src/ResourceManager/AnalysisServices/Commands.AnalysisServices/Models/ServerGateway.cs b/src/ResourceManager/AnalysisServices/Commands.AnalysisServices/Models/ServerGateway.cs index adcaab91a433..3a20537488a9 100644 --- a/src/ResourceManager/AnalysisServices/Commands.AnalysisServices/Models/ServerGateway.cs +++ b/src/ResourceManager/AnalysisServices/Commands.AnalysisServices/Models/ServerGateway.cs @@ -15,14 +15,14 @@ public class ServerGateway public string DmtsClusterUri { get; set; } - internal static ServerGateway FromResourceGateway(GatewayDetails resourceGateway) - { - return new ServerGateway() - { - GatewayResourceId = resourceGateway.GatewayResourceId, - GatewayObjectId = resourceGateway.GatewayObjectId != null ? resourceGateway.GatewayObjectId : null, - DmtsClusterUri = resourceGateway.DmtsClusterUri != null ? resourceGateway.DmtsClusterUri : null - }; + internal static ServerGateway FromResourceGateway(GatewayDetails resourceGateway) + { + return new ServerGateway() + { + GatewayResourceId = resourceGateway.GatewayResourceId, + GatewayObjectId = resourceGateway.GatewayObjectId != null ? resourceGateway.GatewayObjectId : null, + DmtsClusterUri = resourceGateway.DmtsClusterUri != null ? resourceGateway.DmtsClusterUri : null + }; } } } From bdda3d58277e21b8d9b169696e3a4ba5f72f8753 Mon Sep 17 00:00:00 2001 From: Tai-Yi Wu Date: Tue, 24 Apr 2018 17:08:59 -0700 Subject: [PATCH 03/10] Update change log --- src/ResourceManager/AnalysisServices/ChangeLog.md | 1 + 1 file changed, 1 insertion(+) diff --git a/src/ResourceManager/AnalysisServices/ChangeLog.md b/src/ResourceManager/AnalysisServices/ChangeLog.md index 49c195b4befb..232e8ee78d79 100644 --- a/src/ResourceManager/AnalysisServices/ChangeLog.md +++ b/src/ResourceManager/AnalysisServices/ChangeLog.md @@ -19,6 +19,7 @@ --> ## Current Release * Set minimum dependency of module to PowerShell 5.0 +* Enable Gateway assocaite/disassociate operations on AS. ## Version 0.6.6 * Updated to the latest version of the Azure ClientRuntime From 86b199790db816982760f982d7fc7dcf4df4edee Mon Sep 17 00:00:00 2001 From: Tai-Yi Wu Date: Tue, 24 Apr 2018 17:21:49 -0700 Subject: [PATCH 04/10] Fix indent in test --- .../ScenarioTests/AsTests.cs | 12 +++---- .../ScenarioTests/AsTests.ps1 | 34 +++++++++---------- .../Models/ServerSku.cs | 16 ++++----- 3 files changed, 31 insertions(+), 31 deletions(-) diff --git a/src/ResourceManager/AnalysisServices/Commands.AnalysisServices.Test/ScenarioTests/AsTests.cs b/src/ResourceManager/AnalysisServices/Commands.AnalysisServices.Test/ScenarioTests/AsTests.cs index b367ad93b8b2..d0d45514c8a8 100644 --- a/src/ResourceManager/AnalysisServices/Commands.AnalysisServices.Test/ScenarioTests/AsTests.cs +++ b/src/ResourceManager/AnalysisServices/Commands.AnalysisServices.Test/ScenarioTests/AsTests.cs @@ -94,12 +94,12 @@ public void TestAnalysisServicesServerLoginWithSPN() NewInstance.RunPsTest("Test-AnalysisServicesServerLoginWithSPN"); } - [Fact] - [Trait(Category.RunType, Category.LiveOnly)] - public void TestAnalysisServicesServerGateway() - { - NewInstance.RunPsTest("Test-AnalysisServicesServerGateway"); - } + [Fact] + [Trait(Category.RunType, Category.LiveOnly)] + public void TestAnalysisServicesServerGateway() + { + NewInstance.RunPsTest("Test-AnalysisServicesServerGateway"); + } } } diff --git a/src/ResourceManager/AnalysisServices/Commands.AnalysisServices.Test/ScenarioTests/AsTests.ps1 b/src/ResourceManager/AnalysisServices/Commands.AnalysisServices.Test/ScenarioTests/AsTests.ps1 index aa7b6dee625d..28a31ca0dec0 100644 --- a/src/ResourceManager/AnalysisServices/Commands.AnalysisServices.Test/ScenarioTests/AsTests.ps1 +++ b/src/ResourceManager/AnalysisServices/Commands.AnalysisServices.Test/ScenarioTests/AsTests.ps1 @@ -619,23 +619,23 @@ Tests Analysis Services server lifecycle Failure scenarios (Create, Update, Get #> function Test-AnalysisServicesServerGateway { - try - { - - # Updating server - $tagsToUpdate = @{"TestTag" = "TestUpdate"} - #$serverUpdated = Set-AzureRmAnalysisServicesServer -ResourceGroupName $resourceGroupName -Name $serverName -Tag $tagsToUpdate -GatewayName 'azsdktest' -GatewayResourceGroupName 'TestRG' -GatewaySubscriptionId 'ba59a556-5034-4bbb-80b4-4c37cf1083e9' -PassThru + try + { + + # Updating server + $tagsToUpdate = @{"TestTag" = "TestUpdate"} + #$serverUpdated = Set-AzureRmAnalysisServicesServer -ResourceGroupName $resourceGroupName -Name $serverName -Tag $tagsToUpdate -GatewayName 'azsdktest' -GatewayResourceGroupName 'TestRG' -GatewaySubscriptionId 'ba59a556-5034-4bbb-80b4-4c37cf1083e9' -PassThru $serverUpdated = Set-AzureRmAnalysisServicesServer -ResourceGroupName 'TestRG' -Name 'azsdktest0309' -Tag $tagsToUpdate -DisassociateGateway -PassThru - Assert-NotNull $serverUpdated.Tag "Tag do not exists" - Assert-NotNull $serverUpdated.Tag["TestTag"] "The updated tag 'TestTag' does not exist" - Assert-AreEqual $serverUpdated.AsAdministrators.Count 2 - Assert-AreEqual 1 $serverUpdated.Sku.Capacity + Assert-NotNull $serverUpdated.Tag "Tag do not exists" + Assert-NotNull $serverUpdated.Tag["TestTag"] "The updated tag 'TestTag' does not exist" + Assert-AreEqual $serverUpdated.AsAdministrators.Count 2 + Assert-AreEqual 1 $serverUpdated.Sku.Capacity - } - finally - { - # cleanup the resource group that was used in case it still exists. This is a best effort task, we ignore failures here. - Invoke-HandledCmdlet -Command {Remove-AzureRmAnalysisServicesServer -ResourceGroupName $resourceGroupName -Name $serverName -ErrorAction SilentlyContinue} -IgnoreFailures - Invoke-HandledCmdlet -Command {Remove-AzureRmResourceGroup -Name $resourceGroupName -ErrorAction SilentlyContinue} -IgnoreFailures - } + } + finally + { + # cleanup the resource group that was used in case it still exists. This is a best effort task, we ignore failures here. + Invoke-HandledCmdlet -Command {Remove-AzureRmAnalysisServicesServer -ResourceGroupName $resourceGroupName -Name $serverName -ErrorAction SilentlyContinue} -IgnoreFailures + Invoke-HandledCmdlet -Command {Remove-AzureRmResourceGroup -Name $resourceGroupName -ErrorAction SilentlyContinue} -IgnoreFailures + } } \ No newline at end of file diff --git a/src/ResourceManager/AnalysisServices/Commands.AnalysisServices/Models/ServerSku.cs b/src/ResourceManager/AnalysisServices/Commands.AnalysisServices/Models/ServerSku.cs index 371a60b6e8d7..3e722fab6747 100644 --- a/src/ResourceManager/AnalysisServices/Commands.AnalysisServices/Models/ServerSku.cs +++ b/src/ResourceManager/AnalysisServices/Commands.AnalysisServices/Models/ServerSku.cs @@ -15,14 +15,14 @@ public class ServerSku public int Capacity { get; set; } - internal static ServerSku FromResourceSku(ResourceSku resourceSku) - { - return new ServerSku() - { - Name = resourceSku.Name, - Tier = resourceSku.Tier, - Capacity = resourceSku.Capacity == null ? 1 : resourceSku.Capacity.Value - }; + internal static ServerSku FromResourceSku(ResourceSku resourceSku) + { + return new ServerSku() + { + Name = resourceSku.Name, + Tier = resourceSku.Tier, + Capacity = resourceSku.Capacity == null ? 1 : resourceSku.Capacity.Value + }; } } } From 89febba91e6feba5f13a31e8cc9f3735af3eab60 Mon Sep 17 00:00:00 2001 From: Tai-Yi Wu Date: Tue, 24 Apr 2018 17:23:40 -0700 Subject: [PATCH 05/10] Fix indent in Set-operation --- .../SetAzureRmAnalysisServicesServer.cs | 32 +++++++++---------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/src/ResourceManager/AnalysisServices/Commands.AnalysisServices/Commands/SetAzureRmAnalysisServicesServer.cs b/src/ResourceManager/AnalysisServices/Commands.AnalysisServices/Commands/SetAzureRmAnalysisServicesServer.cs index 86f3892a544e..fb7784df46f7 100644 --- a/src/ResourceManager/AnalysisServices/Commands.AnalysisServices/Commands/SetAzureRmAnalysisServicesServer.cs +++ b/src/ResourceManager/AnalysisServices/Commands.AnalysisServices/Commands/SetAzureRmAnalysisServicesServer.cs @@ -88,23 +88,23 @@ public int ReadonlyReplicaCount HelpMessage = "Firewall configuration")] public PsAzureAnalysisServicesFirewallConfig FirewallConfig { get; set; } - [Parameter(ValueFromPipelineByPropertyName = true, Mandatory = false, - HelpMessage = "Gateway resource name")] - public string GatewayName { get; set; } + [Parameter(ValueFromPipelineByPropertyName = true, Mandatory = false, + HelpMessage = "Gateway resource name")] + public string GatewayName { get; set; } - [Parameter(ValueFromPipelineByPropertyName = true, Mandatory = false, - HelpMessage = "Gateway resource group name")] - public string GatewayResourceGroupName { get; set; } + [Parameter(ValueFromPipelineByPropertyName = true, Mandatory = false, + HelpMessage = "Gateway resource group name")] + public string GatewayResourceGroupName { get; set; } - [Parameter(ValueFromPipelineByPropertyName = true, Mandatory = false, - HelpMessage = "Gateway subscription Id")] - public string GatewaySubscriptionId { get; set; } + [Parameter(ValueFromPipelineByPropertyName = true, Mandatory = false, + HelpMessage = "Gateway subscription Id")] + public string GatewaySubscriptionId { get; set; } - [Parameter(ValueFromPipelineByPropertyName = true, Mandatory = false, - HelpMessage = "Disassociate current gateway")] - public SwitchParameter DisassociateGateway { get; set; } + [Parameter(ValueFromPipelineByPropertyName = true, Mandatory = false, + HelpMessage = "Disassociate current gateway")] + public SwitchParameter DisassociateGateway { get; set; } - public override void ExecuteCmdlet() + public override void ExecuteCmdlet() { if (string.IsNullOrEmpty(Name)) { @@ -165,17 +165,17 @@ public override void ExecuteCmdlet() if (string.IsNullOrEmpty(GatewayResourceGroupName)) { - GatewayResourceGroupName = ResourceGroupName; + GatewayResourceGroupName = ResourceGroupName; } string gatewayResourceId = null; if (DisassociateGateway.IsPresent) { - gatewayResourceId = "-"; + gatewayResourceId = "-"; } else { - gatewayResourceId = AnalysisServicesClient.GetGatewayResourceId(GatewayName, GatewayResourceGroupName, GatewaySubscriptionId); + gatewayResourceId = AnalysisServicesClient.GetGatewayResourceId(GatewayName, GatewayResourceGroupName, GatewaySubscriptionId); } AnalysisServicesServer updatedServer = AnalysisServicesClient.CreateOrUpdateServer(ResourceGroupName, Name, location, Sku, Tag, Administrator, currentServer, BackupBlobContainerUri, ReadonlyReplicaCount, DefaultConnectionMode, setting, gatewayResourceId); From ba8ef9da5bfbc5b318654288daac8ec520e9ba9c Mon Sep 17 00:00:00 2001 From: Tai-Yi Wu Date: Wed, 25 Apr 2018 10:32:59 -0700 Subject: [PATCH 06/10] Update gateway association using resource id --- .../ScenarioTests/AsTests.ps1 | 21 +++++++----- .../NewAzureRmAnalysisServicesServer.cs | 21 ++---------- .../SetAzureRmAnalysisServicesServer.cs | 26 +++------------ .../Models/AnalysisServicesClient.cs | 32 ++++++------------- 4 files changed, 30 insertions(+), 70 deletions(-) diff --git a/src/ResourceManager/AnalysisServices/Commands.AnalysisServices.Test/ScenarioTests/AsTests.ps1 b/src/ResourceManager/AnalysisServices/Commands.AnalysisServices.Test/ScenarioTests/AsTests.ps1 index 28a31ca0dec0..9e930b3b8b32 100644 --- a/src/ResourceManager/AnalysisServices/Commands.AnalysisServices.Test/ScenarioTests/AsTests.ps1 +++ b/src/ResourceManager/AnalysisServices/Commands.AnalysisServices.Test/ScenarioTests/AsTests.ps1 @@ -621,16 +621,21 @@ function Test-AnalysisServicesServerGateway { try { + # Creating server + $location = Get-Location + $resourceGroupName = Get-ResourceGroupName + $serverName = Get-AnalysisServicesServerName + $gatewayName = $env:GATEWAY_NAME + $gateway = Get-AzureRmResource -ResourceName $gatewayName -ResourceGroupName $resourceGroupName + $serverCreated = New-AzureRmAnalysisServicesServer -ResourceGroupName $resourceGroupName -Name $serverName -Location $location -Sku S0 -GatewayResourceId $gateway.ResourceId -PassThru - # Updating server - $tagsToUpdate = @{"TestTag" = "TestUpdate"} - #$serverUpdated = Set-AzureRmAnalysisServicesServer -ResourceGroupName $resourceGroupName -Name $serverName -Tag $tagsToUpdate -GatewayName 'azsdktest' -GatewayResourceGroupName 'TestRG' -GatewaySubscriptionId 'ba59a556-5034-4bbb-80b4-4c37cf1083e9' -PassThru - $serverUpdated = Set-AzureRmAnalysisServicesServer -ResourceGroupName 'TestRG' -Name 'azsdktest0309' -Tag $tagsToUpdate -DisassociateGateway -PassThru - Assert-NotNull $serverUpdated.Tag "Tag do not exists" - Assert-NotNull $serverUpdated.Tag["TestTag"] "The updated tag 'TestTag' does not exist" - Assert-AreEqual $serverUpdated.AsAdministrators.Count 2 - Assert-AreEqual 1 $serverUpdated.Sku.Capacity + Assert-True {$serverCreated.ProvisioningState -like "Succeeded"} + Assert-True {$serverCreated.State -like "Succeeded"} + Assert-AreEqual $gateway.ResourceId $serverCreated.GatewayDetails.GatewayResourceId + # Dissociate gateway from server + $serverUpdated = Set-AzureRmAnalysisServicesServer -ResourceGroupName $resourceGroupName -Name $serverName -DisassociateGateway -PassThru + Assert-True {[string]::IsNullOrEmpty($serverUpdated.GatewayDetails.GatewayResourceId)} } finally { diff --git a/src/ResourceManager/AnalysisServices/Commands.AnalysisServices/Commands/NewAzureRmAnalysisServicesServer.cs b/src/ResourceManager/AnalysisServices/Commands.AnalysisServices/Commands/NewAzureRmAnalysisServicesServer.cs index 170ae596c7f1..0e1a7b847561 100644 --- a/src/ResourceManager/AnalysisServices/Commands.AnalysisServices/Commands/NewAzureRmAnalysisServicesServer.cs +++ b/src/ResourceManager/AnalysisServices/Commands.AnalysisServices/Commands/NewAzureRmAnalysisServicesServer.cs @@ -83,16 +83,8 @@ public class NewAnalysisServicesServer : AnalysisServicesCmdletBase public PsAzureAnalysisServicesFirewallConfig FirewallConfig { get; set; } [Parameter(ValueFromPipelineByPropertyName = true, Mandatory = false, - HelpMessage = "Gateway resource name")] - public string GatewayName { get; set; } - - [Parameter(ValueFromPipelineByPropertyName = true, Mandatory = false, - HelpMessage = "Gateway resource group name")] - public string GatewayResourceGroupName { get; set; } - - [Parameter(ValueFromPipelineByPropertyName = true, Mandatory = false, - HelpMessage = "Gateway subscription Id")] - public string GatewaySubscriptionId { get; set; } + HelpMessage = "Gateway resource ID")] + public string GatewayResourceId { get; set; } public override void ExecuteCmdlet() { @@ -156,14 +148,7 @@ public override void ExecuteCmdlet() ReadonlyReplicaCount = 0; } - if (string.IsNullOrEmpty(GatewayResourceGroupName)) - { - GatewayResourceGroupName = ResourceGroupName; - } - - string gatewayId = AnalysisServicesClient.GetGatewayResourceId(GatewayName, GatewayResourceGroupName, GatewaySubscriptionId); - - var createdServer = AnalysisServicesClient.CreateOrUpdateServer(ResourceGroupName, Name, Location, Sku, Tag, Administrator, null, BackupBlobContainerUri, ReadonlyReplicaCount, DefaultConnectionMode, setting, gatewayId); + var createdServer = AnalysisServicesClient.CreateOrUpdateServer(ResourceGroupName, Name, Location, Sku, Tag, Administrator, null, BackupBlobContainerUri, ReadonlyReplicaCount, DefaultConnectionMode, setting, GatewayResourceId); WriteObject(AzureAnalysisServicesServer.FromAnalysisServicesServer(createdServer)); } } diff --git a/src/ResourceManager/AnalysisServices/Commands.AnalysisServices/Commands/SetAzureRmAnalysisServicesServer.cs b/src/ResourceManager/AnalysisServices/Commands.AnalysisServices/Commands/SetAzureRmAnalysisServicesServer.cs index fb7784df46f7..781a4f844b47 100644 --- a/src/ResourceManager/AnalysisServices/Commands.AnalysisServices/Commands/SetAzureRmAnalysisServicesServer.cs +++ b/src/ResourceManager/AnalysisServices/Commands.AnalysisServices/Commands/SetAzureRmAnalysisServicesServer.cs @@ -89,16 +89,8 @@ public int ReadonlyReplicaCount public PsAzureAnalysisServicesFirewallConfig FirewallConfig { get; set; } [Parameter(ValueFromPipelineByPropertyName = true, Mandatory = false, - HelpMessage = "Gateway resource name")] - public string GatewayName { get; set; } - - [Parameter(ValueFromPipelineByPropertyName = true, Mandatory = false, - HelpMessage = "Gateway resource group name")] - public string GatewayResourceGroupName { get; set; } - - [Parameter(ValueFromPipelineByPropertyName = true, Mandatory = false, - HelpMessage = "Gateway subscription Id")] - public string GatewaySubscriptionId { get; set; } + HelpMessage = "Gateway resource ID")] + public string GatewayResourceId { get; set; } [Parameter(ValueFromPipelineByPropertyName = true, Mandatory = false, HelpMessage = "Disassociate current gateway")] @@ -163,22 +155,12 @@ public override void ExecuteCmdlet() ReadonlyReplicaCount = -1; } - if (string.IsNullOrEmpty(GatewayResourceGroupName)) - { - GatewayResourceGroupName = ResourceGroupName; - } - - string gatewayResourceId = null; if (DisassociateGateway.IsPresent) { - gatewayResourceId = "-"; - } - else - { - gatewayResourceId = AnalysisServicesClient.GetGatewayResourceId(GatewayName, GatewayResourceGroupName, GatewaySubscriptionId); + GatewayResourceId = "-"; } - AnalysisServicesServer updatedServer = AnalysisServicesClient.CreateOrUpdateServer(ResourceGroupName, Name, location, Sku, Tag, Administrator, currentServer, BackupBlobContainerUri, ReadonlyReplicaCount, DefaultConnectionMode, setting, gatewayResourceId); + AnalysisServicesServer updatedServer = AnalysisServicesClient.CreateOrUpdateServer(ResourceGroupName, Name, location, Sku, Tag, Administrator, currentServer, BackupBlobContainerUri, ReadonlyReplicaCount, DefaultConnectionMode, setting, GatewayResourceId); if(PassThru.IsPresent) { diff --git a/src/ResourceManager/AnalysisServices/Commands.AnalysisServices/Models/AnalysisServicesClient.cs b/src/ResourceManager/AnalysisServices/Commands.AnalysisServices/Models/AnalysisServicesClient.cs index b4fd12089fd4..85d57191630c 100644 --- a/src/ResourceManager/AnalysisServices/Commands.AnalysisServices/Models/AnalysisServicesClient.cs +++ b/src/ResourceManager/AnalysisServices/Commands.AnalysisServices/Models/AnalysisServicesClient.cs @@ -33,7 +33,6 @@ public class AnalysisServicesClient private readonly AnalysisServicesManagementClient _client; private readonly Guid _subscriptionId; private readonly string _currentUser; - public const string gatewayResourceIdFormat = "/subscriptions/{0}/resourceGroups/{1}/providers/Microsoft.Web/connectionGateways/{2}"; public AnalysisServicesClient(IAzureContext context) { @@ -67,7 +66,7 @@ public AnalysisServicesServer CreateOrUpdateServer( int ReadonlyReplicaCount = 0, string DefaultConnectionMode = null, IPv4FirewallSettings setting = null, - string gatewayId = null) + string gatewayResourceId = null) { if (string.IsNullOrEmpty(resourceGroupName)) { @@ -90,13 +89,13 @@ public AnalysisServicesServer CreateOrUpdateServer( } GatewayDetails gatewayDetails = null; - if (gatewayId == "-") + if (gatewayResourceId == "-") { gatewayDetails = new GatewayDetails(); } - else + else if (gatewayResourceId != null) { - gatewayDetails = new GatewayDetails(gatewayId); + gatewayDetails = new GatewayDetails(gatewayResourceId); } AnalysisServicesServer newOrUpdatedServer = null; @@ -133,7 +132,7 @@ public AnalysisServicesServer CreateOrUpdateServer( updateParameters.IpV4FirewallSettings = setting; } - if (gatewayId != null) + if (gatewayDetails != null) { updateParameters.GatewayDetails = gatewayDetails; } @@ -148,6 +147,11 @@ public AnalysisServicesServer CreateOrUpdateServer( connectionMode = (ConnectionMode)Enum.Parse(typeof(ConnectionMode), DefaultConnectionMode, true); } + if (adminList.Count == 0) + { + adminList.Add(_currentUser); + } + newOrUpdatedServer = _client.Servers.Create( resourceGroupName, serverName, @@ -281,22 +285,6 @@ public void ResumeServer(string resourceGroupName, string serverName) _client.Servers.Resume(resourceGroupName, serverName); } - public string GetGatewayResourceId(string gatewayName, string resourceGroupName, string subscriptionId) - { - string resourcdId = null; - if (!string.IsNullOrEmpty(gatewayName)) - { - if (string.IsNullOrEmpty(subscriptionId)) - { - subscriptionId = _client.SubscriptionId; - } - - resourcdId = string.Format(gatewayResourceIdFormat, subscriptionId, resourceGroupName, gatewayName); - } - - return resourcdId; - } - #endregion } } \ No newline at end of file From db15652cd1d8dfc9b4147368d2d797c93b3c8859 Mon Sep 17 00:00:00 2001 From: Tai-Yi Wu Date: Thu, 26 Apr 2018 10:28:00 -0700 Subject: [PATCH 07/10] Update help doc --- .../ScenarioTests/AsTests.ps1 | 6 ++-- .../help/New-AzureRmAnalysisServicesServer.md | 18 +++++++++- .../help/Set-AzureRmAnalysisServicesServer.md | 34 ++++++++++++++++++- 3 files changed, 53 insertions(+), 5 deletions(-) diff --git a/src/ResourceManager/AnalysisServices/Commands.AnalysisServices.Test/ScenarioTests/AsTests.ps1 b/src/ResourceManager/AnalysisServices/Commands.AnalysisServices.Test/ScenarioTests/AsTests.ps1 index 9e930b3b8b32..dd1d0a702acb 100644 --- a/src/ResourceManager/AnalysisServices/Commands.AnalysisServices.Test/ScenarioTests/AsTests.ps1 +++ b/src/ResourceManager/AnalysisServices/Commands.AnalysisServices.Test/ScenarioTests/AsTests.ps1 @@ -622,9 +622,9 @@ function Test-AnalysisServicesServerGateway try { # Creating server - $location = Get-Location - $resourceGroupName = Get-ResourceGroupName - $serverName = Get-AnalysisServicesServerName + $location = Get-Location + $resourceGroupName = Get-ResourceGroupName + $serverName = Get-AnalysisServicesServerName $gatewayName = $env:GATEWAY_NAME $gateway = Get-AzureRmResource -ResourceName $gatewayName -ResourceGroupName $resourceGroupName $serverCreated = New-AzureRmAnalysisServicesServer -ResourceGroupName $resourceGroupName -Name $serverName -Location $location -Sku S0 -GatewayResourceId $gateway.ResourceId -PassThru diff --git a/src/ResourceManager/AnalysisServices/Commands.AnalysisServices/help/New-AzureRmAnalysisServicesServer.md b/src/ResourceManager/AnalysisServices/Commands.AnalysisServices/help/New-AzureRmAnalysisServicesServer.md index a93b2d68d16c..8f8a64779555 100644 --- a/src/ResourceManager/AnalysisServices/Commands.AnalysisServices/help/New-AzureRmAnalysisServicesServer.md +++ b/src/ResourceManager/AnalysisServices/Commands.AnalysisServices/help/New-AzureRmAnalysisServicesServer.md @@ -15,7 +15,8 @@ Creates a new Analysis Services server ``` New-AzureRmAnalysisServicesServer [-ResourceGroupName] [-Name] [-Location] [-Sku] [[-Tag] ] [[-Administrator] ] [[-BackupBlobContainerUri] ] - [-DefaultProfile ] [-WhatIf] [-Confirm] [] + [[-FirewallConfig] ] + [[-GatewayResourceId] ] [-DefaultProfile ] [-WhatIf] [-Confirm] [] ``` ## DESCRIPTION @@ -199,6 +200,21 @@ Accept pipeline input: True (ByPropertyName) Accept wildcard characters: False ``` +### -GatewayResourceId +Gateway resource Id for assocaite to an Analysis server + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: True (ByPropertyName) +Accept wildcard characters: False +``` + ### -Confirm Prompts user to confirm whether to perform the operation diff --git a/src/ResourceManager/AnalysisServices/Commands.AnalysisServices/help/Set-AzureRmAnalysisServicesServer.md b/src/ResourceManager/AnalysisServices/Commands.AnalysisServices/help/Set-AzureRmAnalysisServicesServer.md index 640fed155b57..42d2def9d441 100644 --- a/src/ResourceManager/AnalysisServices/Commands.AnalysisServices/help/Set-AzureRmAnalysisServicesServer.md +++ b/src/ResourceManager/AnalysisServices/Commands.AnalysisServices/help/Set-AzureRmAnalysisServicesServer.md @@ -15,7 +15,9 @@ Modifies an instance of Analysis Services server ### Default (Default) ``` Set-AzureRmAnalysisServicesServer [-Name] [[-ResourceGroupName] ] [[-Sku] ] - [[-Tag] ] [[-Administrator] ] [[-BackupBlobContainerUri] ] [-PassThru] + [[-Tag] ] [[-Administrator] ] [[-BackupBlobContainerUri] ] + [[-FirewallConfig] ] + [[-GatewayResourceId] ] [-DisassociateGateway] [-PassThru] [-DefaultProfile ] [-WhatIf] [-Confirm] [] ``` @@ -224,6 +226,36 @@ Accept pipeline input: True (ByPropertyName) Accept wildcard characters: False ``` +### -GatewayResourceId +Gateway resource Id for assocaite to an Analysis server + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: True (ByPropertyName) +Accept wildcard characters: False +``` + +### -DisassociateGateway +Disassociate Gateway resource from an Analysis server + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: True +Accept wildcard characters: False +``` + ### -Confirm Prompts user to confirm whether to perform the operation From f0988658bbc94e58d71543610121516a88fa5e16 Mon Sep 17 00:00:00 2001 From: Tai-Yi Wu Date: Fri, 4 May 2018 13:24:10 -0700 Subject: [PATCH 08/10] Update paramter sets for gateway operations and help doc --- .../SetAzureRmAnalysisServicesServer.cs | 3 + .../help/AzureRM.AnalysisServices.md | 14 +- .../help/Get-AzureRmAnalysisServicesServer.md | 2 +- ...w-AzureRmAnalysisServicesFirewallConfig.md | 34 ++++- ...New-AzureRmAnalysisServicesFirewallRule.md | 43 ++++-- .../help/New-AzureRmAnalysisServicesServer.md | 99 +++++++------- .../Remove-AzureRmAnalysisServicesServer.md | 2 +- .../Resume-AzureRmAnalysisServicesServer.md | 2 +- .../help/Set-AzureRmAnalysisServicesServer.md | 124 ++++++++++-------- .../Suspend-AzureRmAnalysisServicesServer.md | 2 +- .../Test-AzureRmAnalysisServicesServer.md | 2 +- 11 files changed, 190 insertions(+), 137 deletions(-) diff --git a/src/ResourceManager/AnalysisServices/Commands.AnalysisServices/Commands/SetAzureRmAnalysisServicesServer.cs b/src/ResourceManager/AnalysisServices/Commands.AnalysisServices/Commands/SetAzureRmAnalysisServicesServer.cs index 781a4f844b47..598394138e99 100644 --- a/src/ResourceManager/AnalysisServices/Commands.AnalysisServices/Commands/SetAzureRmAnalysisServicesServer.cs +++ b/src/ResourceManager/AnalysisServices/Commands.AnalysisServices/Commands/SetAzureRmAnalysisServicesServer.cs @@ -31,6 +31,7 @@ public class SetAzureAnalysisServicesServer : AnalysisServicesCmdletBase { private const string ParamSetDefault = "Default"; private const string ParamSetDisableBackup = "DisableBackup"; + private const string ParamSetDisassociatGateway = "DisassociateGateway"; [Parameter(ValueFromPipelineByPropertyName = true, Position = 0, Mandatory = true, HelpMessage = "Name of the server.")] @@ -89,10 +90,12 @@ public int ReadonlyReplicaCount public PsAzureAnalysisServicesFirewallConfig FirewallConfig { get; set; } [Parameter(ValueFromPipelineByPropertyName = true, Mandatory = false, + ParameterSetName = ParamSetDefault, HelpMessage = "Gateway resource ID")] public string GatewayResourceId { get; set; } [Parameter(ValueFromPipelineByPropertyName = true, Mandatory = false, + ParameterSetName = ParamSetDisassociatGateway, HelpMessage = "Disassociate current gateway")] public SwitchParameter DisassociateGateway { get; set; } diff --git a/src/ResourceManager/AnalysisServices/Commands.AnalysisServices/help/AzureRM.AnalysisServices.md b/src/ResourceManager/AnalysisServices/Commands.AnalysisServices/help/AzureRM.AnalysisServices.md index a934f5ad4c44..f87919bd4b18 100644 --- a/src/ResourceManager/AnalysisServices/Commands.AnalysisServices/help/AzureRM.AnalysisServices.md +++ b/src/ResourceManager/AnalysisServices/Commands.AnalysisServices/help/AzureRM.AnalysisServices.md @@ -1,4 +1,4 @@ ---- +--- Module Name: AzureRM.AnalysisServices Module Guid: acace26c-1775-4100-85c0-20c4d71eaa21 Download Help Link: None_Azure @@ -14,6 +14,12 @@ This topic displays help topics for the Azure AnalysisServices cmdlets. ### [Get-AzureRmAnalysisServicesServer](Get-AzureRmAnalysisServicesServer.md) Gets the details of an Analysis Services server. +### [New-AzureRmAnalysisServicesFirewallConfig](New-AzureRmAnalysisServicesFirewallConfig.md) +Creates a new Analysis Services firewall config + +### [New-AzureRmAnalysisServicesFirewallRule](New-AzureRmAnalysisServicesFirewallRule.md) +Creates a new Analysis Services firewall rule + ### [New-AzureRmAnalysisServicesServer](New-AzureRmAnalysisServicesServer.md) Creates a new Analysis Services server @@ -32,9 +38,3 @@ Suspends an instance of Analysis Services server ### [Test-AzureRmAnalysisServicesServer](Test-AzureRmAnalysisServicesServer.md) Tests the existence of an instance of Analysis Services server -### [New-AzureRmAnalysisServicesFirewallConfig](New-AzureRmAnalysisServicesFirewallConfig.md) -Creates a new firewall config for Analysis Services server - -### [New-AzureRmAnalysisServicesFirewallRule](New-AzureRmAnalysisServicesFirewallRule.md) -Creates a new firewall rule for Analysis Services server - diff --git a/src/ResourceManager/AnalysisServices/Commands.AnalysisServices/help/Get-AzureRmAnalysisServicesServer.md b/src/ResourceManager/AnalysisServices/Commands.AnalysisServices/help/Get-AzureRmAnalysisServicesServer.md index d979c620fe41..2f447b720fa8 100644 --- a/src/ResourceManager/AnalysisServices/Commands.AnalysisServices/help/Get-AzureRmAnalysisServicesServer.md +++ b/src/ResourceManager/AnalysisServices/Commands.AnalysisServices/help/Get-AzureRmAnalysisServicesServer.md @@ -1,4 +1,4 @@ ---- +--- external help file: Microsoft.Azure.Commands.AnalysisServices.dll-Help.xml Module Name: AzureRM.AnalysisServices online version: https://docs.microsoft.com/en-us/powershell/module/azurerm.analysisservices/get-azurermanalysisservicesserver diff --git a/src/ResourceManager/AnalysisServices/Commands.AnalysisServices/help/New-AzureRmAnalysisServicesFirewallConfig.md b/src/ResourceManager/AnalysisServices/Commands.AnalysisServices/help/New-AzureRmAnalysisServicesFirewallConfig.md index 625198423f74..2aa620551e98 100644 --- a/src/ResourceManager/AnalysisServices/Commands.AnalysisServices/help/New-AzureRmAnalysisServicesFirewallConfig.md +++ b/src/ResourceManager/AnalysisServices/Commands.AnalysisServices/help/New-AzureRmAnalysisServicesFirewallConfig.md @@ -1,4 +1,4 @@ ---- +--- external help file: Microsoft.Azure.Commands.AnalysisServices.dll-Help.xml Module Name: AzureRM.AnalysisServices online version: https://docs.microsoft.com/en-us/powershell/module/azurerm.analysisservices/new-azurermanalysisservicesfirewallconfig @@ -13,7 +13,9 @@ Creates a new Analysis Services firewall config ## SYNTAX ``` -New-AzureRmAnalysisServicesFirewallConfig [-EnablePowerBIService] [-FirewallRule] List +New-AzureRmAnalysisServicesFirewallConfig [-EnablePowerBIService] + [-FirewallRule ] + [-DefaultProfile ] [] ``` ## DESCRIPTION @@ -32,6 +34,19 @@ Creates a firewall config object with two rules while also enabling access from ## PARAMETERS +### -DefaultProfile +The credentials, account, tenant, and subscription used for communication with Azure.```yaml +Type: IAzureContextContainer +Parameter Sets: (All) +Aliases: AzureRmContext, AzureCredential + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + ### -EnablePowerBIService A flag to indicate if the firewall is allowing access from Power BI @@ -41,7 +56,7 @@ Parameter Sets: (All) Aliases: Required: False -Position: 0 +Position: Named Default value: None Accept pipeline input: False Accept wildcard characters: False @@ -51,23 +66,28 @@ Accept wildcard characters: False A list of firewall rules ```yaml -Type: List +Type: System.Collections.Generic.List`1[Microsoft.Azure.Commands.AnalysisServices.Models.PsAzureAnalysisServicesFirewallRule] Parameter Sets: (All) Aliases: -Required: True -Position: 1 +Required: False +Position: Named Default value: None -Accept pipeline input: False +Accept pipeline input: True (ByPropertyName) 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 ## OUTPUTS ### Microsoft.Azure.Commands.AnalysisServices.Models.AzureAnalysisServicesFirewallConfig +## NOTES + ## RELATED LINKS [New-AzureRmAnalysisServicesFirewallRule](./New-AzureRmAnalysisServicesFirewallRule.md) diff --git a/src/ResourceManager/AnalysisServices/Commands.AnalysisServices/help/New-AzureRmAnalysisServicesFirewallRule.md b/src/ResourceManager/AnalysisServices/Commands.AnalysisServices/help/New-AzureRmAnalysisServicesFirewallRule.md index 0f4c9ea3a6be..3402585235e8 100644 --- a/src/ResourceManager/AnalysisServices/Commands.AnalysisServices/help/New-AzureRmAnalysisServicesFirewallRule.md +++ b/src/ResourceManager/AnalysisServices/Commands.AnalysisServices/help/New-AzureRmAnalysisServicesFirewallRule.md @@ -1,4 +1,4 @@ ---- +--- external help file: Microsoft.Azure.Commands.AnalysisServices.dll-Help.xml Module Name: AzureRM.AnalysisServices online version: https://docs.microsoft.com/en-us/powershell/module/azurerm.analysisservices/new-azurermanalysisservicesfirewallrule @@ -13,7 +13,8 @@ Creates a new Analysis Services firewall rule ## SYNTAX ``` -New-AzureRmAnalysisServicesFirewallRule [-FirewallRuleName] [-RangeStart] [-RangeEnd] +New-AzureRmAnalysisServicesFirewallRule [-FirewallRuleName] [-RangeStart] + [-RangeEnd] [-DefaultProfile ] [] ``` ## DESCRIPTION @@ -30,6 +31,19 @@ Creates a firewall rule named rule1 with start range 0.0.0.0 and end range 255.2 ## PARAMETERS +### -DefaultProfile +The credentials, account, tenant, and subscription used for communication with Azure.```yaml +Type: IAzureContextContainer +Parameter Sets: (All) +Aliases: AzureRmContext, AzureCredential + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + ### -FirewallRuleName Name of firewall rule @@ -41,12 +55,12 @@ Aliases: Required: True Position: 0 Default value: None -Accept pipeline input: False +Accept pipeline input: True (ByPropertyName) Accept wildcard characters: False ``` -### -RangeStart -The range start of a firewall rule +### -RangeEnd +The range end of a firewall rule ```yaml Type: String @@ -54,33 +68,38 @@ Parameter Sets: (All) Aliases: Required: True -Position: 1 +Position: 2 Default value: None -Accept pipeline input: False +Accept pipeline input: True (ByPropertyName) Accept wildcard characters: False ``` -### -RangeEnd -The range end of a firewall rule +### -RangeStart +The range start of a firewall rule ```yaml Type: String Parameter Sets: (All) -Aliases: AzureRmContext, AzureCredential +Aliases: Required: True -Position: 2 +Position: 1 Default value: None -Accept pipeline input: False +Accept pipeline input: True (ByPropertyName) 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 ## OUTPUTS ### Microsoft.Azure.Commands.AnalysisServices.Models.AzureAnalysisServicesFirewallRule +## NOTES + ## RELATED LINKS [New-AzureRmAnalysisServicesFirewallConfig](./New-AzureRmAnalysisServicesFirewallConfig.md) \ No newline at end of file diff --git a/src/ResourceManager/AnalysisServices/Commands.AnalysisServices/help/New-AzureRmAnalysisServicesServer.md b/src/ResourceManager/AnalysisServices/Commands.AnalysisServices/help/New-AzureRmAnalysisServicesServer.md index 8f8a64779555..e4f3408d92ff 100644 --- a/src/ResourceManager/AnalysisServices/Commands.AnalysisServices/help/New-AzureRmAnalysisServicesServer.md +++ b/src/ResourceManager/AnalysisServices/Commands.AnalysisServices/help/New-AzureRmAnalysisServicesServer.md @@ -1,4 +1,4 @@ ---- +--- external help file: Microsoft.Azure.Commands.AnalysisServices.dll-Help.xml Module Name: AzureRM.AnalysisServices online version: https://docs.microsoft.com/en-us/powershell/module/azurerm.analysisservices/new-azurermanalysisservicesserver @@ -15,8 +15,9 @@ Creates a new Analysis Services server ``` New-AzureRmAnalysisServicesServer [-ResourceGroupName] [-Name] [-Location] [-Sku] [[-Tag] ] [[-Administrator] ] [[-BackupBlobContainerUri] ] - [[-FirewallConfig] ] - [[-GatewayResourceId] ] [-DefaultProfile ] [-WhatIf] [-Confirm] [] + [-ReadonlyReplicaCount ] [-DefaultConnectionMode ] + [-FirewallConfig ] [-GatewayResourceId ] + [-DefaultProfile ] [-WhatIf] [-Confirm] [] ``` ## DESCRIPTION @@ -63,70 +64,69 @@ Accept pipeline input: True (ByPropertyName) Accept wildcard characters: False ``` -### -DefaultProfile -The credentials, account, tenant, and subscription used for communication with azure. +### -DefaultConnectionMode +Default connection mode of an Analysis service server ```yaml -Type: IAzureContextContainer +Type: String Parameter Sets: (All) -Aliases: AzureRmContext, AzureCredential +Aliases: +Accepted values: All, Readonly Required: False Position: Named Default value: None -Accept pipeline input: False +Accept pipeline input: True (ByPropertyName) Accept wildcard characters: False ``` -### -Location -The Azure region where the Analysis Services server is hosted +### -DefaultProfile +The credentials, account, tenant, and subscription used for communication with azure. ```yaml -Type: String +Type: IAzureContextContainer Parameter Sets: (All) -Aliases: -Accepted values: North Central US, South Central US, Central US, West Europe, North Europe, West US, East US, East US 2, Japan East, Japan West, Brazil South, Southeast Asia, East Asia, Australia East, Australia Southeast +Aliases: AzureRmContext, AzureCredential -Required: True -Position: 2 +Required: False +Position: Named Default value: None -Accept pipeline input: True (ByPropertyName) +Accept pipeline input: False Accept wildcard characters: False ``` -### -Name -Name of the Analysis Services server +### -FirewallConfig +Firewall config of an Analysis server ```yaml -Type: String +Type: PsAzureAnalysisServicesFirewallConfig Parameter Sets: (All) Aliases: -Required: True -Position: 1 +Required: False +Position: Named Default value: None Accept pipeline input: True (ByPropertyName) Accept wildcard characters: False ``` -### -ResourceGroupName -Name of the Azure resource group to which the server belongs +### -GatewayResourceId +Gateway resource Id for assocaite to an Analysis server ```yaml Type: String Parameter Sets: (All) Aliases: -Required: True -Position: 0 +Required: False +Position: Named Default value: None Accept pipeline input: True (ByPropertyName) Accept wildcard characters: False ``` -### -Sku -The name of the Sku for the server. -The supported values are 'S0', 'S1', 'S2', 'S4' for the Standard tier; 'B1', 'B2' for the Basic tier and 'D1' for Development tier. +### -Location +The Azure region where the Analysis Services server is hosted ```yaml Type: String @@ -134,22 +134,22 @@ Parameter Sets: (All) Aliases: Required: True -Position: 3 +Position: 2 Default value: None Accept pipeline input: True (ByPropertyName) Accept wildcard characters: False ``` -### -Tag -Key-value pairs in the form of a hash table set as tags on the server. +### -Name +Name of the Analysis Services server ```yaml -Type: Hashtable +Type: String Parameter Sets: (All) Aliases: -Required: False -Position: 4 +Required: True +Position: 1 Default value: None Accept pipeline input: True (ByPropertyName) Accept wildcard characters: False @@ -159,57 +159,58 @@ Accept wildcard characters: False Read only replica count of an Analysis service server ```yaml -Type: Integer +Type: Int32 Parameter Sets: (All) Aliases: Required: False -Position: 7 +Position: Named Default value: None Accept pipeline input: True (ByPropertyName) Accept wildcard characters: False ``` -### -DefaultConnectionMode -Default connection mode of an Analysis service server +### -ResourceGroupName +Name of the Azure resource group to which the server belongs ```yaml Type: String Parameter Sets: (All) Aliases: -Required: False -Position: 8 +Required: True +Position: 0 Default value: None Accept pipeline input: True (ByPropertyName) Accept wildcard characters: False ``` -### -FirewallConfig -Firewall config of an Analysis server +### -Sku +The name of the Sku for the server. +The supported values are 'S0', 'S1', 'S2', 'S4' for the Standard tier; 'B1', 'B2' for the Basic tier and 'D1' for Development tier. ```yaml -Type: Microsoft.Azure.Commands.AnalysisServices.Models.AzureAnalysisServicesFirewallConfig +Type: String Parameter Sets: (All) Aliases: -Required: False -Position: 9 +Required: True +Position: 3 Default value: None Accept pipeline input: True (ByPropertyName) Accept wildcard characters: False ``` -### -GatewayResourceId -Gateway resource Id for assocaite to an Analysis server +### -Tag +Key-value pairs in the form of a hash table set as tags on the server. ```yaml -Type: String +Type: Hashtable Parameter Sets: (All) Aliases: Required: False -Position: Named +Position: 4 Default value: None Accept pipeline input: True (ByPropertyName) Accept wildcard characters: False diff --git a/src/ResourceManager/AnalysisServices/Commands.AnalysisServices/help/Remove-AzureRmAnalysisServicesServer.md b/src/ResourceManager/AnalysisServices/Commands.AnalysisServices/help/Remove-AzureRmAnalysisServicesServer.md index 234e538fce72..8c819c3867de 100644 --- a/src/ResourceManager/AnalysisServices/Commands.AnalysisServices/help/Remove-AzureRmAnalysisServicesServer.md +++ b/src/ResourceManager/AnalysisServices/Commands.AnalysisServices/help/Remove-AzureRmAnalysisServicesServer.md @@ -1,4 +1,4 @@ ---- +--- external help file: Microsoft.Azure.Commands.AnalysisServices.dll-Help.xml Module Name: AzureRM.AnalysisServices online version: https://docs.microsoft.com/en-us/powershell/module/azurerm.analysisservices/remove-azurermanalysisservicesserver diff --git a/src/ResourceManager/AnalysisServices/Commands.AnalysisServices/help/Resume-AzureRmAnalysisServicesServer.md b/src/ResourceManager/AnalysisServices/Commands.AnalysisServices/help/Resume-AzureRmAnalysisServicesServer.md index 35dbfb6a1d25..a5cb3624dd56 100644 --- a/src/ResourceManager/AnalysisServices/Commands.AnalysisServices/help/Resume-AzureRmAnalysisServicesServer.md +++ b/src/ResourceManager/AnalysisServices/Commands.AnalysisServices/help/Resume-AzureRmAnalysisServicesServer.md @@ -1,4 +1,4 @@ ---- +--- external help file: Microsoft.Azure.Commands.AnalysisServices.dll-Help.xml Module Name: AzureRM.AnalysisServices online version: https://docs.microsoft.com/en-us/powershell/module/azurerm.analysisservices/resume-azurermanalysisservicesserver diff --git a/src/ResourceManager/AnalysisServices/Commands.AnalysisServices/help/Set-AzureRmAnalysisServicesServer.md b/src/ResourceManager/AnalysisServices/Commands.AnalysisServices/help/Set-AzureRmAnalysisServicesServer.md index 42d2def9d441..ba5fa8836f4f 100644 --- a/src/ResourceManager/AnalysisServices/Commands.AnalysisServices/help/Set-AzureRmAnalysisServicesServer.md +++ b/src/ResourceManager/AnalysisServices/Commands.AnalysisServices/help/Set-AzureRmAnalysisServicesServer.md @@ -1,4 +1,4 @@ ---- +--- external help file: Microsoft.Azure.Commands.AnalysisServices.dll-Help.xml Module Name: AzureRM.AnalysisServices online version: https://docs.microsoft.com/en-us/powershell/module/azurerm.analysisservices/set-azurermanalysisservicesserver @@ -15,19 +15,28 @@ Modifies an instance of Analysis Services server ### Default (Default) ``` Set-AzureRmAnalysisServicesServer [-Name] [[-ResourceGroupName] ] [[-Sku] ] - [[-Tag] ] [[-Administrator] ] [[-BackupBlobContainerUri] ] - [[-FirewallConfig] ] - [[-GatewayResourceId] ] [-DisassociateGateway] [-PassThru] + [[-Tag] ] [[-Administrator] ] [[-BackupBlobContainerUri] ] [-PassThru] + [-ReadonlyReplicaCount ] [-DefaultConnectionMode ] + [-FirewallConfig ] [-GatewayResourceId ] [-DefaultProfile ] [-WhatIf] [-Confirm] [] ``` ### DisableBackup ``` Set-AzureRmAnalysisServicesServer [-Name] [[-ResourceGroupName] ] [[-Sku] ] - [[-Tag] ] [[-Administrator] ] [-PassThru] [-DisableBackup] + [[-Tag] ] [[-Administrator] ] [-PassThru] [-DisableBackup] [-ReadonlyReplicaCount ] + [-DefaultConnectionMode ] [-FirewallConfig ] [-DefaultProfile ] [-WhatIf] [-Confirm] [] ``` +### DisassociateGateway +``` +Set-AzureRmAnalysisServicesServer [-Name] [[-ResourceGroupName] ] [[-Sku] ] + [[-Tag] ] [[-Administrator] ] [-PassThru] [-ReadonlyReplicaCount ] + [-DefaultConnectionMode ] [-FirewallConfig ] + [-DisassociateGateway] [-DefaultProfile ] [-WhatIf] [-Confirm] [] +``` + ## DESCRIPTION The Set-AzureRmAnalysisServicesServer cmdlet modifies an instance of Analysis Services server @@ -74,6 +83,22 @@ Accept pipeline input: True (ByPropertyName) Accept wildcard characters: False ``` +### -DefaultConnectionMode +Default connection mode of an Analysis service server + +```yaml +Type: String +Parameter Sets: (All) +Aliases: +Accepted values: All, Readonly + +Required: False +Position: Named +Default value: None +Accept pipeline input: True (ByPropertyName) +Accept wildcard characters: False +``` + ### -DefaultProfile The credentials, account, tenant, and subscription used for communication with azure. @@ -105,79 +130,78 @@ Accept pipeline input: True (ByPropertyName) Accept wildcard characters: False ``` -### -Name -Name of the Analysis Services server +### -DisassociateGateway +Disassociate Gateway resource from an Analysis server ```yaml -Type: String -Parameter Sets: (All) +Type: SwitchParameter +Parameter Sets: DisassociateGateway Aliases: -Required: True -Position: 0 +Required: False +Position: Named Default value: None Accept pipeline input: True (ByPropertyName) Accept wildcard characters: False ``` -### -PassThru -Will return the deleted server details if the operation completes successfully +### -FirewallConfig +Firewall config of an Analysis server ```yaml -Type: SwitchParameter +Type: PsAzureAnalysisServicesFirewallConfig Parameter Sets: (All) Aliases: Required: False Position: Named Default value: None -Accept pipeline input: False +Accept pipeline input: True (ByPropertyName) Accept wildcard characters: False ``` -### -ResourceGroupName -Name of the Azure resource group to which the server belongs +### -GatewayResourceId +Gateway resource Id for assocaite to an Analysis server ```yaml Type: String -Parameter Sets: (All) +Parameter Sets: Default Aliases: Required: False -Position: 1 +Position: Named Default value: None Accept pipeline input: True (ByPropertyName) Accept wildcard characters: False ``` -### -Sku -The name of the Sku for the server. -The supported values are 'S0', 'S1', 'S2', 'S4' for the Standard tier; 'B1', 'B2' for the Basic tier and 'D1' for Development tier. +### -Name +Name of the Analysis Services server ```yaml Type: String Parameter Sets: (All) Aliases: -Required: False -Position: 2 +Required: True +Position: 0 Default value: None Accept pipeline input: True (ByPropertyName) Accept wildcard characters: False ``` -### -Tag -Key-value pairs in the form of a hash table set as tags on the server. +### -PassThru +Will return the deleted server details if the operation completes successfully ```yaml -Type: Hashtable +Type: SwitchParameter Parameter Sets: (All) Aliases: Required: False -Position: 3 +Position: Named Default value: None -Accept pipeline input: True (ByPropertyName) +Accept pipeline input: False Accept wildcard characters: False ``` @@ -185,19 +209,19 @@ Accept wildcard characters: False Read only replica count of an Analysis service server ```yaml -Type: Integer +Type: Int32 Parameter Sets: (All) Aliases: Required: False -Position: 6 +Position: Named Default value: None Accept pipeline input: True (ByPropertyName) Accept wildcard characters: False ``` -### -DefaultConnectionMode -Default connection mode of an Analysis service server +### -ResourceGroupName +Name of the Azure resource group to which the server belongs ```yaml Type: String @@ -205,29 +229,15 @@ Parameter Sets: (All) Aliases: Required: False -Position: 7 -Default value: None -Accept pipeline input: True (ByPropertyName) -Accept wildcard characters: False -``` - -### -FirewallConfig -Firewall config of an Analysis server - -```yaml -Type: Microsoft.Azure.Commands.AnalysisServices.Models.AzureAnalysisServicesFirewallConfig -Parameter Sets: (All) -Aliases: - -Required: False -Position: 8 +Position: 1 Default value: None Accept pipeline input: True (ByPropertyName) Accept wildcard characters: False ``` -### -GatewayResourceId -Gateway resource Id for assocaite to an Analysis server +### -Sku +The name of the Sku for the server. +The supported values are 'S0', 'S1', 'S2', 'S4' for the Standard tier; 'B1', 'B2' for the Basic tier and 'D1' for Development tier. ```yaml Type: String @@ -235,24 +245,24 @@ Parameter Sets: (All) Aliases: Required: False -Position: Named +Position: 2 Default value: None Accept pipeline input: True (ByPropertyName) Accept wildcard characters: False ``` -### -DisassociateGateway -Disassociate Gateway resource from an Analysis server +### -Tag +Key-value pairs in the form of a hash table set as tags on the server. ```yaml -Type: SwitchParameter +Type: Hashtable Parameter Sets: (All) Aliases: Required: False -Position: Named +Position: 3 Default value: None -Accept pipeline input: True +Accept pipeline input: True (ByPropertyName) Accept wildcard characters: False ``` diff --git a/src/ResourceManager/AnalysisServices/Commands.AnalysisServices/help/Suspend-AzureRmAnalysisServicesServer.md b/src/ResourceManager/AnalysisServices/Commands.AnalysisServices/help/Suspend-AzureRmAnalysisServicesServer.md index 9fc52394e7e1..efd098168cc0 100644 --- a/src/ResourceManager/AnalysisServices/Commands.AnalysisServices/help/Suspend-AzureRmAnalysisServicesServer.md +++ b/src/ResourceManager/AnalysisServices/Commands.AnalysisServices/help/Suspend-AzureRmAnalysisServicesServer.md @@ -1,4 +1,4 @@ ---- +--- external help file: Microsoft.Azure.Commands.AnalysisServices.dll-Help.xml Module Name: AzureRM.AnalysisServices online version: https://docs.microsoft.com/en-us/powershell/module/azurerm.analysisservices/suspend-azurermanalysisservicesserver diff --git a/src/ResourceManager/AnalysisServices/Commands.AnalysisServices/help/Test-AzureRmAnalysisServicesServer.md b/src/ResourceManager/AnalysisServices/Commands.AnalysisServices/help/Test-AzureRmAnalysisServicesServer.md index ade5912cc255..1175b2b2225a 100644 --- a/src/ResourceManager/AnalysisServices/Commands.AnalysisServices/help/Test-AzureRmAnalysisServicesServer.md +++ b/src/ResourceManager/AnalysisServices/Commands.AnalysisServices/help/Test-AzureRmAnalysisServicesServer.md @@ -1,4 +1,4 @@ ---- +--- external help file: Microsoft.Azure.Commands.AnalysisServices.dll-Help.xml Module Name: AzureRM.AnalysisServices online version: https://docs.microsoft.com/en-us/powershell/module/azurerm.analysisservices/test-azurermanalysisservicesserver From d9592f464d22cb059000d46364d09088f85cbe4e Mon Sep 17 00:00:00 2001 From: Tai-Yi Wu Date: Fri, 4 May 2018 15:29:46 -0700 Subject: [PATCH 09/10] Fix md by removing trailing yaml --- .../help/New-AzureRmAnalysisServicesFirewallConfig.md | 2 +- .../help/New-AzureRmAnalysisServicesFirewallRule.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/ResourceManager/AnalysisServices/Commands.AnalysisServices/help/New-AzureRmAnalysisServicesFirewallConfig.md b/src/ResourceManager/AnalysisServices/Commands.AnalysisServices/help/New-AzureRmAnalysisServicesFirewallConfig.md index 2aa620551e98..65073f7195f2 100644 --- a/src/ResourceManager/AnalysisServices/Commands.AnalysisServices/help/New-AzureRmAnalysisServicesFirewallConfig.md +++ b/src/ResourceManager/AnalysisServices/Commands.AnalysisServices/help/New-AzureRmAnalysisServicesFirewallConfig.md @@ -35,7 +35,7 @@ Creates a firewall config object with two rules while also enabling access from ## PARAMETERS ### -DefaultProfile -The credentials, account, tenant, and subscription used for communication with Azure.```yaml +The credentials, account, tenant, and subscription used for communication with Azure. Type: IAzureContextContainer Parameter Sets: (All) Aliases: AzureRmContext, AzureCredential diff --git a/src/ResourceManager/AnalysisServices/Commands.AnalysisServices/help/New-AzureRmAnalysisServicesFirewallRule.md b/src/ResourceManager/AnalysisServices/Commands.AnalysisServices/help/New-AzureRmAnalysisServicesFirewallRule.md index 3402585235e8..66c5eea155e4 100644 --- a/src/ResourceManager/AnalysisServices/Commands.AnalysisServices/help/New-AzureRmAnalysisServicesFirewallRule.md +++ b/src/ResourceManager/AnalysisServices/Commands.AnalysisServices/help/New-AzureRmAnalysisServicesFirewallRule.md @@ -32,7 +32,7 @@ Creates a firewall rule named rule1 with start range 0.0.0.0 and end range 255.2 ## PARAMETERS ### -DefaultProfile -The credentials, account, tenant, and subscription used for communication with Azure.```yaml +The credentials, account, tenant, and subscription used for communication with Azure. Type: IAzureContextContainer Parameter Sets: (All) Aliases: AzureRmContext, AzureCredential From f008839a0570f60daba0fe0d522810742cacb05c Mon Sep 17 00:00:00 2001 From: Tai-Yi Wu Date: Wed, 9 May 2018 11:11:43 -0700 Subject: [PATCH 10/10] Fix changelog and minor changes for comments --- src/ResourceManager/AnalysisServices/ChangeLog.md | 2 +- .../ScenarioTests/AsTests.ps1 | 6 +++++- .../Commands/SetAzureRmAnalysisServicesServer.cs | 2 +- .../Models/AnalysisServicesClient.cs | 3 ++- 4 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/ResourceManager/AnalysisServices/ChangeLog.md b/src/ResourceManager/AnalysisServices/ChangeLog.md index 3922344f1ae4..5114381a3659 100644 --- a/src/ResourceManager/AnalysisServices/ChangeLog.md +++ b/src/ResourceManager/AnalysisServices/ChangeLog.md @@ -18,10 +18,10 @@ - Additional information about change #1 --> ## Current Release +* Enable Gateway assocaite/disassociate operations on AS. ## Version 0.6.7 * Set minimum dependency of module to PowerShell 5.0 -* Enable Gateway assocaite/disassociate operations on AS. ## Version 0.6.6 * Updated to the latest version of the Azure ClientRuntime diff --git a/src/ResourceManager/AnalysisServices/Commands.AnalysisServices.Test/ScenarioTests/AsTests.ps1 b/src/ResourceManager/AnalysisServices/Commands.AnalysisServices.Test/ScenarioTests/AsTests.ps1 index dd1d0a702acb..082156a249fe 100644 --- a/src/ResourceManager/AnalysisServices/Commands.AnalysisServices.Test/ScenarioTests/AsTests.ps1 +++ b/src/ResourceManager/AnalysisServices/Commands.AnalysisServices.Test/ScenarioTests/AsTests.ps1 @@ -615,7 +615,11 @@ function Test-AnalysisServicesServerLoginWithSPN <# .SYNOPSIS -Tests Analysis Services server lifecycle Failure scenarios (Create, Update, Get, Delete). +Tests Analysis Services server gateway scenarios (associate/dissociate). +The assocaited gateway is a unified gateway, which required pre-setup. +1. Install on-premise gateway on target host https://www.microsoft.com/en-us/download/details.aspx?id=53127 +2. Follow installation instruction to create azure on-premise gateway resource associating to the host. +Afterward, use the gateway resource to associate with the AAS for testing. #> function Test-AnalysisServicesServerGateway { diff --git a/src/ResourceManager/AnalysisServices/Commands.AnalysisServices/Commands/SetAzureRmAnalysisServicesServer.cs b/src/ResourceManager/AnalysisServices/Commands.AnalysisServices/Commands/SetAzureRmAnalysisServicesServer.cs index 598394138e99..90a14dc421ee 100644 --- a/src/ResourceManager/AnalysisServices/Commands.AnalysisServices/Commands/SetAzureRmAnalysisServicesServer.cs +++ b/src/ResourceManager/AnalysisServices/Commands.AnalysisServices/Commands/SetAzureRmAnalysisServicesServer.cs @@ -160,7 +160,7 @@ public override void ExecuteCmdlet() if (DisassociateGateway.IsPresent) { - GatewayResourceId = "-"; + GatewayResourceId = AnalysisServicesClient.DissasociateGateway; } AnalysisServicesServer updatedServer = AnalysisServicesClient.CreateOrUpdateServer(ResourceGroupName, Name, location, Sku, Tag, Administrator, currentServer, BackupBlobContainerUri, ReadonlyReplicaCount, DefaultConnectionMode, setting, GatewayResourceId); diff --git a/src/ResourceManager/AnalysisServices/Commands.AnalysisServices/Models/AnalysisServicesClient.cs b/src/ResourceManager/AnalysisServices/Commands.AnalysisServices/Models/AnalysisServicesClient.cs index 85d57191630c..345afeab4086 100644 --- a/src/ResourceManager/AnalysisServices/Commands.AnalysisServices/Models/AnalysisServicesClient.cs +++ b/src/ResourceManager/AnalysisServices/Commands.AnalysisServices/Models/AnalysisServicesClient.cs @@ -33,6 +33,7 @@ public class AnalysisServicesClient private readonly AnalysisServicesManagementClient _client; private readonly Guid _subscriptionId; private readonly string _currentUser; + public const string DissasociateGateway = "-"; public AnalysisServicesClient(IAzureContext context) { @@ -89,7 +90,7 @@ public AnalysisServicesServer CreateOrUpdateServer( } GatewayDetails gatewayDetails = null; - if (gatewayResourceId == "-") + if (gatewayResourceId == DissasociateGateway) { gatewayDetails = new GatewayDetails(); }