Skip to content

Commit

Permalink
Merge pull request #4397 from r0bnet/analysis_services_server-backup-…
Browse files Browse the repository at this point in the history
…blob-container

Analysis services server server_full_name & backup_blob_container_uri
  • Loading branch information
tombuildsstuff committed Sep 26, 2019
2 parents 1a8ef07 + 7f0eefa commit 9677b2f
Show file tree
Hide file tree
Showing 3 changed files with 144 additions and 0 deletions.
26 changes: 26 additions & 0 deletions azurerm/resource_arm_analysis_services_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
},
}
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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
}

Expand All @@ -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
}

Expand Down
114 changes: 114 additions & 0 deletions azurerm/resource_arm_analysis_services_server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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" {
Expand Down Expand Up @@ -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

Expand Down
4 changes: 4 additions & 0 deletions website/docs/r/analysis_services_server.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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.
Expand Down

0 comments on commit 9677b2f

Please sign in to comment.