azure logo
Azure Classic v5.38.0, Mar 21 23

azure.appinsights.ApiKey

Manages an Application Insights API key.

Example Usage

using System.Collections.Generic;
using Pulumi;
using Azure = Pulumi.Azure;

return await Deployment.RunAsync(() => 
{
    var exampleResourceGroup = new Azure.Core.ResourceGroup("exampleResourceGroup", new()
    {
        Location = "West Europe",
    });

    var exampleInsights = new Azure.AppInsights.Insights("exampleInsights", new()
    {
        Location = exampleResourceGroup.Location,
        ResourceGroupName = exampleResourceGroup.Name,
        ApplicationType = "web",
    });

    var readTelemetry = new Azure.AppInsights.ApiKey("readTelemetry", new()
    {
        ApplicationInsightsId = exampleInsights.Id,
        ReadPermissions = new[]
        {
            "aggregate",
            "api",
            "draft",
            "extendqueries",
            "search",
        },
    });

    var writeAnnotations = new Azure.AppInsights.ApiKey("writeAnnotations", new()
    {
        ApplicationInsightsId = exampleInsights.Id,
        WritePermissions = new[]
        {
            "annotations",
        },
    });

    var authenticateSdkControlChannelApiKey = new Azure.AppInsights.ApiKey("authenticateSdkControlChannelApiKey", new()
    {
        ApplicationInsightsId = exampleInsights.Id,
        ReadPermissions = new[]
        {
            "agentconfig",
        },
    });

    var fullPermissions = new Azure.AppInsights.ApiKey("fullPermissions", new()
    {
        ApplicationInsightsId = exampleInsights.Id,
        ReadPermissions = new[]
        {
            "agentconfig",
            "aggregate",
            "api",
            "draft",
            "extendqueries",
            "search",
        },
        WritePermissions = new[]
        {
            "annotations",
        },
    });

    return new Dictionary<string, object?>
    {
        ["readTelemetryApiKey"] = readTelemetry.ApiKey,
        ["writeAnnotationsApiKey"] = writeAnnotations.ApiKey,
        ["authenticateSdkControlChannel"] = authenticateSdkControlChannelApiKey.ApiKey,
        ["fullPermissionsApiKey"] = fullPermissions.ApiKey,
    };
});
package main

import (
	"github.com/pulumi/pulumi-azure/sdk/v5/go/azure/appinsights"
	"github.com/pulumi/pulumi-azure/sdk/v5/go/azure/core"
	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)

func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		exampleResourceGroup, err := core.NewResourceGroup(ctx, "exampleResourceGroup", &core.ResourceGroupArgs{
			Location: pulumi.String("West Europe"),
		})
		if err != nil {
			return err
		}
		exampleInsights, err := appinsights.NewInsights(ctx, "exampleInsights", &appinsights.InsightsArgs{
			Location:          exampleResourceGroup.Location,
			ResourceGroupName: exampleResourceGroup.Name,
			ApplicationType:   pulumi.String("web"),
		})
		if err != nil {
			return err
		}
		readTelemetry, err := appinsights.NewApiKey(ctx, "readTelemetry", &appinsights.ApiKeyArgs{
			ApplicationInsightsId: exampleInsights.ID(),
			ReadPermissions: pulumi.StringArray{
				pulumi.String("aggregate"),
				pulumi.String("api"),
				pulumi.String("draft"),
				pulumi.String("extendqueries"),
				pulumi.String("search"),
			},
		})
		if err != nil {
			return err
		}
		writeAnnotations, err := appinsights.NewApiKey(ctx, "writeAnnotations", &appinsights.ApiKeyArgs{
			ApplicationInsightsId: exampleInsights.ID(),
			WritePermissions: pulumi.StringArray{
				pulumi.String("annotations"),
			},
		})
		if err != nil {
			return err
		}
		authenticateSdkControlChannelApiKey, err := appinsights.NewApiKey(ctx, "authenticateSdkControlChannelApiKey", &appinsights.ApiKeyArgs{
			ApplicationInsightsId: exampleInsights.ID(),
			ReadPermissions: pulumi.StringArray{
				pulumi.String("agentconfig"),
			},
		})
		if err != nil {
			return err
		}
		fullPermissions, err := appinsights.NewApiKey(ctx, "fullPermissions", &appinsights.ApiKeyArgs{
			ApplicationInsightsId: exampleInsights.ID(),
			ReadPermissions: pulumi.StringArray{
				pulumi.String("agentconfig"),
				pulumi.String("aggregate"),
				pulumi.String("api"),
				pulumi.String("draft"),
				pulumi.String("extendqueries"),
				pulumi.String("search"),
			},
			WritePermissions: pulumi.StringArray{
				pulumi.String("annotations"),
			},
		})
		if err != nil {
			return err
		}
		ctx.Export("readTelemetryApiKey", readTelemetry.ApiKey)
		ctx.Export("writeAnnotationsApiKey", writeAnnotations.ApiKey)
		ctx.Export("authenticateSdkControlChannel", authenticateSdkControlChannelApiKey.ApiKey)
		ctx.Export("fullPermissionsApiKey", fullPermissions.ApiKey)
		return nil
	})
}
package generated_program;

