fancy-fall-81083
09/19/2018, 7:49 PMconst resourceGroup = await azure.core.getResourceGroup …
) but am stuck in reading about the typescript Promise type and brain compiling to javascript. Any hints would be highly appreciated. As I am new to async/await that might be my main problem. @stocky-spoon-28903’s example seems to be just the core and I am just not getting how to do my async/await call so that nodejs does not fail with an ReferenceError: resourceGroup is not defined
when using resourceGroup.name
later in the code.white-balloon-205
import * as azure from "@pulumi/azure";
async function main(): Promise<string> {
const resourceGroup = await azure.core.getResourceGroup({
name: "appservice-rg24afd37d",
});
return resourceGroup.location;
}
export const location = main();
Note that getResourceGroup
does not appear to return the name
, but you also don't really need it because you can only get the resource group by name anyway, so you could just use that name where needed instead of calling getResourceGroup
. You only need that function if you want to e.g. figure out what location the resource group is in.import * as pulumi from "@pulumi/pulumi";
import * as azure from "@pulumi/azure";
async function main(): Promise<pulumi.Output<string>> {
// Get an Azure Resource Group
const resourceGroupName = "appservice-rg24afd37d";
const resourceGroup = await azure.core.getResourceGroup({ name: resourceGroupName });
// Create an Azure resource (Storage Account)
const account = new azure.storage.Account("storage", {
resourceGroupName: resourceGroupName,
location: resourceGroup.location,
accountTier: "Standard",
accountReplicationType: "LRS",
});
return account.primaryConnectionString;
}
export const connectionString = main()
fancy-fall-81083
09/19/2018, 8:18 PMwhite-balloon-205
const azure = require("@pulumi/azure")
async function main() {
const resourceGroup = await azure.core.getResourceGroup({
name: "appservice-rg24afd37d",
});
return resourceGroup.location;
}
exports.location = main();
fancy-fall-81083
09/19/2018, 8:53 PM