Files
cosmos-explorer/src/Common/dataAccess/deleteUserDefinedFunction.ts
asier-isayas 92c8afd166 More playwright tests (#2310)
* Add playwright tests for Autoscale/Manual Throughpout and TTL

* fix unit tests and lint

* fix unit tests

* fix tests

* fix autoscale selector

* changed throughput above limit

* Add more playwright tests

* fix tests

* nit

* cleanup

* format

* stored procedure playwright test

* add user defined function playwright test

* Add user defined functions and trigger test

* fix upload items

* fix tests

* fix lint errors

* fix lint

* run cleanup every 3 hours

* keep cleanup at 2 hours

---------

Co-authored-by: Asier Isayas <aisayas@microsoft.com>
2026-01-09 10:23:35 -06:00

35 lines
1.3 KiB
TypeScript

import { AuthType } from "../../AuthType";
import { userContext } from "../../UserContext";
import { deleteSqlUserDefinedFunction } from "../../Utils/arm/generatedClients/cosmos/sqlResources";
import { logConsoleProgress } from "../../Utils/NotificationConsoleUtils";
import { client } from "../CosmosClient";
import { handleError } from "../ErrorHandlingUtils";
export async function deleteUserDefinedFunction(databaseId: string, collectionId: string, id: string): Promise<void> {
const clearMessage = logConsoleProgress(`Deleting user defined function ${id}`);
try {
if (
userContext.authType === AuthType.AAD &&
!userContext.features.enableSDKoperations &&
userContext.apiType === "SQL"
) {
await deleteSqlUserDefinedFunction(
userContext.subscriptionId,
userContext.resourceGroup,
userContext.databaseAccount.name,
databaseId,
collectionId,
id,
);
} else {
await client().database(databaseId).container(collectionId).scripts.userDefinedFunction(id).delete();
}
logConsoleProgress(`Successfully deleted user defined function ${id}`);
} catch (error) {
handleError(error, "DeleteUserDefinedFunction", `Error while deleting user defined function ${id}`);
throw error;
} finally {
clearMessage();
}
}