diff --git a/internal/services/streamanalytics/stream_analytics_output_blob_resource.go b/internal/services/streamanalytics/stream_analytics_output_blob_resource.go index c58f80b85f4c..99aa94322aa1 100644 --- a/internal/services/streamanalytics/stream_analytics_output_blob_resource.go +++ b/internal/services/streamanalytics/stream_analytics_output_blob_resource.go @@ -121,6 +121,13 @@ func resourceStreamAnalyticsOutputBlob() *pluginsdk.Resource { Sensitive: true, ValidateFunc: validation.StringIsNotEmpty, }, + + "blob_write_mode": { + Type: pluginsdk.TypeString, + Optional: true, + Default: string(outputs.BlobWriteModeAppend), + ValidateFunc: validation.StringInSlice(outputs.PossibleValuesForBlobWriteMode(), false), + }, }, } } @@ -174,6 +181,7 @@ func resourceStreamAnalyticsOutputBlobCreateUpdate(d *pluginsdk.ResourceData, me PathPattern: pointer.To(pathPattern), TimeFormat: pointer.To(timeFormat), AuthenticationMode: pointer.To(outputs.AuthenticationMode(d.Get("authentication_mode").(string))), + BlobWriteMode: pointer.To(outputs.BlobWriteMode(d.Get("blob_write_mode").(string))), }, }, Serialization: serialization, @@ -281,6 +289,12 @@ func resourceStreamAnalyticsOutputBlobRead(d *pluginsdk.ResourceData, meta inter } d.Set("batch_max_wait_time", props.TimeWindow) d.Set("batch_min_rows", props.SizeWindow) + + blobWriteMode := "" + if v := output.Properties.BlobWriteMode; v != nil { + blobWriteMode = string(*v) + } + d.Set("blob_write_mode", blobWriteMode) } } return nil diff --git a/internal/services/streamanalytics/stream_analytics_output_blob_resource_test.go b/internal/services/streamanalytics/stream_analytics_output_blob_resource_test.go index 25ba480af7a7..922e395448e8 100644 --- a/internal/services/streamanalytics/stream_analytics_output_blob_resource_test.go +++ b/internal/services/streamanalytics/stream_analytics_output_blob_resource_test.go @@ -138,6 +138,21 @@ func TestAccStreamAnalyticsOutputBlob_authenticationMode(t *testing.T) { }) } +func TestAccStreamAnalyticsOutputBlob_blobWriteMode(t *testing.T) { + data := acceptance.BuildTestData(t, "azurerm_stream_analytics_output_blob", "test") + r := StreamAnalyticsOutputBlobResource{} + + data.ResourceTest(t, r, []acceptance.TestStep{ + { + Config: r.blobWriteMode(data), + Check: acceptance.ComposeTestCheckFunc( + check.That(data.ResourceName).ExistsInAzure(r), + ), + }, + data.ImportStep("storage_account_key"), + }) +} + func (r StreamAnalyticsOutputBlobResource) Exists(ctx context.Context, client *clients.Client, state *pluginsdk.InstanceState) (*bool, error) { id, err := outputs.ParseOutputID(state.ID) if err != nil { @@ -387,3 +402,28 @@ QUERY } `, data.RandomInteger, data.Locations.Primary, data.RandomString, data.RandomInteger, identity) } + +func (r StreamAnalyticsOutputBlobResource) blobWriteMode(data acceptance.TestData) string { + return fmt.Sprintf(` +%s + +resource "azurerm_stream_analytics_output_blob" "test" { + name = "acctestinput-%d" + stream_analytics_job_name = azurerm_stream_analytics_job.test.name + resource_group_name = azurerm_stream_analytics_job.test.resource_group_name + storage_account_name = azurerm_storage_account.test.name + storage_account_key = azurerm_storage_account.test.primary_access_key + storage_container_name = azurerm_storage_container.test.name + path_pattern = "some-pattern/{date}/{time}" + date_format = "yyyy-MM-dd" + time_format = "HH" + blob_write_mode = "Once" + + serialization { + type = "Csv" + encoding = "UTF8" + field_delimiter = "," + } +} +`, r.template(data, ""), data.RandomInteger) +} diff --git a/website/docs/r/stream_analytics_output_blob.html.markdown b/website/docs/r/stream_analytics_output_blob.html.markdown index 9a8d9b8e5903..765283f4bf02 100644 --- a/website/docs/r/stream_analytics_output_blob.html.markdown +++ b/website/docs/r/stream_analytics_output_blob.html.markdown @@ -86,6 +86,8 @@ The following arguments are supported: * `storage_account_key` - (Optional) The Access Key which should be used to connect to this Storage Account. +* `blob_write_mode` - (Optional) Determines whether blob blocks are either committed automatically or appended. Possible values are `Append` and `Once`. Defaults to `Append`. + --- A `serialization` block supports the following: