Good day all, I'm trying to create an apikey for a...
# azure
a
Good day all, I'm trying to create an apikey for an appinsights following this guide. The first create looks good, but all the subsequent pulumi preview/up, I am getting issue where it will be
create-replacement
but actually nothing has changed in the appinsights nor the appinsights apikey. This is the diff logs:
Copy code
++ azure:appinsights/apiKey:ApiKey (create-replacement)
    [id=/subscriptions/[id]/resourcegroups/[resourceGroupName]/providers/microsoft.insights/components/[resourceGroupName]/apiKeys/[keyId]]
    __meta               : "{"....":{"create":1800000000000,"delete":1800000000000,"read":300000000000,"update":1800000000000},"schema_version":"1"}"
    apiKey               : "[secret]"
    applicationInsightsId: "/subscriptions/[id]/resourceGroups/[resourceGroupName]/providers/Microsoft.Insights/components/[resourceGroupName]" => "/subscriptions/[id]/resourceGroups/[resourceGroupName]/providers/microsoft.insights/components/[resourceGroupName]"
    id                   : "/subscriptions/[id]/resourcegroups/[resourceGroupName]/providers/microsoft.insights/components/[resourceGroupName]/apiKeys/[keyId]"
    writePermissions     : []
Does anyone have this issue as well? Any help is much appreciated! thanks!
b
hi @adorable-airport-36662 would you be able to share the code you're using to create the key?
a
Hi @billowy-army-68599 this is the ts code i used
Copy code
const appInsights = new azure.appinsights.Insights(
    componentName,
    {
        resourceGroupName: resourceGroupName,
        location: location,
        name: componentName,
        applicationType: "web"
    },
    { parent: resourceGroup });

const appInsightsApiKey = new azure.appinsights.ApiKey(
    componentName, {
        name: componentName,
        applicationInsightsId: appInsights.id,
        readPermissions: ["aggregate", "api", "draft", "extendqueries", "search"],
    },
    { parent: appInsights });
Hi @billowy-army-68599 i've able to hackily solve this
create-replacement
issue by replacing the casing in the
appInsightsId
like below. But it feels hacky. Do you have any idea why this is working or have any other approach in mind? thanks!
Copy code
const appInsightsApiKey = appInsights.id.apply(id => new azure.appinsights.ApiKey(
    componentName, {
        name: componentName,
        applicationInsightsId: id.replace(/microsoft.insights/g, "Microsoft.Insights"),
        readPermissions: ["aggregate", "api", "draft", "extendqueries", "search"],
    },
    { parent: appInsights }));