Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

stream_analytics_output_blob - Add support for the blob_write_mode property #25127

Merged
merged 3 commits into from
Mar 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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),
},
},
}
}
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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)
}
2 changes: 2 additions & 0 deletions website/docs/r/stream_analytics_output_blob.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
Loading