in src/durableClient/DurableClient.ts [470:502]
public async startNew(
orchestratorFunctionName: string,
options?: StartNewOptions
): Promise<string> {
if (!orchestratorFunctionName) {
throw new Error("orchestratorFunctionName must be a valid string.");
}
// TODO: Add support for specifying a task hub and a connection name
let requestUrl: string;
const instanceIdPath: string = options?.instanceId ? `/${options.instanceId}` : "";
if (this.clientData.rpcBaseUrl) {
// Fast local RPC path
requestUrl = new URL(
`orchestrators/${orchestratorFunctionName}${instanceIdPath}`,
this.clientData.rpcBaseUrl
).href;
} else {
// Legacy app frontend path
requestUrl = this.clientData.creationUrls.createNewInstancePostUri;
requestUrl = requestUrl
.replace(this.functionNamePlaceholder, orchestratorFunctionName)
.replace(this.instanceIdPlaceholder, instanceIdPath);
}
const input: unknown = options?.input !== undefined ? JSON.stringify(options.input) : "";
const response = await this.axiosInstance.post(requestUrl, input);
if (response.data && response.status <= 202) {
return (response.data as HttpManagementPayload).id;
} else {
return Promise.reject(this.createGenericError(response));
}
}