Skip to content

Infisical is the open-source platform for securing secrets, certificates, access, and AI Agents.

feat(audit-log-stream): azure support

x032205a2550b1d0475
diff --git a/backend/src/ee/routes/v1/audit-log-stream-routers/audit-log-stream-router.ts b/backend/src/ee/routes/v1/audit-log-stream-routers/audit-log-stream-router.ts
index bf10e48bf1..de68352f6e 100644
--- a/backend/src/ee/routes/v1/audit-log-stream-routers/audit-log-stream-router.ts
+++ b/backend/src/ee/routes/v1/audit-log-stream-routers/audit-log-stream-router.ts
@@ -1,5 +1,9 @@
import { z } from "zod";
+import {
+ AzureProviderListItemSchema,
+ SanitizedAzureProviderSchema
+} from "@app/ee/services/audit-log-stream/azure/azure-provider-schemas";
import {
CustomProviderListItemSchema,
SanitizedCustomProviderSchema
@@ -19,13 +23,15 @@ import { AuthMode } from "@app/services/auth/auth-type";
const SanitizedAuditLogStreamSchema = z.union([
SanitizedCustomProviderSchema,
SanitizedDatadogProviderSchema,
- SanitizedSplunkProviderSchema
+ SanitizedSplunkProviderSchema,
+ SanitizedAzureProviderSchema
]);
const ProviderOptionsSchema = z.discriminatedUnion("provider", [
CustomProviderListItemSchema,
DatadogProviderListItemSchema,
- SplunkProviderListItemSchema
+ SplunkProviderListItemSchema,
+ AzureProviderListItemSchema
]);
export const registerAuditLogStreamRouter = async (server: FastifyZodProvider) => {
diff --git a/backend/src/ee/routes/v1/audit-log-stream-routers/index.ts b/backend/src/ee/routes/v1/audit-log-stream-routers/index.ts
index ea3d48b308..1884ce3ead 100644
--- a/backend/src/ee/routes/v1/audit-log-stream-routers/index.ts
+++ b/backend/src/ee/routes/v1/audit-log-stream-routers/index.ts
@@ -1,4 +1,9 @@
import { LogProvider } from "@app/ee/services/audit-log-stream/audit-log-stream-enums";
+import {
+ CreateAzureProviderLogStreamSchema,
+ SanitizedAzureProviderSchema,
+ UpdateAzureProviderLogStreamSchema
+} from "@app/ee/services/audit-log-stream/azure/azure-provider-schemas";
import {
CreateCustomProviderLogStreamSchema,
SanitizedCustomProviderSchema,
@@ -21,6 +26,15 @@ export * from "./audit-log-stream-router";
export const AUDIT_LOG_STREAM_REGISTER_ROUTER_MAP: Record<LogProvider, (server: FastifyZodProvider) => Promise<void>> =
{
+ [LogProvider.Azure]: async (server: FastifyZodProvider) => {
+ registerAuditLogStreamEndpoints({
+ server,
+ provider: LogProvider.Azure,
+ sanitizedResponseSchema: SanitizedAzureProviderSchema,
+ createSchema: CreateAzureProviderLogStreamSchema,
+ updateSchema: UpdateAzureProviderLogStreamSchema
+ });
+ },
[LogProvider.Custom]: async (server: FastifyZodProvider) => {
registerAuditLogStreamEndpoints({
server,
diff --git a/backend/src/ee/services/audit-log-stream/audit-log-stream-enums.ts b/backend/src/ee/services/audit-log-stream/audit-log-stream-enums.ts
index 9c03dc2bdb..b23a528a7e 100644
--- a/backend/src/ee/services/audit-log-stream/audit-log-stream-enums.ts
+++ b/backend/src/ee/services/audit-log-stream/audit-log-stream-enums.ts
@@ -1,4 +1,5 @@
export enum LogProvider {
+ Azure = "azure",
Datadog = "datadog",
Splunk = "splunk",
Custom = "custom"
diff --git a/backend/src/ee/services/audit-log-stream/audit-log-stream-factory.ts b/backend/src/ee/services/audit-log-stream/audit-log-stream-factory.ts
index f70dc02a0a..4dea122d8c 100644
--- a/backend/src/ee/services/audit-log-stream/audit-log-stream-factory.ts
+++ b/backend/src/ee/services/audit-log-stream/audit-log-stream-factory.ts
@@ -1,5 +1,6 @@
import { LogProvider } from "./audit-log-stream-enums";
import { TAuditLogStreamCredentials, TLogStreamFactory } from "./audit-log-stream-types";
+import { AzureProviderFactory } from "./azure/azure-provider-factory";
import { CustomProviderFactory } from "./custom/custom-provider-factory";
import { DatadogProviderFactory } from "./datadog/datadog-provider-factory";
import { SplunkProviderFactory } from "./splunk/splunk-provider-factory";
@@ -7,6 +8,7 @@ import { SplunkProviderFactory } from "./splunk/splunk-provider-factory";
type TLogStreamFactoryImplementation = TLogStreamFactory<TAuditLogStreamCredentials>;
export const LOG_STREAM_FACTORY_MAP: Record<LogProvider, TLogStreamFactoryImplementation> = {
+ [LogProvider.Azure]: AzureProviderFactory as TLogStreamFactoryImplementation,
[LogProvider.Datadog]: DatadogProviderFactory as TLogStreamFactoryImplementation,
[LogProvider.Splunk]: SplunkProviderFactory as TLogStreamFactoryImplementation,
[LogProvider.Custom]: CustomProviderFactory as TLogStreamFactoryImplementation
diff --git a/backend/src/ee/services/audit-log-stream/audit-log-stream-fns.ts b/backend/src/ee/services/audit-log-stream/audit-log-stream-fns.ts
index 87a7736a34..4261bb146d 100644
--- a/backend/src/ee/services/audit-log-stream/audit-log-stream-fns.ts
+++ b/backend/src/ee/services/audit-log-stream/audit-log-stream-fns.ts
@@ -3,14 +3,18 @@ import { TKmsServiceFactory } from "@app/services/kms/kms-service";
import { KmsDataKey } from "@app/services/kms/kms-types";
import { TAuditLogStream, TAuditLogStreamCredentials } from "./audit-log-stream-types";
+import { getAzureProviderListItem } from "./azure/azure-provider-fns";
import { getCustomProviderListItem } from "./custom/custom-provider-fns";
import { getDatadogProviderListItem } from "./datadog/datadog-provider-fns";
import { getSplunkProviderListItem } from "./splunk/splunk-provider-fns";
export const listProviderOptions = () => {
- return [getDatadogProviderListItem(), getSplunkProviderListItem(), getCustomProviderListItem()].sort((a, b) =>
- a.name.localeCompare(b.name)
- );
+ return [
+ getDatadogProviderListItem(),
+ getSplunkProviderListItem(),
+ getCustomProviderListItem(),
+ getAzureProviderListItem()
+ ].sort((a, b) => a.name.localeCompare(b.name));
};
export const encryptLogStreamCredentials = async ({
diff --git a/backend/src/ee/services/audit-log-stream/audit-log-stream-types.ts b/backend/src/ee/services/audit-log-stream/audit-log-stream-types.ts
index d0f78f632d..d3f2e0a9eb 100644
--- a/backend/src/ee/services/audit-log-stream/audit-log-stream-types.ts
+++ b/backend/src/ee/services/audit-log-stream/audit-log-stream-types.ts
@@ -1,16 +1,18 @@
import { TAuditLogs } from "@app/db/schemas";
import { LogProvider } from "./audit-log-stream-enums";
+import { TAzureProvider, TAzureProviderCredentials } from "./azure/azure-provider-types";
import { TCustomProvider, TCustomProviderCredentials } from "./custom/custom-provider-types";
import { TDatadogProvider, TDatadogProviderCredentials } from "./datadog/datadog-provider-types";
import { TSplunkProvider, TSplunkProviderCredentials } from "./splunk/splunk-provider-types";
-export type TAuditLogStream = TDatadogProvider | TSplunkProvider | TCustomProvider;
+export type TAuditLogStream = TDatadogProvider | TSplunkProvider | TCustomProvider | TAzureProvider;
export type TAuditLogStreamCredentials =
| TDatadogProviderCredentials
| TSplunkProviderCredentials
- | TCustomProviderCredentials;
+ | TCustomProviderCredentials
+ | TAzureProviderCredentials;
export type TCreateAuditLogStreamDTO = {
provider: LogProvider;
diff --git a/backend/src/ee/services/audit-log-stream/azure/azure-provider-factory.ts b/backend/src/ee/services/audit-log-stream/azure/azure-provider-factory.ts
new file mode 100644
index 0000000000..9a6157666b
--- /dev/null
+++ b/backend/src/ee/services/audit-log-stream/azure/azure-provider-factory.ts
@@ -0,0 +1,98 @@
+import { RawAxiosRequestHeaders } from "axios";
+
+import { request } from "@app/lib/config/request";
+import { BadRequestError } from "@app/lib/errors";
+import { blockLocalAndPrivateIpAddresses } from "@app/lib/validator";
+
+import { AUDIT_LOG_STREAM_TIMEOUT } from "../../audit-log/audit-log-queue";
+import { TLogStreamFactoryStreamLog, TLogStreamFactoryValidateCredentials } from "../audit-log-stream-types";
+import { TAzureProviderCredentials } from "./azure-provider-types";
+
+function createPayload(event: { createdAt?: Date | string } & Record<string, unknown>) {
+ return [
+ {
+ ...event,
+ TimeGenerated: (event.createdAt ? new Date(event.createdAt) : new Date()).toISOString()
+ }
+ ];
+}
+
+async function getAzureToken(tenantId: string, clientId: string, clientSecret: string) {
+ const { data } = await request.post<{ access_token: string }>(
+ `https://login.microsoftonline.com/${tenantId}/oauth2/v2.0/token`,
+ new URLSearchParams({
+ grant_type: "client_credentials",
+ client_id: clientId,
+ client_secret: clientSecret,
+ scope: "https://monitor.azure.com/.default"
+ }),
+ {
+ headers: {
+ "Content-Type": "application/x-www-form-urlencoded"
+ }
+ }
+ );
+
+ return data.access_token;
+}
+
+export const AzureProviderFactory = () => {
+ const validateCredentials: TLogStreamFactoryValidateCredentials<TAzureProviderCredentials> = async ({
+ credentials
+ }) => {
+ const { tenantId, clientId, clientSecret, dceUrl, dcrId, cltName } = credentials;
+
+ await blockLocalAndPrivateIpAddresses(dceUrl);
+
+ const token = await getAzureToken(tenantId, clientId, clientSecret);
+
+ const streamHeaders: RawAxiosRequestHeaders = {
+ "Content-Type": "application/json",
+ Authorization: `Bearer ${token}`
+ };
+
+ await request
+ .post(
+ `${dceUrl}/dataCollectionRules/${dcrId}/streams/Custom-${cltName}_CL?api-version=2023-01-01`,
+ createPayload({ ping: "ok" }),
+ {
+ headers: streamHeaders,
+ timeout: AUDIT_LOG_STREAM_TIMEOUT,
+ signal: AbortSignal.timeout(AUDIT_LOG_STREAM_TIMEOUT)
+ }
+ )
+ .catch((err) => {
+ throw new BadRequestError({ message: `Failed to connect with Azure: ${(err as Error)?.message}` });
+ });
+
+ return credentials;
+ };
+
+ const streamLog: TLogStreamFactoryStreamLog<TAzureProviderCredentials> = async ({ credentials, auditLog }) => {
+ const { tenantId, clientId, clientSecret, dceUrl, dcrId, cltName } = credentials;
+
+ await blockLocalAndPrivateIpAddresses(dceUrl);
+
+ const token = await getAzureToken(tenantId, clientId, clientSecret);
+
+ const streamHeaders: RawAxiosRequestHeaders = {
+ "Content-Type": "application/json",
+ Authorization: `Bearer ${token}`
+ };
+
+ await request.post(
+ `${dceUrl}/dataCollectionRules/${dcrId}/streams/Custom-${cltName}_CL?api-version=2023-01-01`,
+ createPayload(auditLog),
+ {
+ headers: streamHeaders,
+ timeout: AUDIT_LOG_STREAM_TIMEOUT,
+ signal: AbortSignal.timeout(AUDIT_LOG_STREAM_TIMEOUT)
+ }
+ );
+ };
+
+ return {
+ validateCredentials,
+ streamLog
+ };
+};
diff --git a/backend/src/ee/services/audit-log-stream/azure/azure-provider-fns.ts b/backend/src/ee/services/audit-log-stream/azure/azure-provider-fns.ts
new file mode 100644
index 0000000000..e558b69e25
--- /dev/null
+++ b/backend/src/ee/services/audit-log-stream/azure/azure-provider-fns.ts
@@ -0,0 +1,8 @@
+import { LogProvider } from "../audit-log-stream-enums";
+
+export const getAzureProviderListItem = () => {
+ return {
+ name: "Azure" as const,
+ provider: LogProvider.Azure as const
+ };
+};
diff --git a/backend/src/ee/services/audit-log-stream/azure/azure-provider-schemas.ts b/backend/src/ee/services/audit-log-stream/azure/azure-provider-schemas.ts
new file mode 100644
index 0000000000..50def1d790
--- /dev/null
+++ b/backend/src/ee/services/audit-log-stream/azure/azure-provider-schemas.ts
@@ -0,0 +1,52 @@
+import RE2 from "re2";
+import { z } from "zod";
+
+import { LogProvider } from "../audit-log-stream-enums";
+import { BaseProviderSchema } from "../audit-log-stream-schemas";
+
+export const AzureProviderCredentialsSchema = z.object({
+ tenantId: z.string().trim().uuid(),
+ clientId: z.string().trim().uuid(),
+ clientSecret: z.string().trim().length(40),
+
+ // Data Collection Endpoint URL
+ dceUrl: z.string().trim().url().min(1).max(255),
+
+ // Data Collection Rule Immutable ID
+ dcrId: z
+ .string()
+ .trim()
+ .refine((val) => new RE2(/^dcr-[0-9a-f]{32}$/).test(val), "DCR ID must be in dcr-*** format"),
+
+ // Custom Log Table Name
+ cltName: z.string().trim().min(1).max(255)
+});
+
+const BaseAzureProviderSchema = BaseProviderSchema.extend({ provider: z.literal(LogProvider.Azure) });
+
+export const AzureProviderSchema = BaseAzureProviderSchema.extend({
+ credentials: AzureProviderCredentialsSchema
+});
+
+export const SanitizedAzureProviderSchema = BaseAzureProviderSchema.extend({
+ credentials: AzureProviderCredentialsSchema.pick({
+ tenantId: true,
+ clientId: true,
+ dceUrl: true,
+ dcrId: true,
+ cltName: true
+ })
+});
+
+export const AzureProviderListItemSchema = z.object({
+ name: z.literal("Azure"),
+ provider: z.literal(LogProvider.Azure)
+});
+
+export const CreateAzureProviderLogStreamSchema = z.object({
+ credentials: AzureProviderCredentialsSchema
+});
+
+export const UpdateAzureProviderLogStreamSchema = z.object({
+ credentials: AzureProviderCredentialsSchema
+});
diff --git a/backend/src/ee/services/audit-log-stream/azure/azure-provider-types.ts b/backend/src/ee/services/audit-log-stream/azure/azure-provider-types.ts
new file mode 100644
index 0000000000..0ba5f120d9
--- /dev/null
+++ b/backend/src/ee/services/audit-log-stream/azure/azure-provider-types.ts
@@ -0,0 +1,7 @@
+import { z } from "zod";
+
+import { AzureProviderCredentialsSchema, AzureProviderSchema } from "./azure-provider-schemas";
+
+export type TAzureProvider = z.infer<typeof AzureProviderSchema>;
+
+export type TAzureProviderCredentials = z.infer<typeof AzureProviderCredentialsSchema>;
diff --git a/backend/src/keystore/keystore.ts b/backend/src/keystore/keystore.ts
index 45589e529e..a6135e0ca9 100644
--- a/backend/src/keystore/keystore.ts
+++ b/backend/src/keystore/keystore.ts
@@ -1,9 +1,10 @@
+import { Cluster, Redis } from "ioredis";
+
import { buildRedisFromConfig, TRedisConfigKeys } from "@app/lib/config/redis";
import { pgAdvisoryLockHashText } from "@app/lib/crypto/hashtext";
import { applyJitter } from "@app/lib/dates";
import { delay as delayMs } from "@app/lib/delay";
import { ExecutionResult, Redlock, Settings } from "@app/lib/red-lock";
-import { Redis, Cluster } from "ioredis";
export const PgSqlLock = {
BootUpMigration: 2023,
diff --git a/docs/documentation/platform/audit-log-streams/audit-log-streams.mdx b/docs/documentation/platform/audit-log-streams/audit-log-streams.mdx
index fab5f16b7e..0a3a414583 100644
--- a/docs/documentation/platform/audit-log-streams/audit-log-streams.mdx
+++ b/docs/documentation/platform/audit-log-streams/audit-log-streams.mdx
@@ -45,6 +45,116 @@ Infisical Audit Log Streaming enables you to transmit your organization's audit
## Example Providers
<AccordionGroup>
+ <Accordion title="Azure">
+ Infisical offers a dedicated **Azure** provider to stream your audit logs, enabling seamless integration with services like Microsoft Sentinel.
+
+ <Warning>
+ After setting up all Azure resources, it may take 10-20 minutes for logs to begin streaming.
+ </Warning>
+
+ <Steps>
+ <Step title="Create a Data Collection Endpoint">
+ Navigate to [Data Collection Endpoints](https://portal.azure.com/#view/HubsExtension/BrowseResource.ReactView/resourceType/microsoft.insights%2Fdatacollectionendpoints) and click **Create**.
+
+ ![azure create dce](/images/platform/audit-log-streams/azure-create-dce.png)
+
+ Configure your Data Collection Endpoint by providing an **Endpoint Name**, **Subscription**, and a **Resource group**. Then click **Review + Create**.
+
+ ![azure configure dce](/images/platform/audit-log-streams/azure-configure-dce.png)
+
+ After creation, it may take a few minutes for the Data Collection Endpoint to appear. Once visible, click on it and copy the **Logs Ingestion** URL. You will need this URL in later steps.
+
+ ![azure dce url](/images/platform/audit-log-streams/azure-dce-url.png)
+ </Step>
+ <Step title="Create a Log Analytics Workspace">
+ <Info>
+ If you already have a Log Analytics Workspace, you may skip this step.
+ </Info>
+
+ Navigate to [Log Analytics Workspaces](https://portal.azure.com/#browse/Microsoft.OperationalInsights%2Fworkspaces) and click **Create**.
+
+ ![azure create law](/images/platform/audit-log-streams/azure-create-law.png)
+
+ Configure your Log Analytics Workspace by providing a **Subscription**, **Resource group**, and a **Name**. Then click **Review + Create**.
+
+ ![azure configure law](/images/platform/audit-log-streams/azure-configure-law.png)
+
+ Once the workspace is deployed, click **Go to resource** to access it.
+
+ ![azure go to resource](/images/platform/audit-log-streams/azure-go-to-resource.png)
+ </Step>
+ <Step title="Create a Custom Log Table">
+ Within your Log Analytics Workspace, navigate to **Tables** and click **Create**. Select **New custom log (DCR-based)** from the dropdown.
+
+ ![azure new table](/images/platform/audit-log-streams/azure-new-table.png)
+
+ Configure the Custom Log Table: Provide a **Table name** (e.g., `InfisicalLogs`), select the **Data collection endpoint** created in Step 1, and create a new **Data collection rule** as illustrated in the image below. Then, click **Next**.
+
+ ![azure configure table](/images/platform/audit-log-streams/azure-configure-table.png)
+
+ On the **Schema and transformation** page, you'll be prompted to upload a **Log Sample**. Create a `.json` file with the following content and upload it:
+
+ ```json
+ {
+ "id": "00000000-0000-0000-0000-000000000000",
+ "actor": "user",
+ "actorMetadata": {
+ "email": "[email protected]",
+ "userId": "00000000-0000-0000-0000-000000000000",
+ "username": "[email protected]"
+ },
+ "ipAddress": "0.0.0.0",
+ "userAgent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/139.0.0.0 Safari/537.36",
+ "userAgentType": "web",
+ "eventType": "get-secrets",
+ "eventMetadata": {},
+ "projectName": "MyProject",
+ "orgId": "00000000-0000-0000-0000-000000000000",
+ "projectId": "00000000-0000-0000-0000-000000000000",
+ "TimeGenerated": "2025-01-01T00:00:00.000Z"
+ }
+ ```
+
+ Optionally, you can add **Transformations** to further destructure the data. For example, to extract actor email and userId:
+
+ ```
+ source
+ | extend
+ ActorEmail = tostring(actorMetadata.email),
+ ActorUserId = tostring(actorMetadata.userId)
+ ```
+
+ On the final step, click **Create**.
+
+ <Warning>
+ It may take a few minutes for your Custom Log Table to be created and appear under Tables.
+ </Warning>
+ </Step>
+ <Step title="Obtain Data Collection Rule Immutable ID">
+ After creating your Data Collection Rule, you'll need its **Immutable ID**.
+
+ Navigate to [Data collection rules](https://portal.azure.com/#view/HubsExtension/BrowseResource.ReactView/resourceType/microsoft.insights%2Fdatacollectionrules). Click on your newly created DCR and copy its **Immutable ID** for the next step.
+
+ ![azure dcr](/images/platform/audit-log-streams/azure-dcr.png)
+ </Step>
+ <Step title="Create Audit Log Stream on Infisical">
+ In Infisical, create a new audit log stream and select the **Azure** provider. Input the following details:
+
+ - **Tenant ID**: Your Tenant ID
+ - **Client ID**: The Client ID of an App Registration
+ - **Client Secret**: The Client Secret of an App Registration
+ - **Data Collection Endpoint URL**: Obtained from Step 1
+ - **Data Collection Rule Immutable ID**: Obtained from Step 4
+ - **Custom Log Table Name**: Defined in Step 3
+
+ ![azure create als](/images/platform/audit-log-streams/azure-create-als.png)
+
+ <Warning>
+ The App Registration used for authentication must have the **Monitoring Metrics Publisher** role assigned on the **Data Collection Rule** created in Step 3. [See Microsoft Guide](https://learn.microsoft.com/en-us/azure/azure-monitor/logs/tutorial-logs-ingestion-portal#assign-permissions-to-the-dcr).
+ </Warning>
+ </Step>
+ </Steps>
+ </Accordion>
<Accordion title="Better Stack">
You can stream to Better Stack using a **Custom** log stream.
diff --git a/docs/images/platform/audit-log-streams/azure-configure-dce.png b/docs/images/platform/audit-log-streams/azure-configure-dce.png
new file mode 100644
index 0000000000..b0b32f0b21
Binary files /dev/null and b/docs/images/platform/audit-log-streams/azure-configure-dce.png differ
diff --git a/docs/images/platform/audit-log-streams/azure-configure-law.png b/docs/images/platform/audit-log-streams/azure-configure-law.png
new file mode 100644
index 0000000000..11ec8d86f5
Binary files /dev/null and b/docs/images/platform/audit-log-streams/azure-configure-law.png differ
diff --git a/docs/images/platform/audit-log-streams/azure-configure-table.png b/docs/images/platform/audit-log-streams/azure-configure-table.png
new file mode 100644
index 0000000000..7dba237b9f
Binary files /dev/null and b/docs/images/platform/audit-log-streams/azure-configure-table.png differ
diff --git a/docs/images/platform/audit-log-streams/azure-create-als.png b/docs/images/platform/audit-log-streams/azure-create-als.png
new file mode 100644
index 0000000000..bdfb2f8d6c
Binary files /dev/null and b/docs/images/platform/audit-log-streams/azure-create-als.png differ
diff --git a/docs/images/platform/audit-log-streams/azure-create-dce.png b/docs/images/platform/audit-log-streams/azure-create-dce.png
new file mode 100644
index 0000000000..00a546c308
Binary files /dev/null and b/docs/images/platform/audit-log-streams/azure-create-dce.png differ
diff --git a/docs/images/platform/audit-log-streams/azure-create-law.png b/docs/images/platform/audit-log-streams/azure-create-law.png
new file mode 100644
index 0000000000..1150f64ffc
Binary files /dev/null and b/docs/images/platform/audit-log-streams/azure-create-law.png differ
diff --git a/docs/images/platform/audit-log-streams/azure-dce-url.png b/docs/images/platform/audit-log-streams/azure-dce-url.png
new file mode 100644
index 0000000000..d8c1dc96dc
Binary files /dev/null and b/docs/images/platform/audit-log-streams/azure-dce-url.png differ
diff --git a/docs/images/platform/audit-log-streams/azure-dcr.png b/docs/images/platform/audit-log-streams/azure-dcr.png
new file mode 100644
index 0000000000..441808947d
Binary files /dev/null and b/docs/images/platform/audit-log-streams/azure-dcr.png differ
diff --git a/docs/images/platform/audit-log-streams/azure-go-to-resource.png b/docs/images/platform/audit-log-streams/azure-go-to-resource.png
new file mode 100644
index 0000000000..ef197517dc
Binary files /dev/null and b/docs/images/platform/audit-log-streams/azure-go-to-resource.png differ
diff --git a/docs/images/platform/audit-log-streams/azure-new-table.png b/docs/images/platform/audit-log-streams/azure-new-table.png
new file mode 100644
index 0000000000..829af3e53e
Binary files /dev/null and b/docs/images/platform/audit-log-streams/azure-new-table.png differ
diff --git a/frontend/src/helpers/auditLogStreams.ts b/frontend/src/helpers/auditLogStreams.ts
index 00d2b9e510..b426ada1ca 100644
--- a/frontend/src/helpers/auditLogStreams.ts
+++ b/frontend/src/helpers/auditLogStreams.ts
@@ -8,6 +8,7 @@ export const AUDIT_LOG_STREAM_PROVIDER_MAP: Record<
LogProvider,
{ name: string; image?: string; icon?: IconDefinition; size?: number }
> = {
+ [LogProvider.Azure]: { name: "Azure", image: "Microsoft Azure.png", size: 60 },
[LogProvider.Custom]: { name: "Custom", icon: faCode },
[LogProvider.Datadog]: { name: "Datadog", image: "Datadog.png" },
[LogProvider.Splunk]: { name: "Splunk", image: "Splunk.png", size: 65 }
@@ -19,11 +20,12 @@ export function getProviderUrl(
) {
switch (logStream.provider) {
case LogProvider.Custom:
- return logStream.credentials.url;
case LogProvider.Datadog:
return logStream.credentials.url;
case LogProvider.Splunk:
return `https://${logStream.credentials.hostname}:8088/services/collector/event`;
+ case LogProvider.Azure:
+ return `${logStream.credentials.dceUrl}/dataCollectionRules/${logStream.credentials.dcrId}/streams/Custom-${logStream.credentials.cltName}_CL`;
default:
throw new Error(
`Unhandled provider in getProviderUrl: ${(logStream as TAuditLogStream).provider}`
diff --git a/frontend/src/hooks/api/auditLogStreams/enums.ts b/frontend/src/hooks/api/auditLogStreams/enums.ts
index 9c03dc2bdb..b23a528a7e 100644
--- a/frontend/src/hooks/api/auditLogStreams/enums.ts
+++ b/frontend/src/hooks/api/auditLogStreams/enums.ts
@@ -1,4 +1,5 @@
export enum LogProvider {
+ Azure = "azure",
Datadog = "datadog",
Splunk = "splunk",
Custom = "custom"
diff --git a/frontend/src/hooks/api/auditLogStreams/types/index.ts b/frontend/src/hooks/api/auditLogStreams/types/index.ts
index d3dffe6a91..d007785cde 100644
--- a/frontend/src/hooks/api/auditLogStreams/types/index.ts
+++ b/frontend/src/hooks/api/auditLogStreams/types/index.ts
@@ -1,4 +1,5 @@
import { LogProvider } from "../enums";
+import { TAzureProviderLogStream } from "./providers/azure-provider";
import { TCustomProviderLogStream } from "./providers/custom-provider";
import { TDatadogProviderLogStream } from "./providers/datadog-provider";
import { TSplunkProviderLogStream } from "./providers/splunk-provider";
@@ -6,9 +7,11 @@ import { TSplunkProviderLogStream } from "./providers/splunk-provider";
export type TAuditLogStream =
| TCustomProviderLogStream
| TDatadogProviderLogStream
- | TSplunkProviderLogStream;
+ | TSplunkProviderLogStream
+ | TAzureProviderLogStream;
export type TAuditLogStreamProviderMap = {
+ [LogProvider.Azure]: TAzureProviderLogStream;
[LogProvider.Custom]: TCustomProviderLogStream;
[LogProvider.Datadog]: TDatadogProviderLogStream;
[LogProvider.Splunk]: TSplunkProviderLogStream;
diff --git a/frontend/src/hooks/api/auditLogStreams/types/providers/azure-provider.ts b/frontend/src/hooks/api/auditLogStreams/types/providers/azure-provider.ts
new file mode 100644
index 0000000000..3086fd7cca
--- /dev/null
+++ b/frontend/src/hooks/api/auditLogStreams/types/providers/azure-provider.ts
@@ -0,0 +1,14 @@
+import { LogProvider } from "../../enums";
+import { TRootProviderLogStream } from "./root-provider";
+
+export type TAzureProviderLogStream = TRootProviderLogStream & {
+ provider: LogProvider.Azure;
+ credentials: {
+ tenantId: string;
+ clientId: string;
+ clientSecret: string;
+ dceUrl: string;
+ dcrId: string;
+ cltName: string;
+ };
+};
diff --git a/frontend/src/pages/organization/SettingsPage/components/AuditLogStreamTab/AuditLogStreamForm/AuditLogStreamForm.tsx b/frontend/src/pages/organization/SettingsPage/components/AuditLogStreamTab/AuditLogStreamForm/AuditLogStreamForm.tsx
index 1af5e8d1ae..7ba2f2eaab 100644
--- a/frontend/src/pages/organization/SettingsPage/components/AuditLogStreamTab/AuditLogStreamForm/AuditLogStreamForm.tsx
+++ b/frontend/src/pages/organization/SettingsPage/components/AuditLogStreamTab/AuditLogStreamForm/AuditLogStreamForm.tsx
@@ -6,6 +6,7 @@ import { TAuditLogStream } from "@app/hooks/api/types";
import { DiscriminativePick } from "@app/types";
import { AuditLogStreamHeader } from "../components/AuditLogStreamHeader";
+import { AzureProviderAuditLogStreamForm } from "./AzureProviderAuditLogStreamForm";
import { CustomProviderAuditLogStreamForm } from "./CustomProviderAuditLogStreamForm";
import { DatadogProviderAuditLogStreamForm } from "./DatadogProviderAuditLogStreamForm";
import { SplunkProviderAuditLogStreamForm } from "./SplunkProviderAuditLogStreamForm";
@@ -44,6 +45,8 @@ const CreateForm = ({ provider, onComplete }: CreateFormProps) => {
};
switch (provider) {
+ case LogProvider.Azure:
+ return <AzureProviderAuditLogStreamForm onSubmit={onSubmit} />;
case LogProvider.Custom:
return <CustomProviderAuditLogStreamForm onSubmit={onSubmit} />;
case LogProvider.Datadog:
@@ -83,6 +86,10 @@ const UpdateForm = ({ auditLogStream, onComplete }: UpdateFormProps) => {
};
switch (auditLogStream.provider) {
+ case LogProvider.Azure:
+ return (
+ <AzureProviderAuditLogStreamForm onSubmit={onSubmit} auditLogStream={auditLogStream} />
+ );
case LogProvider.Custom:
return (
<CustomProviderAuditLogStreamForm onSubmit={onSubmit} auditLogStream={auditLogStream} />
diff --git a/frontend/src/pages/organization/SettingsPage/components/AuditLogStreamTab/AuditLogStreamForm/AzureProviderAuditLogStreamForm.tsx b/frontend/src/pages/organization/SettingsPage/components/AuditLogStreamTab/AuditLogStreamForm/AzureProviderAuditLogStreamForm.tsx
new file mode 100644
index 0000000000..131ea1c85a
--- /dev/null
+++ b/frontend/src/pages/organization/SettingsPage/components/AuditLogStreamTab/AuditLogStreamForm/AzureProviderAuditLogStreamForm.tsx
@@ -0,0 +1,158 @@
+import { Controller, FormProvider, useForm } from "react-hook-form";
+import { zodResolver } from "@hookform/resolvers/zod";
+import { z } from "zod";
+
+import { Button, FormControl, Input, ModalClose, SecretInput } from "@app/components/v2";
+import { LogProvider } from "@app/hooks/api/auditLogStreams/enums";
+import { TAzureProviderLogStream } from "@app/hooks/api/auditLogStreams/types/providers/azure-provider";
+
+type Props = {
+ auditLogStream?: TAzureProviderLogStream;
+ onSubmit: (formData: FormData) => void;
+};
+
+const formSchema = z.object({
+ provider: z.literal(LogProvider.Azure),
+ credentials: z.object({
+ tenantId: z.string().trim().uuid(),
+ clientId: z.string().trim().uuid(),
+ clientSecret: z.string().trim().length(40),
+ dceUrl: z.string().trim().url().min(1).max(255),
+ dcrId: z
+ .string()
+ .trim()
+ .regex(/^dcr-[0-9a-f]{32}$/, "DCR ID must be in dcr-*** format"),
+ cltName: z.string().trim().min(1).max(255)
+ })
+});
+
+type FormData = z.infer<typeof formSchema>;
+
+export const AzureProviderAuditLogStreamForm = ({ auditLogStream, onSubmit }: Props) => {
+ const isUpdate = Boolean(auditLogStream);
+
+ const form = useForm<FormData>({
+ resolver: zodResolver(formSchema),
+ defaultValues: auditLogStream ?? {
+ provider: LogProvider.Azure
+ }
+ });
+
+ const {
+ handleSubmit,
+ control,
+ formState: { isSubmitting, isDirty }
+ } = form;
+
+ return (
+ <FormProvider {...form}>
+ <form onSubmit={handleSubmit(onSubmit)}>
+ <Controller
+ name="credentials.tenantId"
+ control={control}
+ shouldUnregister
+ render={({ field, fieldState: { error } }) => (
+ <FormControl
+ errorText={error?.message}
+ isError={Boolean(error?.message)}
+ label="Tenant ID"
+ >
+ <Input {...field} placeholder="00000000-0000-0000-0000-000000000000" />
+ </FormControl>
+ )}
+ />
+ <Controller
+ name="credentials.clientId"
+ control={control}
+ shouldUnregister
+ render={({ field, fieldState: { error } }) => (
+ <FormControl
+ errorText={error?.message}
+ isError={Boolean(error?.message)}
+ label="Client ID"
+ >
+ <Input {...field} placeholder="00000000-0000-0000-0000-000000000000" />
+ </FormControl>
+ )}
+ />
+ <Controller
+ name="credentials.clientSecret"
+ control={control}
+ shouldUnregister
+ render={({ field: { value, onChange }, fieldState: { error } }) => (
+ <FormControl
+ errorText={error?.message}
+ isError={Boolean(error?.message)}
+ label="Client Secret"
+ >
+ <SecretInput
+ containerClassName="text-gray-400 group-focus-within:!border-primary-400/50 border border-mineshaft-500 bg-mineshaft-900 px-2.5 py-1.5"
+ value={value}
+ onChange={(e) => onChange(e.target.value)}
+ />
+ </FormControl>
+ )}
+ />
+ <Controller
+ name="credentials.dceUrl"
+ control={control}
+ shouldUnregister
+ render={({ field, fieldState: { error } }) => (
+ <FormControl
+ errorText={error?.message}
+ isError={Boolean(error?.message)}
+ label="Data Collection Endpoint URL"
+ >
+ <Input {...field} placeholder="https://example.eastus-1.ingest.monitor.azure.com" />
+ </FormControl>
+ )}
+ />
+ <Controller
+ name="credentials.dcrId"
+ control={control}
+ shouldUnregister
+ render={({ field, fieldState: { error } }) => (
+ <FormControl
+ errorText={error?.message}
+ isError={Boolean(error?.message)}
+ label="Data Collection Rule Immutable ID"
+ >
+ <Input {...field} placeholder="dcr-00000000000000000000000000000000" />
+ </FormControl>
+ )}
+ />
+ <Controller
+ name="credentials.cltName"
+ control={control}
+ shouldUnregister
+ render={({ field, fieldState: { error } }) => (
+ <FormControl
+ errorText={error?.message}
+ isError={Boolean(error?.message)}
+ label="Custom Log Table Name"
+ >
+ <Input {...field} placeholder="InfisicalLogs" />
+ </FormControl>
+ )}
+ />
+ <div className="mt-8 flex items-center">
+ <Button
+ className="mr-4"
+ size="sm"
+ type="submit"
+ colorSchema="secondary"
+ isLoading={isSubmitting}
+ isDisabled={isSubmitting || !isDirty}
+ >
+ {isUpdate ? "Update Credentials" : "Create Log Stream"}
+ </Button>
+ <ModalClose asChild>
+ <Button colorSchema="secondary" variant="plain">
+ Cancel
+ </Button>
+ </ModalClose>
+ </div>
+ </form>
+ </FormProvider>
+ );
+};