import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.azure.core.ResourceGroup;
import com.pulumi.azure.core.ResourceGroupArgs;
import com.pulumi.azure.appinsights.Insights;
import com.pulumi.azure.appinsights.InsightsArgs;
import com.pulumi.azure.appinsights.ApiKey;
import com.pulumi.azure.appinsights.ApiKeyArgs;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;

public class App {
    public static void main(String[] args) {
        Pulumi.run(App::stack);
    }

    public static void stack(Context ctx) {
        var exampleResourceGroup = new ResourceGroup("exampleResourceGroup", ResourceGroupArgs.builder()        
            .location("West Europe")
            .build());

        var exampleInsights = new Insights("exampleInsights", InsightsArgs.builder()        
            .location(exampleResourceGroup.location())
            .resourceGroupName(exampleResourceGroup.name())
            .applicationType("web")
            .build());

        var readTelemetry = new ApiKey("readTelemetry", ApiKeyArgs.builder()        
            .applicationInsightsId(exampleInsights.id())
            .readPermissions(            
                "aggregate",
                "api",
                "draft",
                "extendqueries",
                "search")
            .build());

        var writeAnnotations = new ApiKey("writeAnnotations", ApiKeyArgs.builder()        
            .applicationInsightsId(exampleInsights.id())
            .writePermissions("annotations")
            .build());

        var authenticateSdkControlChannelApiKey = new ApiKey("authenticateSdkControlChannelApiKey", ApiKeyArgs.builder()        
            .applicationInsightsId(exampleInsights.id())
            .readPermissions("agentconfig")
            .build());

        var fullPermissions = new ApiKey("fullPermissions", ApiKeyArgs.builder()        
            .applicationInsightsId(exampleInsights.id())
            .readPermissions(            
                "agentconfig",
                "aggregate",
                "api",
                "draft",
                "extendqueries",
                "search")
            .writePermissions("annotations")
            .build());

        ctx.export("readTelemetryApiKey", readTelemetry.apiKey());
        ctx.export("writeAnnotationsApiKey", writeAnnotations.apiKey());
        ctx.export("authenticateSdkControlChannel", authenticateSdkControlChannelApiKey.apiKey());
        ctx.export("fullPermissionsApiKey", fullPermissions.apiKey());
    }
}
import pulumi
import pulumi_azure as azure

example_resource_group = azure.core.ResourceGroup("exampleResourceGroup", location="West Europe")
example_insights = azure.appinsights.Insights("exampleInsights",
    location=example_resource_group.location,
    resource_group_name=example_resource_group.name,
    application_type="web")
read_telemetry = azure.appinsights.ApiKey("readTelemetry",
    application_insights_id=example_insights.id,
    read_permissions=[
        "aggregate",
        "api",
        "draft",
        "extendqueries",
        "search",
    ])
