quick-noon-18541
04/23/2025, 9:16 AMtry
{
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
`waiting for the Azure CLI: exit status 1: ERROR: Please run 'az login' to setup account.
Full stack
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