Hi all! I have a design where I want to use automa...
# automation-api
q
Hi all! I have a design where I want to use automation API in azure function app. So I deploy dotnet function app as docker container with preinstalled pulumi. I setup function with bunch of environment variables like ARM_SUBSCRIPTION_ID, ARM_USE_MSI, ARM_CLIENT_ID, ARM_TENANT_ID and some to configure cosmosDb connection, storage account as backend etc. And now I have such test code
Copy code
try
{
    var accountStackName = "test_stack_1";

    var accountProjectName = "cosmosAccount";
    var accountProgram = CosmosAccount();
    var keyVaultKeyId = "<http://xxx.vault.azure.net/keys/cosmosEncryptionKey|xxx.vault.azure.net/keys/cosmosEncryptionKey>";
    var stackArgs = new InlineProgramArgs(accountProjectName, accountStackName, accountProgram)
    {
        SecretsProvider = $"azurekeyvault://{keyVaultKeyId}",
    };
    var options = new LocalWorkspaceOptions
    {
        SecretsProvider = $"azurekeyvault://{keyVaultKeyId}",
        StackSettings = new Dictionary<string, StackSettings>
        {
            ["secrets_provider"] = new() { SecretsProvider = $"azurekeyvault://{keyVaultKeyId}" }
        },
        ProjectSettings = new ProjectSettings(accountProjectName, ProjectRuntimeName.Dotnet)
        {
            Backend = new ProjectBackend
            {
                Url = Environment.GetEnvironmentVariable("PULUMI_BACKEND_URL")
            },
            
        },
    };
    var workspace = await LocalWorkspace.SelectStackAsync(stackArgs);
    await ConfigureStackAsync(workspace, "East US");

    // Deploy the stack
    var upResult = await workspace.UpAsync();

    List<UpResult> outputResults =
    [
        upResult
    ];

    var response = req.CreateResponse(HttpStatusCode.OK);

    await response.WriteAsJsonAsync(outputResults);

    return response;
}
catch (Exception ex)
{
    logger.LogError(ex, "Error occurred while processing the request.");
    logger.LogError(ex.Message);
    throw;
}
And it throws with
Copy code
`waiting for the Azure CLI: exit status 1: ERROR: Please run 'az login' to setup account.
Full stack
Copy code
2025-04-23T09:03:01Z   [Error]   Error occurred while processing the request.
2025-04-23T09:03:01Z   [Error]   code: 255
stdout: Updating (test_stack_1):
Downloading plugin azure-native-3.1.0: starting
Downloading plugin azure-native-3.1.0: done
Installing plugin azure-native-3.1.0: starting
@ updating....
Installing plugin azure-native-3.1.0: done

    pulumi:pulumi:Stack cosmosAccount-test_stack_1 running 
@ updating......
    azure-native:cosmosdb:DatabaseAccount account1  error: obtain subscription(<sub_id>) from Azure CLI: parsing json result from the Azure CLI: waiting for the Azure CLI: exit status 1: ERROR: Please run 'az login' to setup account.
    azure-native:cosmosdb:DatabaseAccount account1 **failed** 1 error
    pulumi:pulumi:Stack cosmosAccount-test_stack_1  
Diagnostics:
  azure-native:cosmosdb:DatabaseAccount (account1):
    error: obtain subscription(<sub_id>) from Azure CLI: parsing json result from the Azure CLI: waiting for the Azure CLI: exit status 1: ERROR: Please run 'az login' to setup account.

Resources:
    1 unchanged

Duration: 4s


stderr: 
2025-04-23T09:03:01Z   [Error]   Function 'Test', Invocation id '<invocation_id>': An exception was thrown by the invocation.
2025-04-23T09:03:01Z   [Error]   Executed 'Functions.Test' (Failed, Id=<some_id>, Duration=11707ms)
Do you have any suggestions how to deal with it? I setup resources for azure func app in another classic pulumi project so if changes need to be done there, it's possible. Ideally I wouldn't want to pass anything to dockerfile, as variables are passed to app in pulumi run Thanks, Grzesiek