1. Packages
  2. Packages
  3. Azure Classic
  4. API Docs
  5. sentinel
  6. getAlertRule

We recommend using Azure Native.

Viewing docs for Azure v4.42.0 (Older version)
published on Monday, Mar 9, 2026 by Pulumi
azure logo

We recommend using Azure Native.

Viewing docs for Azure v4.42.0 (Older version)
published on Monday, Mar 9, 2026 by Pulumi

    Use this data source to access information about an existing Sentinel Alert Rule.

    Example Usage

    using Pulumi;
    using Azure = Pulumi.Azure;
    
    class MyStack : Stack
    {
        public MyStack()
        {
            var exampleAnalyticsWorkspace = Output.Create(Azure.OperationalInsights.GetAnalyticsWorkspace.InvokeAsync(new Azure.OperationalInsights.GetAnalyticsWorkspaceArgs
            {
                Name = "example",
                ResourceGroupName = "example-resources",
            }));
            var exampleAlertRule = exampleAnalyticsWorkspace.Apply(exampleAnalyticsWorkspace => Output.Create(Azure.Sentinel.GetAlertRule.InvokeAsync(new Azure.Sentinel.GetAlertRuleArgs
            {
                Name = "existing",
                LogAnalyticsWorkspaceId = exampleAnalyticsWorkspace.Id,
            })));
            this.Id = exampleAlertRule.Apply(exampleAlertRule => exampleAlertRule.Id);
        }
    
        [Output("id")]
        public Output<string> Id { get; set; }
    }
    
    package main
    
    import (
    	"github.com/pulumi/pulumi-azure/sdk/v4/go/azure/operationalinsights"
    	"github.com/pulumi/pulumi-azure/sdk/v4/go/azure/sentinel"
    	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    )
    
    func main() {
    	pulumi.Run(func(ctx *pulumi.Context) error {
    		exampleAnalyticsWorkspace, err := operationalinsights.LookupAnalyticsWorkspace(ctx, &operationalinsights.LookupAnalyticsWorkspaceArgs{
    			Name:              "example",
    			ResourceGroupName: "example-resources",
    		}, nil)
    		if err != nil {
    			return err
    		}
    		exampleAlertRule, err := sentinel.GetAlertRule(ctx, &sentinel.GetAlertRuleArgs{
    			Name:                    "existing",
    			LogAnalyticsWorkspaceId: exampleAnalyticsWorkspace.Id,
    		}, nil)
    		if err != nil {
    			return err
    		}
    		ctx.Export("id", exampleAlertRule.Id)
    		return nil
    	})
    }
    

    Example coming soon!

    import * as pulumi from "@pulumi/pulumi";
    import * as azure from "@pulumi/azure";
    
    const exampleAnalyticsWorkspace = azure.operationalinsights.getAnalyticsWorkspace({
        name: "example",
        resourceGroupName: "example-resources",
    });
    const exampleAlertRule = exampleAnalyticsWorkspace.then(exampleAnalyticsWorkspace => azure.sentinel.getAlertRule({
        name: "existing",
        logAnalyticsWorkspaceId: exampleAnalyticsWorkspace.id,
    }));
    export const id = exampleAlertRule.then(exampleAlertRule => exampleAlertRule.id);
    
    import pulumi
    import pulumi_azure as azure
    
    example_analytics_workspace = azure.operationalinsights.get_analytics_workspace(name="example",
        resource_group_name="example-resources")
    example_alert_rule = azure.sentinel.get_alert_rule(name="existing",
        log_analytics_workspace_id=example_analytics_workspace.id)
    pulumi.export("id", example_alert_rule.id)
    

    Example coming soon!

    Using getAlertRule

    Two invocation forms are available. The direct form accepts plain arguments and either blocks until the result value is available, or returns a Promise-wrapped result. The output form accepts Input-wrapped arguments and returns an Output-wrapped result.

    function getAlertRule(args: GetAlertRuleArgs, opts?: InvokeOptions): Promise<GetAlertRuleResult>
    function getAlertRuleOutput(args: GetAlertRuleOutputArgs, opts?: InvokeOptions): Output<GetAlertRuleResult>
    def get_alert_rule(log_analytics_workspace_id: Optional[str] = None,
                       name: Optional[str] = None,
                       opts: Optional[InvokeOptions] = None) -> GetAlertRuleResult
    def get_alert_rule_output(log_analytics_workspace_id: Optional[pulumi.Input[str]] = None,
                       name: Optional[pulumi.Input[str]] = None,
                       opts: Optional[InvokeOptions] = None) -> Output[GetAlertRuleResult]
    func GetAlertRule(ctx *Context, args *GetAlertRuleArgs, opts ...InvokeOption) (*GetAlertRuleResult, error)
    func GetAlertRuleOutput(ctx *Context, args *GetAlertRuleOutputArgs, opts ...InvokeOption) GetAlertRuleResultOutput

    > Note: This function is named GetAlertRule in the Go SDK.

    public static class GetAlertRule 
    {
        public static Task<GetAlertRuleResult> InvokeAsync(GetAlertRuleArgs args, InvokeOptions? opts = null)
        public static Output<GetAlertRuleResult> Invoke(GetAlertRuleInvokeArgs args, InvokeOptions? opts = null)
    }
    public static CompletableFuture<GetAlertRuleResult> getAlertRule(GetAlertRuleArgs args, InvokeOptions options)
    public static Output<GetAlertRuleResult> getAlertRule(GetAlertRuleArgs args, InvokeOptions options)
    
    fn::invoke:
      function: azure:sentinel/getAlertRule:getAlertRule
      arguments:
        # arguments dictionary

    The following arguments are supported:

    LogAnalyticsWorkspaceId string
    The ID of the Log Analytics Workspace this Sentinel Alert Rule belongs to.
    Name string
    The name which should be used for this Sentinel Alert Rule.
    LogAnalyticsWorkspaceId string
    The ID of the Log Analytics Workspace this Sentinel Alert Rule belongs to.
    Name string
    The name which should be used for this Sentinel Alert Rule.
    logAnalyticsWorkspaceId String
    The ID of the Log Analytics Workspace this Sentinel Alert Rule belongs to.
    name String
    The name which should be used for this Sentinel Alert Rule.
    logAnalyticsWorkspaceId string
    The ID of the Log Analytics Workspace this Sentinel Alert Rule belongs to.
    name string
    The name which should be used for this Sentinel Alert Rule.
    log_analytics_workspace_id str
    The ID of the Log Analytics Workspace this Sentinel Alert Rule belongs to.
    name str
    The name which should be used for this Sentinel Alert Rule.
    logAnalyticsWorkspaceId String
    The ID of the Log Analytics Workspace this Sentinel Alert Rule belongs to.
    name String
    The name which should be used for this Sentinel Alert Rule.

    getAlertRule Result

    The following output properties are available:

    Id string
    The provider-assigned unique ID for this managed resource.
    LogAnalyticsWorkspaceId string
    Name string
    Id string
    The provider-assigned unique ID for this managed resource.
    LogAnalyticsWorkspaceId string
    Name string
    id String
    The provider-assigned unique ID for this managed resource.
    logAnalyticsWorkspaceId String
    name String
    id string
    The provider-assigned unique ID for this managed resource.
    logAnalyticsWorkspaceId string
    name string
    id str
    The provider-assigned unique ID for this managed resource.
    log_analytics_workspace_id str
    name str
    id String
    The provider-assigned unique ID for this managed resource.
    logAnalyticsWorkspaceId String
    name String

    Package Details

    Repository
    Azure Classic pulumi/pulumi-azure
    License
    Apache-2.0
    Notes
    This Pulumi package is based on the azurerm Terraform Provider.
    azure logo

    We recommend using Azure Native.

    Viewing docs for Azure v4.42.0 (Older version)
    published on Monday, Mar 9, 2026 by Pulumi
      Try Pulumi Cloud free. Your team will thank you.