{"record":{"id":"21d1675691c10653","repo":"microsoft/aspire","slug":"azure-cli-az-not-found-install-it-from-https-learn-microsoft","errorCode":null,"errorMessage":"Azure CLI (az) not found. Install it from https://learn.microsoft.com/cli/azure/install-azure-cli","messagePattern":"Azure CLI \\(az\\) not found\\. Install it from https://learn\\.microsoft\\.com/cli/azure/install-azure-cli","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/Aspire.Hosting.Azure.Kubernetes/AzureKubernetesEnvironmentResource.AksPipeline.cs","lineNumber":735,"sourceCode":"                    \"Ensure the AKS preview features 'Microsoft.ContainerService/AKSGatewayAPIPreview' and \" +\n                    \"'Microsoft.ContainerService/AKSAppGatewayContainersPreview' are registered on the subscription, \" +\n                    \"and that the AGC ALB controller add-on (ingressProfile.applicationLoadBalancer) finished installing.\");\n            }\n\n            logger.LogDebug(\n                \"GatewayClass 'azure-alb-external' not yet available (attempt {Attempt}); retrying in {Delay}s\",\n                attempt, pollInterval.TotalSeconds);\n\n            await Task.Delay(pollInterval, cancellationToken).ConfigureAwait(false);\n        }\n    }\n\n    private static string FindAzCli()\n    {\n        var azPath = PathLookupHelper.FindFullPathFromPath(\"az\");\n        if (azPath is null)\n        {\n            throw new InvalidOperationException(\n                \"Azure CLI (az) not found. Install it from https://learn.microsoft.com/cli/azure/install-azure-cli\");\n        }\n        return azPath;\n    }\n\n    /// <summary>\n    /// Gets the subscription and resource group this resource explicitly targets, if any.\n    /// </summary>\n    /// <remarks>\n    /// Mirrors the precedence in <c>BicepUtilities.GetExistingResourceScope</c>: an explicitly\n    /// assigned <see cref=\"AzureBicepResource.Scope\"/> (which <c>ConfigureInfrastructure</c> can set)\n    /// wins over the <see cref=\"ExistingAzureResourceAnnotation\"/> that <c>AsExistingInResourceGroup</c>\n    /// and friends attach. The credential fetch has to agree with whatever the provisioner deployed\n    /// against. Values are returned unresolved because they may be a literal string, a\n    /// <see cref=\"ParameterResource\"/>, or a <see cref=\"BicepOutputReference\"/>.\n    /// </remarks>\n    private (object? Subscription, object? ResourceGroup) GetExplicitScopeValues()\n    {","sourceCodeStart":717,"sourceCodeEnd":753,"githubUrl":"https://github.com/microsoft/aspire/blob/25830f84bd145686607ad00c057b3f84e2e51d43/src/Aspire.Hosting.Azure.Kubernetes/AzureKubernetesEnvironmentResource.AksPipeline.cs#L717-L753","documentation":"The AKS pipeline shells out to the Azure CLI, and FindAzCli could not find an 'az' executable on PATH. Every az-driven step (get-credentials, destroy credentials, etc.) requires the Azure CLI to be installed and discoverable.","triggerScenarios":"Any pipeline step resolving azPath runs on a machine/container where PathLookupHelper.FindFullPathFromPath(\"az\") returns null — Azure CLI not installed, or PATH in the app host process lacks the az install location (common on CI agents or containers).","commonSituations":"Fresh CI agent or devcontainer without the Azure CLI; az installed only in a user profile dir not on PATH; running the AppHost from an IDE whose PATH differs from the shell.","solutions":["Install the Azure CLI: https://learn.microsoft.com/cli/azure/install-azure-cli","Verify with 'az --version' in the same shell/user context that launches the AppHost","If az is installed but not found, add its directory to PATH for the process (e.g. export PATH=\"$PATH:/usr/local/bin\" or update the IDE/CI environment)","On CI, use the Azure CLI setup step/action before running the deploy"],"exampleFix":"// before\n// $ az --version\n// bash: az: command not found\n// after\n// $ curl -sL https://aka.ms/InstallAzureCLIDeb | sudo bash\n// $ az --version\n// azure-cli 2.x.x","handlingStrategy":"fallback","validationCode":"if (PathLookupHelper.FindFullPathFromPath(\"az\") is null)\n    throw new InvalidOperationException(\"Install the Azure CLI before deploying AKS environments.\");","typeGuard":null,"tryCatchPattern":"catch (InvalidOperationException ex) when (ex.Message.Contains(\"Azure CLI (az) not found\"))\n{\n    // install the Azure CLI or fix PATH, then rerun\n}","preventionTips":["Install az on dev machines, containers, and CI agents","Launch the AppHost from an environment where 'az --version' works","Add an Azure CLI setup step in CI before aspire deploy"],"tags":["azure","cli","dependency","path"],"backgroundTag":"command-not-found","analyzedSha":"25830f84bd145686607ad00c057b3f84e2e51d43","analyzedAt":"2026-09-16T11:10:06.193Z","contentChangedAt":"2026-09-16T11:10:06.193Z","schemaVersion":2},"datasetVersion":"2026-09-21T04:17:39.646Z"}