Skip to content

Azure CLI Authentication not working in Container Image due to missing Shell #19

Open
@techdecline

Description

@techdecline

Hi,

I'd like to run Azure-Janitor from the provided container image with the mounted .azure directory using the Azure CLI Authentication.

This fails probably due to missing shell environment within the image:

Stderr: {"level":"info","caller":"azure-janitor/main.go:42","msg":"starting azure-janitor v24.2.1 (5265f70; go1.22.0; by webdevops.io)"} {"level":"info","caller":"azure-janitor/main.go:43","msg":"{\"DryRun\":true,\"Logger\":{\"Debug\":false,\"Development\":false,\"Json\":true},\"Azure\":{\"Environment\":\"AZUREPUBLICCLOUD\",\"Subscription\":null,\"ResourceTags\":[\"owner\"]},\"Janitor\":{\"Interval\":3600000000000,\"Tag\":\"ttl\",\"TagTarget\":\"ttl_expiry\",\"ResourceGroups\":{\"Enable\":true,\"AdditionalFilter\":null,\"Filter\":\"tagName eq 'ttl'\"},\"Resources\":{\"Enable\":false,\"AdditionalFilter\":null,\"Filter\":\"\"},\"Deployments\":{\"Enable\":false,\"Ttl\":31536000000000000,\"Limit\":700},\"RoleAssignments\":{\"Enable\":false,\"Ttl\":21600000000000,\"RoleDefintionIds\":null,\"AdditionalFilter\":null,\"Filter\":\"\",\"DescriptionTtl\":null,\"DescriptionTtlRegExp\":null}},\"Server\":{\"Bind\":\":8080\",\"ReadTimeout\":5000000000,\"WriteTimeout\":10000000000}}"} {"level":"info","caller":"azure-janitor/main.go:45","msg":"init Azure connection"} {"level":"info","caller":"azure-janitor/main.go:48","msg":"init Janitor"} {"level":"info","caller":"azure-janitor/main.go:63","msg":"starting http server on :8080"} {"level":"panic","caller":"janitor/janitor.go:267","msg":"AzureCLICredential: fork/exec /bin/sh: no such file or directory","stacktrace":"github.com/webdevops/azure-janitor/janitor.(*Janitor).initAzureApiVersions\n\t/go/src/github.com/webdevops/azure-janitor/janitor/janitor.go:267\ngithub.com/webdevops/azure-janitor/janitor.(*Janitor).Init\n\t/go/src/github.com/webdevops/azure-janitor/janitor/janitor.go:82\nmain.main.func1\n\t/go/src/github.com/webdevops/azure-janitor/main.go:59"} panic: AzureCLICredential: fork/exec /bin/sh: no such file or directory

This is the snippet, that is executing the container:

class Ci:
    @function
    def run_azure_janitor(self, azure_cli_path: dagger.Directory) -> dagger.Container:
        """Returns a container that echoes whatever string argument is provided"""
        return (dag.container()
            .from_("webdevops/azure-janitor")
            .with_directory("/root/.azure",azure_cli_path)
            .with_env_variable("AZURE_AUTH", "az")
            .with_exec(["--janitor.resourcegroups"])
        )

Is it possible to provide an image that includs a shell?

Thanks and regards,
Cornelius

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions