mirror of
https://github.com/hanzoai/azure-sdk-for-js.git
synced 2026-10-30 19:51:51 +00:00
80 lines
3.3 KiB
TypeScript
80 lines
3.3 KiB
TypeScript
// Copyright (c) Microsoft Corporation.
|
|
// Licensed under the MIT License.
|
|
|
|
/**
|
|
* This sample demonstrates how to Updates an existing function under an existing streaming job. This can be used to partially update (ie. update one or two properties) a function without affecting the rest the job or function definition.
|
|
*
|
|
* @summary Updates an existing function under an existing streaming job. This can be used to partially update (ie. update one or two properties) a function without affecting the rest the job or function definition.
|
|
* x-ms-original-file: specification/streamanalytics/resource-manager/Microsoft.StreamAnalytics/preview/2021-10-01-preview/examples/Function_Update_JavaScript.json
|
|
*/
|
|
|
|
import type { FunctionModel } from "@azure/arm-streamanalytics";
|
|
import { StreamAnalyticsManagementClient } from "@azure/arm-streamanalytics";
|
|
import { DefaultAzureCredential } from "@azure/identity";
|
|
import "dotenv/config";
|
|
|
|
async function updateAJavaScriptFunction(): Promise<void> {
|
|
const subscriptionId =
|
|
process.env["STREAMANALYTICS_SUBSCRIPTION_ID"] || "56b5e0a9-b645-407d-99b0-c64f86013e3d";
|
|
const resourceGroupName = process.env["STREAMANALYTICS_RESOURCE_GROUP"] || "sjrg1637";
|
|
const jobName = "sj8653";
|
|
const functionName = "function8197";
|
|
const functionParam: FunctionModel = {
|
|
properties: {
|
|
type: "Scalar",
|
|
binding: {
|
|
type: "Microsoft.StreamAnalytics/JavascriptUdf",
|
|
script: "function (a, b) { return a * b; }",
|
|
},
|
|
},
|
|
};
|
|
const credential = new DefaultAzureCredential();
|
|
const client = new StreamAnalyticsManagementClient(credential, subscriptionId);
|
|
const result = await client.functions.update(
|
|
resourceGroupName,
|
|
jobName,
|
|
functionName,
|
|
functionParam,
|
|
);
|
|
console.log(result);
|
|
}
|
|
|
|
/**
|
|
* This sample demonstrates how to Updates an existing function under an existing streaming job. This can be used to partially update (ie. update one or two properties) a function without affecting the rest the job or function definition.
|
|
*
|
|
* @summary Updates an existing function under an existing streaming job. This can be used to partially update (ie. update one or two properties) a function without affecting the rest the job or function definition.
|
|
* x-ms-original-file: specification/streamanalytics/resource-manager/Microsoft.StreamAnalytics/preview/2021-10-01-preview/examples/Function_Update_AzureML.json
|
|
*/
|
|
async function updateAnAzureMlFunction(): Promise<void> {
|
|
const subscriptionId =
|
|
process.env["STREAMANALYTICS_SUBSCRIPTION_ID"] || "56b5e0a9-b645-407d-99b0-c64f86013e3d";
|
|
const resourceGroupName = process.env["STREAMANALYTICS_RESOURCE_GROUP"] || "sjrg7";
|
|
const jobName = "sj9093";
|
|
const functionName = "function588";
|
|
const functionParam: FunctionModel = {
|
|
properties: {
|
|
type: "Scalar",
|
|
binding: {
|
|
type: "Microsoft.MachineLearning/WebService",
|
|
batchSize: 5000,
|
|
},
|
|
},
|
|
};
|
|
const credential = new DefaultAzureCredential();
|
|
const client = new StreamAnalyticsManagementClient(credential, subscriptionId);
|
|
const result = await client.functions.update(
|
|
resourceGroupName,
|
|
jobName,
|
|
functionName,
|
|
functionParam,
|
|
);
|
|
console.log(result);
|
|
}
|
|
|
|
async function main(): Promise<void> {
|
|
await updateAJavaScriptFunction();
|
|
await updateAnAzureMlFunction();
|
|
}
|
|
|
|
main().catch(console.error);
|