diff --git a/azurerm/resource_arm_analysis_services_server.go b/azurerm/resource_arm_analysis_services_server.go index 1c8a6ce9bc8a..b46af3a64793 100644 --- a/azurerm/resource_arm_analysis_services_server.go +++ b/azurerm/resource_arm_analysis_services_server.go @@ -96,6 +96,18 @@ func resourceArmAnalysisServicesServer() *schema.Resource { ValidateFunc: validateQuerypoolConnectionMode(), }, + "backup_blob_container_uri": { + Type: schema.TypeString, + Optional: true, + Sensitive: true, + ValidateFunc: validate.NoEmptyStrings, + }, + + "server_full_name": { + Type: schema.TypeString, + Computed: true, + }, + "tags": tags.Schema(), }, } @@ -208,6 +220,12 @@ func resourceArmAnalysisServicesServerRead(d *schema.ResourceData, meta interfac } d.Set("querypool_connection_mode", string(serverProps.QuerypoolConnectionMode)) + + d.Set("server_full_name", serverProps.ServerFullName) + + if containerUri, ok := d.GetOk("backup_blob_container_uri"); ok { + d.Set("backup_blob_container_uri", containerUri) + } } return tags.FlattenAndSet(d, server.Tags) @@ -303,6 +321,10 @@ func expandAnalysisServicesServerProperties(d *schema.ResourceData) *analysisser serverProperties.QuerypoolConnectionMode = analysisservices.ConnectionMode(querypoolConnectionMode.(string)) } + if containerUri, ok := d.GetOk("backup_blob_container_uri"); ok { + serverProperties.BackupBlobContainerURI = utils.String(containerUri.(string)) + } + return &serverProperties } @@ -315,6 +337,10 @@ func expandAnalysisServicesServerMutableProperties(d *schema.ResourceData) *anal serverProperties.QuerypoolConnectionMode = analysisservices.ConnectionMode(d.Get("querypool_connection_mode").(string)) + if containerUri, ok := d.GetOk("backup_blob_container_uri"); ok { + serverProperties.BackupBlobContainerURI = utils.String(containerUri.(string)) + } + return &serverProperties } diff --git a/azurerm/resource_arm_analysis_services_server_test.go b/azurerm/resource_arm_analysis_services_server_test.go index 8d1a9c902aa0..06de35fdb4e1 100644 --- a/azurerm/resource_arm_analysis_services_server_test.go +++ b/azurerm/resource_arm_analysis_services_server_test.go @@ -6,6 +6,7 @@ import ( "strings" "testing" + "github.com/hashicorp/terraform/helper/acctest" "github.com/hashicorp/terraform/helper/resource" "github.com/hashicorp/terraform/terraform" "github.com/terraform-providers/terraform-provider-azurerm/azurerm/helpers/tf" @@ -192,6 +193,52 @@ func TestAccAzureRMAnalysisServicesServer_adminUsers(t *testing.T) { }) } +func TestAccAzureRMAnalysisServicesServer_serverFullName(t *testing.T) { + resourceName := "azurerm_analysis_services_server.test" + ri := tf.AccRandTimeInt() + + resource.ParallelTest(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + CheckDestroy: testCheckAzureRMAnalysisServicesServerDestroy, + Steps: []resource.TestStep{ + { + Config: testAccAzureRMAnalysisServicesServer_serverFullName(ri, testLocation()), + Check: resource.ComposeTestCheckFunc( + testCheckAzureRMAnalysisServicesServerExists(resourceName), + resource.TestCheckResourceAttrSet(resourceName, "server_full_name"), + ), + }, + { + ResourceName: resourceName, + ImportState: true, + ImportStateVerify: true, + }, + }, + }) +} + +func TestAccAzureRMAnalysisServicesServer_backupBlobContainerUri(t *testing.T) { + resourceName := "azurerm_analysis_services_server.test" + ri := tf.AccRandTimeInt() + rs := acctest.RandString(6) + + resource.ParallelTest(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + CheckDestroy: testCheckAzureRMAnalysisServicesServerDestroy, + Steps: []resource.TestStep{ + { + Config: testAccAzureRMAnalysisServicesServer_backupBlobContainerUri(ri, testLocation(), rs), + Check: resource.ComposeTestCheckFunc( + testCheckAzureRMAnalysisServicesServerExists(resourceName), + resource.TestCheckResourceAttrSet(resourceName, "backup_blob_container_uri"), + ), + }, + }, + }) +} + func testAccAzureRMAnalysisServicesServer_basic(rInt int, location string) string { return fmt.Sprintf(` resource "azurerm_resource_group" "test" { @@ -352,6 +399,73 @@ resource "azurerm_analysis_services_server" "test" { `, rInt, location, rInt, strings.Join(adminUsers, "\", \"")) } +func testAccAzureRMAnalysisServicesServer_serverFullName(rInt int, location string) string { + return fmt.Sprintf(` +resource "azurerm_resource_group" "test" { + name = "acctestRG-%d" + location = "%s" +} + +resource "azurerm_analysis_services_server" "test" { + name = "acctestass%d" + location = "${azurerm_resource_group.test.location}" + resource_group_name = "${azurerm_resource_group.test.name}" + sku = "B1" +} +`, rInt, location, rInt) +} + +func testAccAzureRMAnalysisServicesServer_backupBlobContainerUri(rInt int, location string, rString string) string { + return fmt.Sprintf(` +resource "azurerm_resource_group" "test" { + name = "acctestRG-%d" + location = "%s" +} + +resource "azurerm_storage_account" "test" { + name = "acctestass%s" + resource_group_name = "${azurerm_resource_group.test.name}" + location = "${azurerm_resource_group.test.location}" + account_kind = "BlobStorage" + account_tier = "Standard" + account_replication_type = "LRS" +} + +resource "azurerm_storage_container" "test" { + name = "assbackup" + storage_account_name = "${azurerm_storage_account.test.name}" + container_access_type = "private" +} + +data "azurerm_storage_account_blob_container_sas" "test" { + connection_string = "${azurerm_storage_account.test.primary_connection_string}" + container_name = "${azurerm_storage_container.test.name}" + https_only = true + + start = "2018-06-01" + expiry = "2048-06-01" + + permissions { + read = true + add = true + create = true + write = true + delete = true + list = true + } +} + +resource "azurerm_analysis_services_server" "test" { + name = "acctestass%d" + location = "${azurerm_resource_group.test.location}" + resource_group_name = "${azurerm_resource_group.test.name}" + sku = "B1" + + backup_blob_container_uri = "${azurerm_storage_account.test.primary_blob_endpoint}${azurerm_storage_container.test.name}${data.azurerm_storage_account_blob_container_sas.test.sas}" +} +`, rInt, location, rString, rInt) +} + func testCheckAzureRMAnalysisServicesServerDestroy(s *terraform.State) error { client := testAccProvider.Meta().(*ArmClient).analysisservices.ServerClient diff --git a/website/docs/r/analysis_services_server.html.markdown b/website/docs/r/analysis_services_server.html.markdown index a705212c917d..0c9b1848f206 100644 --- a/website/docs/r/analysis_services_server.html.markdown +++ b/website/docs/r/analysis_services_server.html.markdown @@ -54,6 +54,8 @@ The following arguments are supported: * `querypool_connection_mode` - (Optional) Controls how the read-write server is used in the query pool. If this values is set to `All` then read-write servers are also used for queries. Otherwise with `ReadOnly` these servers do not participate in query operations. +* `backup_blob_container_uri` - (Optional) URI and SAS token for a blob container to store backups. + * `enable_power_bi_service` - (Optional) Indicates if the Power BI service is allowed to access or not. * `ipv4_firewall_rule` - (Optional) One or more `ipv4_firewall_rule` block(s) as defined below. @@ -75,6 +77,8 @@ In addition to all arguments above, the following attributes are exported: * `id` - The ID of the Analysis Services Server. +* `server_full_name` - The full name of the Analysis Services Server. + ## Import Analysis Services Server can be imported using the `resource id`, e.g.