Skip to content

Commit 7fcf768

Browse files
authored
Merge pull request #48259 from kerend/patch-5
Added generate data section
2 parents f89a22d + f8422db commit 7fcf768

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

articles/data-explorer/data-connection-event-grid-csharp.md

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,4 +90,36 @@ await kustoManagementClient.DataConnections.CreateOrUpdateAsync(resourceGroupNam
9090
| consumerGroup | *$Default* | The consumer group of your Event Hub.|
9191
| location | *Central US* | The location of the data connection resource.|
9292

93+
## Generate sample data
94+
95+
Now that Azure Data Explorer and the storage account are connected, you can create sample data and upload it to the blob storage.
96+
97+
This script creates a new container in your storage account, uploads an existing file (as a blob) to that container, and then lists the blobs in the container.
98+
99+
```csharp
100+
var azureStorageAccountConnectionString=<storage_account_connection_string>;
101+
102+
var containerName=<container_name>;
103+
var blobName=<blob_name>;
104+
var localFileName=<file_to_upload>;
105+
106+
// Creating the container
107+
var azureStorageAccount = CloudStorageAccount.Parse(azureStorageAccountConnectionString);
108+
var blobClient = azureStorageAccount.CreateCloudBlobClient();
109+
var container = blobClient.GetContainerReference(containerName);
110+
container.CreateIfNotExists();
111+
112+
// Set metadata and upload file to blob
113+
var blob = container.GetBlockBlobReference(blobName);
114+
blob.Metadata.Add("rawSizeBytes", "4096‬"); // the uncompressed size is 4096 bytes
115+
blob.Metadata.Add("kustoIngestionMappingReference", "mapping_v2‬");
116+
blob.UploadFromFile(localFileName);
117+
118+
// List blobs
119+
var blobs = container.ListBlobs();
120+
```
121+
122+
> [!NOTE]
123+
> Azure Data Explorer won't delete the blobs post ingestion. Retain the blobs for three to five days by using [Azure Blob storage lifecycle](https://docs.microsoft.com/azure/storage/blobs/storage-lifecycle-management-concepts?tabs=azure-portal) to manage blob deletion.
124+
93125
[!INCLUDE [data-explorer-data-connection-clean-resources-csharp](../../includes/data-explorer-data-connection-clean-resources-csharp.md)]

0 commit comments

Comments
 (0)