Files

51 lines
1.8 KiB
TypeScript

// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
/**
* This sample demonstrates how to Sample the Stream Analytics input data.
*
* @summary Sample the Stream Analytics input data.
* x-ms-original-file: specification/streamanalytics/resource-manager/Microsoft.StreamAnalytics/preview/2021-10-01-preview/examples/Subscription_SampleInput.json
*/
import type { SampleInput } from "@azure/arm-streamanalytics";
import { StreamAnalyticsManagementClient } from "@azure/arm-streamanalytics";
import { DefaultAzureCredential } from "@azure/identity";
import "dotenv/config";
async function sampleTheStreamAnalyticsInputData(): Promise<void> {
const subscriptionId =
process.env["STREAMANALYTICS_SUBSCRIPTION_ID"] || "56b5e0a9-b645-407d-99b0-c64f86013e3d";
const location = "West US";
const sampleInput: SampleInput = {
compatibilityLevel: "1.2",
dataLocale: "en-US",
eventsUri: "http://myoutput.com",
input: {
properties: {
type: "Stream",
datasource: {
type: "Microsoft.Storage/Blob",
container: "state",
dateFormat: "yyyy/MM/dd",
pathPattern: "{date}/{time}",
sourcePartitionCount: 16,
storageAccounts: [{ accountKey: "someAccountKey==", accountName: "someAccountName" }],
timeFormat: "HH",
},
serialization: { type: "Csv", encoding: "UTF8", fieldDelimiter: "," },
},
},
};
const credential = new DefaultAzureCredential();
const client = new StreamAnalyticsManagementClient(credential, subscriptionId);
const result = await client.subscriptions.beginSampleInputAndWait(location, sampleInput);
console.log(result);
}
async function main(): Promise<void> {
await sampleTheStreamAnalyticsInputData();
}
main().catch(console.error);