{"record":{"id":"641d62732c07a926","repo":"dotnet/runtime","slug":"azure-failed-to-download","errorCode":null,"errorMessage":"Azure failed to download","messagePattern":"Azure failed to download","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"src/coreclr/scripts/jitutil.py","lineNumber":649,"sourceCode":"    ok = True\n    az_credential = AzureCliCredential()\n    blob = BlobClient.from_blob_url(uri, credential=az_credential)\n    with open(target_location, \"wb\") as my_blob:\n        try:\n            download_stream = blob.download_blob(retry_total=0)\n            try:\n                my_blob.write(download_stream.readall())\n            except Exception as ex1:\n                logging.error(\"Error writing data to %s\", target_location)\n                report_azure_error()\n                ok = False\n        except Exception as ex2:\n            logging.error(\"Azure error downloading %s\", uri)\n            report_azure_error()\n            ok = False\n\n    if not ok and fail_if_not_found:\n        raise RuntimeError(\"Azure failed to download\")\n    return ok\n\n################################################################################\n##\n## File downloading functions\n##\n################################################################################\n\n\ndef download_progress_hook(count, block_size, total_size):\n    \"\"\" A hook for urlretrieve to report download progress\n\n    Args:\n        count (int)               : current block index\n        block_size (int)          : size of a block\n        total_size (int)          : total size of a payload\n    \"\"\"\n    sys.stdout.write(\"\\rDownloading {0:.1f}/{1:.1f} MB...\".format(min(count * block_size, total_size) / 1024 / 1024, total_size / 1024 / 1024))","sourceCodeStart":631,"sourceCodeEnd":667,"githubUrl":"https://github.com/dotnet/runtime/blob/60108ba66eb7d1d12f595480091b4ad80a24b172/src/coreclr/scripts/jitutil.py#L631-L667","documentation":"Raised by download_with_azure() in jitutil.py. It opens a BlobClient and tries blob.download_blob(); if the download or the local write throws, ok is set False and, when fail_if_not_found is True, the function raises 'Azure failed to download'. The accompanying logs (via report_azure_error) point to CLI authentication.","triggerScenarios":"Azure blob download fails due to no `az login`, expired credentials, a 404 (blob missing) with fail_if_not_found=True, a network/IO error, or a local disk write error while streaming the blob.","commonSituations":"Forgot to run `az login`; Azure CLI not installed; the blob/git-hash does not exist in storage; transient network failure; insufficient disk space or permissions on target_location.","solutions":["Run `az login` to authenticate the Azure CLI, then retry.","Install the Azure CLI if missing (see https://learn.microsoft.com/cli/azure/install-azure-cli).","Verify the URI/blob exists (e.g. check the git hash / collection name) — a 404 with fail_if_not_found surfaces here.","Check disk space and write permissions for target_location; retry on transient network errors."],"exampleFix":"// before\npython superpmi.py download ...   # 'Azure failed to download'\n// after\naz login\npython superpmi.py download ...","handlingStrategy":"retry","validationCode":"import subprocess\nif subprocess.call([\"az\", \"account\", \"show\"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL) != 0:\n    raise SystemExit(\"Not logged in to Azure CLI; run `az login` before downloading\")","typeGuard":null,"tryCatchPattern":"from jitutil import download_with_azure\nfor attempt in range(3):\n    try:\n        ok = download_with_azure(uri, target, fail_if_not_found=True)\n        break\n    except RuntimeError:\n        if attempt == 2:\n            raise\n        logging.warning(\"Azure download failed, retrying (%d/3)\", attempt + 1)","preventionTips":["Run `az login` and verify `az account show` succeeds before scripted downloads.","For optional blobs, call with fail_if_not_found=False and handle the False return."],"tags":["jitutil","azure","download","authentication","network","python"],"backgroundTag":null,"analyzedSha":"60108ba66eb7d1d12f595480091b4ad80a24b172","analyzedAt":"2026-08-10T18:54:11.478Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}