write_annotations = azure.appinsights.ApiKey("writeAnnotations",
    application_insights_id=example_insights.id,
    write_permissions=["annotations"])
authenticate_sdk_control_channel_api_key = azure.appinsights.ApiKey("authenticateSdkControlChannelApiKey",
    application_insights_id=example_insights.id,
    read_permissions=["agentconfig"])
full_permissions = azure.appinsights.ApiKey("fullPermissions",
    application_insights_id=example_insights.id,
    read_permissions=[
        "agentconfig",
        "aggregate",
        "api",
        "draft",
        "extendqueries",
        "search",
    ],
    write_permissions=["annotations"])
pulumi.export("readTelemetryApiKey", read_telemetry.api_key)
pulumi.export("writeAnnotationsApiKey", write_annotations.api_key)
pulumi.export("authenticateSdkControlChannel", authenticate_sdk_control_channel_api_key.api_key)
pulumi.export("fullPermissionsApiKey", full_permissions.api_key)
import * as pulumi from "@pulumi/pulumi";
import * as azure from "@pulumi/azure";

const exampleResourceGroup = new azure.core.ResourceGroup("exampleResourceGroup", {location: "West Europe"});
const exampleInsights = new azure.appinsights.Insights("exampleInsights", {
    location: exampleResourceGroup.location,
    resourceGroupName: exampleResourceGroup.name,
    applicationType: "web",
});
const readTelemetry = new azure.appinsights.ApiKey("readTelemetry", {
    applicationInsightsId: exampleInsights.id,
    readPermissions: [
        "aggregate",
        "api",
        "draft",
        "extendqueries",
        "search",
    ],
});
const writeAnnotations = new azure.appinsights.ApiKey("writeAnnotations", {
    applicationInsightsId: exampleInsights.id,
    writePermissions: ["annotations"],
});
const authenticateSdkControlChannelApiKey = new azure.appinsights.ApiKey("authenticateSdkControlChannelApiKey", {
    applicationInsightsId: exampleInsights.id,
    readPermissions: ["agentconfig"],
});
const fullPermissions = new azure.appinsights.ApiKey("fullPermissions", {
    applicationInsightsId: exampleInsights.id,
    readPermissions: [
        "agentconfig",
        "aggregate",
        "api",
        "draft",
        "extendqueries",
        "search",
    ],
    writePermissions: ["annotations"],
});
export const readTelemetryApiKey = readTelemetry.apiKey;
export const writeAnnotationsApiKey = writeAnnotations.apiKey;
export const authenticateSdkControlChannel = authenticateSdkControlChannelApiKey.apiKey;
export const fullPermissionsApiKey = fullPermissions.apiKey;
resources:
  exampleResourceGroup:
    type: azure:core:ResourceGroup
    properties:
      location: West Europe
  exampleInsights:
    type: azure:appinsights:Insights
    properties:
      location: ${exampleResourceGroup.location}
      resourceGroupName: ${exampleResourceGroup.name}
      applicationType: web
  readTelemetry:
    type: azure:appinsights:ApiKey
    properties:
      applicationInsightsId: ${exampleInsights.id}
      readPermissions:
        - aggregate
        - api
        - draft
        - extendqueries
        - search
  writeAnnotations:
    type: azure:appinsights:ApiKey
    properties:
      applicationInsightsId: ${exampleInsights.id}
      writePermissions:
        - annotations
  authenticateSdkControlChannelApiKey:
    type: azure:appinsights:ApiKey
    properties:
      applicationInsightsId: ${exampleInsights.id}
      readPermissions:
        - agentconfig
  fullPermissions:
    type: azure:appinsights:ApiKey
    properties:
      applicationInsightsId: ${exampleInsights.id}
      readPermissions:
        - agentconfig
        - aggregate
        - api
        - draft
        - extendqueries
        - search
      writePermissions:
        - annotations
