Files

71 lines
2.3 KiB
TypeScript

// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
/**
* This sample demonstrates how to Test the Stream Analytics query on a sample input.
*
* @summary Test the Stream Analytics query on a sample input.
* x-ms-original-file: specification/streamanalytics/resource-manager/Microsoft.StreamAnalytics/preview/2021-10-01-preview/examples/Subscription_TestQuery.json
*/
import type { TestQuery } from "@azure/arm-streamanalytics";
import { StreamAnalyticsManagementClient } from "@azure/arm-streamanalytics";
import { DefaultAzureCredential } from "@azure/identity";
import "dotenv/config";
async function testTheStreamAnalyticsQuery(): Promise<void> {
const subscriptionId =
process.env["STREAMANALYTICS_SUBSCRIPTION_ID"] || "56b5e0a9-b645-407d-99b0-c64f86013e3d";
const location = "West US";
const testQuery: TestQuery = {
diagnostics: {
path: "/pathto/subdirectory",
writeUri: "http://myoutput.com",
},
streamingJob: {
compatibilityLevel: "1.0",
dataLocale: "en-US",
eventsLateArrivalMaxDelayInSeconds: 5,
eventsOutOfOrderMaxDelayInSeconds: 0,
eventsOutOfOrderPolicy: "Drop",
functions: [],
inputs: [
{
name: "inputtest",
properties: {
type: "Stream",
datasource: { type: "Raw", payloadUri: "http://myinput.com" },
serialization: { type: "Json", encoding: "UTF8" },
},
},
],
location: "West US",
outputErrorPolicy: "Drop",
outputs: [
{
name: "outputtest",
datasource: { type: "Raw", payloadUri: "http://myoutput.com" },
serialization: { type: "Json" },
},
],
skuPropertiesSku: { name: "Standard" },
tags: { key1: "value1", key3: "value3", randomKey: "randomValue" },
transformation: {
name: "transformationtest",
query: "Select Id, Name from inputtest",
streamingUnits: 1,
},
},
};
const credential = new DefaultAzureCredential();
const client = new StreamAnalyticsManagementClient(credential, subscriptionId);
const result = await client.subscriptions.beginTestQueryAndWait(location, testQuery);
console.log(result);
}
async function main(): Promise<void> {
await testTheStreamAnalyticsQuery();
}
main().catch(console.error);