Azure / Azure/azure-cli-extensions

`az extension list-available` is super slow - Store index.json somewhere else?

Open
#7,874 2 comments 0 reactions 1 assignee Claimed by @jsntcy View on GitHub
Azure CLI Team customer-reported question
Dominant language
Python
Stars
454
Forks
1.7k
Avg merge
2d 19h
Merged PRs (30d)
64

Description

### Describe the bug

`az extension list-available` is super slow, it takes seconds just to fetch `index.json` from `https://aka.ms/azure-cli-extension-index-v1`. Most likely because it's stored on a single region Azure storage account, blob storage. Related to:

*

Here are some ideas to make it faster:

1. Store it somewhere else.
* What about just pointing to [`index.json` in the main branch](https://raw.githubusercontent.com/Azure/azure-cli-extensions/main/src/index.json)?
* Azure static web app with CDN?
1. Reduce file size of `index.json`: We're usually only interested in knowing what's the latest version available. Create a `index-latest.json` with just the latest stable and preview version? `index.json` will just continue growing.
1. Cache `index.json` locally, don't attempt to refetch it every CLI command that needs it.
* Invalidate local version of `index.json` after 15 minutes?
* Version `index.json`, then Azure CLI can check local cached version vs. what's available. Which should be much faster than fetching `index.json`. Use GitHub releases?

### Related command

```pwsh
# Fastest - Use GitHub repo
$AvailableExtensions = [PSCustomObject](
(Invoke-RestMethod -Method 'Get' -Uri 'https://raw.githubusercontent.com/Azure/azure-cli-extensions/main/src/index.json').'extensions'
)

# Use same URI as CLI
## Before redirect
$AvailableExtensions = [PSCustomObject](
(Invoke-RestMethod -Method 'Get' -Uri 'https://aka.ms/azure-cli-extension-index-v1').'extensions'
)

## What redirect goes to
$AvailableExtensions = [PSCustomObject](
(Invoke-RestMethod -Method 'Get' -Uri 'https://azcliextensionsync.blob.core.windows.net/index1/index.json').'extensions'
)

# Use CLI
$AvailableExtensions = [array](
az extension list-available | ConvertFrom-Json
)
```

### Errors

None

### Issue script & Debug output

None

### Expected behavior

Would be nice it if was faster

### Environment Summary

Azure CLI v2.43.0

### Additional context

_No response_

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.