outputs:
  readTelemetryApiKey: ${readTelemetry.apiKey}
  writeAnnotationsApiKey: ${writeAnnotations.apiKey}
  authenticateSdkControlChannel: ${authenticateSdkControlChannelApiKey.apiKey}
  fullPermissionsApiKey: ${fullPermissions.apiKey}

Create ApiKey Resource

new ApiKey(name: string, args: ApiKeyArgs, opts?: CustomResourceOptions);
@overload
def ApiKey(resource_name: str,
           opts: Optional[ResourceOptions] = None,
           application_insights_id: Optional[str] = None,
           name: Optional[str] = None,
           read_permissions: Optional[Sequence[str]] = None,
           write_permissions: Optional[Sequence[str]] = None)
@overload
def ApiKey(resource_name: str,
           args: ApiKeyArgs,
           opts: Optional[ResourceOptions] = None)
func NewApiKey(ctx *Context, name string, args ApiKeyArgs, opts ...ResourceOption) (*ApiKey, error)
public ApiKey(string name, ApiKeyArgs args, CustomResourceOptions? opts = null)
public ApiKey(String name, ApiKeyArgs args)
public ApiKey(String name, ApiKeyArgs args, CustomResourceOptions options)
type: azure:appinsights:ApiKey
properties: # The arguments to resource properties.
options: # Bag of options to control resource's behavior.

name string
The unique name of the resource.
args ApiKeyArgs
The arguments to resource properties.
opts CustomResourceOptions
Bag of options to control resource's behavior.
resource_name str
The unique name of the resource.
args ApiKeyArgs
The arguments to resource properties.
opts ResourceOptions
Bag of options to control resource's behavior.
ctx Context
Context object for the current deployment.
name string
The unique name of the resource.
args ApiKeyArgs
The arguments to resource properties.
opts ResourceOption
Bag of options to control resource's behavior.
name string
The unique name of the resource.
args ApiKeyArgs
The arguments to resource properties.
opts CustomResourceOptions
Bag of options to control resource's behavior.
name String
The unique name of the resource.
args ApiKeyArgs
The arguments to resource properties.
options CustomResourceOptions
Bag of options to control resource's behavior.

ApiKey Resource Properties

To learn more about resource properties and how to use them, see Inputs and Outputs in the Architecture and Concepts docs.

Inputs

The ApiKey resource accepts the following input properties:

ApplicationInsightsId string

The ID of the Application Insights component on which the API key operates. Changing this forces a new resource to be created.

Name string

Specifies the name of the Application Insights API key. Changing this forces a new resource to be created.

ReadPermissions List<string>

Specifies the list of read permissions granted to the API key. Valid values are agentconfig, aggregate, api, draft, extendqueries, search. Please note these values are case sensitive. Changing this forces a new resource to be created.

WritePermissions List<string>

Specifies the list of write permissions granted to the API key. Valid values are annotations. Please note these values are case sensitive. Changing this forces a new resource to be created.

ApplicationInsightsId string

The ID of the Application Insights component on which the API key operates. Changing this forces a new resource to be created.

Name string

Specifies the name of the Application Insights API key. Changing this forces a new resource to be created.

ReadPermissions []string

Specifies the list of read permissions granted to the API key. Valid values are agentconfig, aggregate, api, draft, extendqueries, search. Please note these values are case sensitive. Changing this forces a new resource to be created.

WritePermissions []string

Specifies the list of write permissions granted to the API key. Valid values are annotations. Please note these values are case sensitive. Changing this forces a new resource to be created.

applicationInsightsId String

The ID of the Application Insights component on which the API key operates. Changing this forces a new resource to be created.

name String

Specifies the name of the Application Insights API key. Changing this forces a new resource to be created.

readPermissions List<String>

Specifies the list of read permissions granted to the API key. Valid values are agentconfig, aggregate, api, draft, extendqueries, search. Please note these values are case sensitive. Changing this forces a new resource to be created.

writePermissions List<String>

Specifies the list of write permissions granted to the API key. Valid values are annotations. Please note these values are case sensitive. Changing this forces a new resource to be created.

