This message was deleted.
# general
s
This message was deleted.
w
The following should work:
Copy code
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.
Here's another example:
Copy code
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()
f
Hi @white-balloon-205, thanks a lot. However, that looks like typescript and, sorry for the confusion, I have no idea about typescript. Would you mind to send me a js example, that would be great! The first short example would be mighty sufficient.
w
How about this?
Copy code
const azure = require("@pulumi/azure")

async function main() {
    const resourceGroup = await azure.core.getResourceGroup({
        name: "appservice-rg24afd37d",
    });

    return resourceGroup.location;
}

exports.location = main();
f
Thanks a lot and thanks a lot for the js lessons as well 😉. I tried to figure out how to return the whole resourceGroup object at once (so that I can access its values by using resourceGroup.location) but I gave up and just repeated your function multiple times for now. Will try to think about how to do that tomorrow. Javascript really is a beast, no wonder you are using typescript ...