We recommend using Azure Native.
published on Monday, Mar 9, 2026 by Pulumi
We recommend using Azure Native.
published on Monday, Mar 9, 2026 by Pulumi
Manages an Application Insights API key.
Example Usage
using Pulumi;
using Azure = Pulumi.Azure;
class MyStack : Stack
{
public MyStack()
{
var exampleResourceGroup = new Azure.Core.ResourceGroup("exampleResourceGroup", new Azure.Core.ResourceGroupArgs
{
Location = "West Europe",
});
var exampleInsights = new Azure.AppInsights.Insights("exampleInsights", new Azure.AppInsights.InsightsArgs
{
Location = "West Europe",
ResourceGroupName = exampleResourceGroup.Name,
ApplicationType = "web",
});
var readTelemetry = new Azure.AppInsights.ApiKey("readTelemetry", new Azure.AppInsights.ApiKeyArgs
{
ApplicationInsightsId = exampleInsights.Id,
ReadPermissions =
{
"aggregate",
"api",
"draft",
"extendqueries",
"search",
},
});
var writeAnnotations = new Azure.AppInsights.ApiKey("writeAnnotations", new Azure.AppInsights.ApiKeyArgs
{
ApplicationInsightsId = exampleInsights.Id,
WritePermissions =
{
"annotations",
},
});
var authenticateSdkControlChannelApiKey = new Azure.AppInsights.ApiKey("authenticateSdkControlChannelApiKey", new Azure.AppInsights.ApiKeyArgs
{
ApplicationInsightsId = exampleInsights.Id,
ReadPermissions =
{
"agentconfig",
},
});
var fullPermissions = new Azure.AppInsights.ApiKey("fullPermissions", new Azure.AppInsights.ApiKeyArgs
{
ApplicationInsightsId = exampleInsights.Id,
ReadPermissions =
{
"agentconfig",
"aggregate",
"api",
"draft",
"extendqueries",
"search",
},
WritePermissions =
{
"annotations",
},
});
this.ReadTelemetryApiKey = readTelemetry.ApiKey;
this.WriteAnnotationsApiKey = writeAnnotations.ApiKey;
this.AuthenticateSdkControlChannel = authenticateSdkControlChannelApiKey.ApiKey;
this.FullPermissionsApiKey = fullPermissions.ApiKey;
}
[Output("readTelemetryApiKey")]
public Output<string> ReadTelemetryApiKey { get; set; }
[Output("writeAnnotationsApiKey")]
public Output<string> WriteAnnotationsApiKey { get; set; }
[Output("authenticateSdkControlChannel")]
public Output<string> AuthenticateSdkControlChannel { get; set; }
[Output("fullPermissionsApiKey")]
public Output<string> FullPermissionsApiKey { get; set; }
}
package main
import (
"github.com/pulumi/pulumi-azure/sdk/v4/go/azure/appinsights"
"github.com/pulumi/pulumi-azure/sdk/v4/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: pulumi.String("West Europe"),
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
})
}
Example coming soon!
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: "West Europe",
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;
import pulumi
import pulumi_azure as azure
example_resource_group = azure.core.ResourceGroup("exampleResourceGroup", location="West Europe")
example_insights = azure.appinsights.Insights("exampleInsights",
location="West Europe",
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)
Example coming soon!
Create ApiKey Resource
Resources are created with functions called constructors. To learn more about declaring and configuring resources, see Resources.
Constructor syntax
new ApiKey(name: string, args: ApiKeyArgs, opts?: CustomResourceOptions);@overload
def ApiKey(resource_name: str,
args: ApiKeyArgs,
opts: Optional[ResourceOptions] = None)
@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)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.
Parameters
- 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.
Constructor example
The following reference example uses placeholder values for all input properties.
var apiKeyResource = new Azure.AppInsights.ApiKey("apiKeyResource", new()
{
ApplicationInsightsId = "string",
Name = "string",
ReadPermissions = new[]
{
"string",
},
WritePermissions = new[]
{
"string",
},
});
example, err := appinsights.NewApiKey(ctx, "apiKeyResource", &appinsights.ApiKeyArgs{
ApplicationInsightsId: pulumi.String("string"),
Name: pulumi.String("string"),
ReadPermissions: pulumi.StringArray{
pulumi.String("string"),
},
WritePermissions: pulumi.StringArray{
pulumi.String("string"),
},
})
var apiKeyResource = new ApiKey("apiKeyResource", ApiKeyArgs.builder()
.applicationInsightsId("string")
.name("string")
.readPermissions("string")
.writePermissions("string")
.build());
api_key_resource = azure.appinsights.ApiKey("apiKeyResource",
application_insights_id="string",
name="string",
read_permissions=["string"],
write_permissions=["string"])
const apiKeyResource = new azure.appinsights.ApiKey("apiKeyResource", {
applicationInsightsId: "string",
name: "string",
readPermissions: ["string"],
writePermissions: ["string"],
});
type: azure:appinsights:ApiKey
properties:
applicationInsightsId: string
name: string
readPermissions:
- string
writePermissions:
- string
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
In Python, inputs that are objects can be passed either as argument classes or as dictionary literals.
The ApiKey resource accepts the following input properties:
- Application
Insights stringId - 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.
- Read
Permissions 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. - Write
Permissions 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.
- Application
Insights stringId - 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.
- Read
Permissions []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. - Write
Permissions []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 StringId - 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.
- read
Permissions 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. - write
Permissions 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.
- application
Insights stringId - 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.
- read
Permissions 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. - write
Permissions 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_ strid - 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.
- application
Insights StringId - 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.
- read
Permissions 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. - write
Permissions 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:
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) -> ApiKeyfunc 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)resources: _: type: azure:appinsights:ApiKey get: id: ${id}- 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.
- Application
Insights stringId - 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.
- Read
Permissions 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. - Write
Permissions 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.
- Api
Key string - The API Key secret (Sensitive).
- Application
Insights stringId - 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.
- Read
Permissions []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. - Write
Permissions []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 String - The API Key secret (Sensitive).
- application
Insights StringId - 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.
- read
Permissions 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. - write
Permissions 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.
- api
Key string - The API Key secret (Sensitive).
- application
Insights stringId - 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.
- read
Permissions 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. - write
Permissions 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_ strid - 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.
- api
Key String - The API Key secret (Sensitive).
- application
Insights StringId - 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.
- read
Permissions 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. - write
Permissions 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
To learn more about importing existing cloud resources, see Importing resources.
Package Details
- Repository
- Azure Classic pulumi/pulumi-azure
- License
- Apache-2.0
- Notes
- This Pulumi package is based on the
azurermTerraform Provider.
We recommend using Azure Native.
published on Monday, Mar 9, 2026 by Pulumi