applicationInsightsId string

The ID of the Application Insights component on which the API key operates. Changing this forces a new resource to be created.

name string

Specifies the name of the Application Insights API key. Changing this forces a new resource to be created.

readPermissions string[]

Specifies the list of read permissions granted to the API key. Valid values are agentconfig, aggregate, api, draft, extendqueries, search. Please note these values are case sensitive. Changing this forces a new resource to be created.

writePermissions string[]

Specifies the list of write permissions granted to the API key. Valid values are annotations. Please note these values are case sensitive. Changing this forces a new resource to be created.

application_insights_id str

The ID of the Application Insights component on which the API key operates. Changing this forces a new resource to be created.

name str

Specifies the name of the Application Insights API key. Changing this forces a new resource to be created.

read_permissions Sequence[str]

Specifies the list of read permissions granted to the API key. Valid values are agentconfig, aggregate, api, draft, extendqueries, search. Please note these values are case sensitive. Changing this forces a new resource to be created.

write_permissions Sequence[str]

Specifies the list of write permissions granted to the API key. Valid values are annotations. Please note these values are case sensitive. Changing this forces a new resource to be created.

applicationInsightsId String

The ID of the Application Insights component on which the API key operates. Changing this forces a new resource to be created.

name String

Specifies the name of the Application Insights API key. Changing this forces a new resource to be created.

readPermissions List<String>

Specifies the list of read permissions granted to the API key. Valid values are agentconfig, aggregate, api, draft, extendqueries, search. Please note these values are case sensitive. Changing this forces a new resource to be created.

writePermissions List<String>

Specifies the list of write permissions granted to the API key. Valid values are annotations. Please note these values are case sensitive. Changing this forces a new resource to be created.

Outputs

All input properties are implicitly available as output properties. Additionally, the ApiKey resource produces the following output properties:

Id string

The provider-assigned unique ID for this managed resource.

Key string

The API Key secret (Sensitive).

ApiKey string

The API Key secret (Sensitive).

Id string

The provider-assigned unique ID for this managed resource.

apiKey String

The API Key secret (Sensitive).

id String

The provider-assigned unique ID for this managed resource.

apiKey string

The API Key secret (Sensitive).

id string

The provider-assigned unique ID for this managed resource.

api_key str

The API Key secret (Sensitive).

id str

The provider-assigned unique ID for this managed resource.

apiKey String

The API Key secret (Sensitive).

id String

The provider-assigned unique ID for this managed resource.

Look up Existing ApiKey Resource

Get an existing ApiKey resource’s state with the given name, ID, and optional extra properties used to qualify the lookup.

public static get(name: string, id: Input<ID>, state?: ApiKeyState, opts?: CustomResourceOptions): ApiKey
@staticmethod
def get(resource_name: str,
        id: str,
        opts: Optional[ResourceOptions] = None,
        api_key: Optional[str] = None,
        application_insights_id: Optional[str] = None,
        name: Optional[str] = None,
        read_permissions: Optional[Sequence[str]] = None,
        write_permissions: Optional[Sequence[str]] = None) -> ApiKey
func GetApiKey(ctx *Context, name string, id IDInput, state *ApiKeyState, opts ...ResourceOption) (*ApiKey, error)
public static ApiKey Get(string name, Input<string> id, ApiKeyState? state, CustomResourceOptions? opts = null)
public static ApiKey get(String name, Output<String> id, ApiKeyState state, CustomResourceOptions options)
Resource lookup is not supported in YAML
name
The unique name of the resulting resource.
id
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.
resource_name
The unique name of the resulting resource.
id
The unique provider ID of the resource to lookup.
name
The unique name of the resulting resource.
id
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.
name
The unique name of the resulting resource.
id
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.
name
The unique name of the resulting resource.
id
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.
The following state arguments are supported:
ApplicationInsightsId string

The ID of the Application Insights component on which the API key operates. Changing this forces a new resource to be created.

Key string

The API Key secret (Sensitive).

Name string

