https://pulumi.com logo
#general
Title
# general
s

stale-knife-36790

03/31/2020, 8:22 AM
How do I use a resource account / group to deploy functions with pulumi? (I can't seem to get the 'appId', 'tenant' and 'password' as well as I'm currently getting the following error:
Copy code
Diagnostics:
  pulumi:pulumi:Stack (azure-dev):
    The Pulumi runtime detected that 166 promises were still active
    at the time that the process exited. There are a few ways that this can occur:
      * Not using `await` or `.then` on a Promise returned from a Pulumi API
      * Introducing a cyclic dependency between two Pulumi Resources
      * A bug in the Pulumi Runtime
    Leaving promises active is probably not what you want. If you are unsure about
    why you are seeing this message, re-run your program with the `PULUMI_DEBUG_PROMISE_LEAKS`
    environment variable. The Pulumi runtime will then print out additional
    debug information about the leaked promises.

  azure:core:ResourceGroup (my_specified_resource_group):
    error: Error ensuring Resource Providers are registered.

    Terraform automatically attempts to register the Resource Providers it supports to
    ensure it's able to provision resources.

    If you don't have permission to register Resource Providers you may wish to use the
    "skip_provider_registration" flag in the Provider block to disable this functionality.

    Please note that if you opt out of Resource Provider Registration and Terraform tries
    to provision a resource from a Resource Provider which is unregistered, then the errors
    may appear misleading - for example:

    > API version 2019-XX-XX was not found for Microsoft.Foo

    Could indicate either that the Resource Provider "Microsoft.Foo" requires registration,
    but this could also indicate that this Azure Region doesn't support this API version.

    More information on the "skip_provider_registration" flag can be found here:
    <https://www.terraform.io/docs/providers/azurerm/index.html#skip_provider_registration>

    Original Error: Cannot register provider Microsoft.Kusto with Azure Resource Manager: resources.ProvidersClient#Register: Failure responding to request: StatusCode=403 -- Original Error: autorest/azure: Service returned an error. Status=403 Code="AuthorizationFailed" Message="The client <mailto:'live.com#my_email@hotmail.com|'live.com#my_email@hotmail.com>' with object id '********-****-****-********950e' does not have authorization to perform action 'Microsoft.Kusto/register/action' over scope '/subscriptions/********-****-****-****-********e859' or the scope is invalid. If access was recently granted, please refresh your credentials.".
t

tall-librarian-49374

03/31/2020, 8:36 AM
This issue should help you avoid this immediate error: https://github.com/pulumi/pulumi/issues/4164
s

stale-knife-36790

03/31/2020, 8:59 AM
@tall-librarian-49374 Thanks for the reply! I tried the code and this code currently gives an error:
Copy code
var resourceGroup = new ResourceGroup("ppwe-playground-pulumi-dev",null, new CustomResourceOptions
{
    ImportId = "ppwe-playground-pulumi-dev" 
});
(my IDE doesn't recognize 'CustomResourceOptions')
t

tall-librarian-49374

03/31/2020, 10:23 AM
Weird... It's in Pulumi namespace.
s

stale-knife-36790

03/31/2020, 10:30 AM
Copy code
const resourceGroup = new azure.core.ResourceGroup("name", null, new pulumi.CustomResourceOptions {
    ImportId = "";
});
@tall-librarian-49374 ^ also doesn't work. Was there any update in the past week? Is there a fix for this?
t

tall-librarian-49374

03/31/2020, 10:45 AM
Oh, based on your previous snippet I thought you are in C#… This should work in TypeScript:
Copy code
const resourceGroup = new azure.core.ResourceGroup("name", {}, {
    importId: "",
});
(edited my code). I’m confused about the language you are using…
s

stale-knife-36790

03/31/2020, 10:55 AM
@tall-librarian-49374 NodeJS, Javascript.
t

tall-librarian-49374

03/31/2020, 10:57 AM
Okay, try my last snippet then.
s

stale-knife-36790

03/31/2020, 10:57 AM
Still doesn't work.
Copy code
"use strict";
const pulumi = require("@pulumi/pulumi");
const azure = require("@pulumi/azure");

// Create an Azure Resource Group
const resourceGroup = new azure.core.ResourceGroup("kynda_crud", {}, {
    importId: "cc7bdc8c-aff8-4c6b-81ca-154b2e02e859",
});

// Create an Azure resource (Storage Account)
const account = new azure.storage.Account("pulumi-storage", {
    // The location for the storage account will be derived automatically from the resource group.
    resourceGroupName: resourceGroup.name,
    accountTier: "Standard",
    accountReplicationType: "LRS",
});

// Export the connection string for the storage account
return exports.connectionString = account.primaryConnectionString;
c

colossal-room-15708

03/31/2020, 11:13 AM
I assume you ran "npm install"?
s

stale-knife-36790

03/31/2020, 11:19 AM
@colossal-room-15708 Yes, I also installed the full Pulumi packages globally.
Still getting the following error:
Copy code
azure:storage:Account (pulumi-storage):
error: Error reading resource group: resources.GroupsClient#Get: Failure responding to request: StatusCode=403 -- Orig<m action 'Microsoft.Resources/subscriptions/resourcegroups/read' over scope '/subscriptions/<subscription id>/resourcegroups/kynda_crud3e6161db' or
the scope is invalid. If access was recently granted, please refresh your credentials."
@colossal-room-15708 @tall-librarian-49374 is there a fix for this error?
c

colossal-room-15708

04/02/2020, 7:48 AM
did you create that resource group or someone else?
it seems like whatever account you're using to log in to azure does not have permissions to that resource group
s

stale-knife-36790

04/02/2020, 7:56 AM
I created the resource group
and was able to call Cosmos DB in a previous project without Pulumi
@colossal-room-15708 Is there maybe an option to use a custom endpoint url and key? Ex for Cosmos DB:
Copy code
{
  "endpoint": "<https://resource-account.documents.azure.com:443/>",
  "key": "Key",
  "databaseId": "Database_Id",
  "containerId": "items"
}
c

colossal-room-15708

04/02/2020, 8:20 AM
Are you still trying to get the example script working that you pasted in above? This looks very much like a permissions issue on the resource group, not with the pulumi code.
does this happen when you run
pulumi preview
?
s

stale-knife-36790

04/02/2020, 9:10 AM
@colossal-room-15708 Yes, I'm still trying to let Azure work with the example script. Sadly it does the same on
pulumi preview