Specifies the name of the Application Insights API key. Changing this forces a new resource to be created.

ReadPermissions List<string>

Specifies the list of read permissions granted to the API key. Valid values are agentconfig, aggregate, api, draft, extendqueries, search. Please note these values are case sensitive. Changing this forces a new resource to be created.

WritePermissions List<string>

Specifies the list of write permissions granted to the API key. Valid values are annotations. Please note these values are case sensitive. Changing this forces a new resource to be created.

ApiKey string

The API Key secret (Sensitive).

ApplicationInsightsId string

The ID of the Application Insights component on which the API key operates. Changing this forces a new resource to be created.

Name string

Specifies the name of the Application Insights API key. Changing this forces a new resource to be created.

ReadPermissions []string

Specifies the list of read permissions granted to the API key. Valid values are agentconfig, aggregate, api, draft, extendqueries, search. Please note these values are case sensitive. Changing this forces a new resource to be created.

WritePermissions []string

Specifies the list of write permissions granted to the API key. Valid values are annotations. Please note these values are case sensitive. Changing this forces a new resource to be created.

apiKey String

The API Key secret (Sensitive).

applicationInsightsId String

The ID of the Application Insights component on which the API key operates. Changing this forces a new resource to be created.

name String

Specifies the name of the Application Insights API key. Changing this forces a new resource to be created.

readPermissions List<String>

Specifies the list of read permissions granted to the API key. Valid values are agentconfig, aggregate, api, draft, extendqueries, search. Please note these values are case sensitive. Changing this forces a new resource to be created.

writePermissions List<String>

Specifies the list of write permissions granted to the API key. Valid values are annotations. Please note these values are case sensitive. Changing this forces a new resource to be created.

apiKey string

The API Key secret (Sensitive).

applicationInsightsId string

The ID of the Application Insights component on which the API key operates. Changing this forces a new resource to be created.

name string

Specifies the name of the Application Insights API key. Changing this forces a new resource to be created.

readPermissions string[]

Specifies the list of read permissions granted to the API key. Valid values are agentconfig, aggregate, api, draft, extendqueries, search. Please note these values are case sensitive. Changing this forces a new resource to be created.

writePermissions string[]

Specifies the list of write permissions granted to the API key. Valid values are annotations. Please note these values are case sensitive. Changing this forces a new resource to be created.

api_key str

The API Key secret (Sensitive).

application_insights_id str

The ID of the Application Insights component on which the API key operates. Changing this forces a new resource to be created.

name str

Specifies the name of the Application Insights API key. Changing this forces a new resource to be created.

read_permissions Sequence[str]

Specifies the list of read permissions granted to the API key. Valid values are agentconfig, aggregate, api, draft, extendqueries, search. Please note these values are case sensitive. Changing this forces a new resource to be created.

write_permissions Sequence[str]

Specifies the list of write permissions granted to the API key. Valid values are annotations. Please note these values are case sensitive. Changing this forces a new resource to be created.

apiKey String

The API Key secret (Sensitive).

applicationInsightsId String

The ID of the Application Insights component on which the API key operates. Changing this forces a new resource to be created.

name String

Specifies the name of the Application Insights API key. Changing this forces a new resource to be created.

readPermissions List<String>

Specifies the list of read permissions granted to the API key. Valid values are agentconfig, aggregate, api, draft, extendqueries, search. Please note these values are case sensitive. Changing this forces a new resource to be created.

writePermissions List<String>

Specifies the list of write permissions granted to the API key. Valid values are annotations. Please note these values are case sensitive. Changing this forces a new resource to be created.

Import

Application Insights API keys can be imported using the resource id, e.g.

 $ pulumi import azure:appinsights/apiKey:ApiKey my_key /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/mygroup1/providers/Microsoft.Insights/components/instance1/apiKeys/00000000-0000-0000-0000-000000000000

Package Details

Repository
Azure Classic pulumi/pulumi-azure
License
Apache-2.0
Notes

This Pulumi package is based on the azurerm Terraform Provider.