Azure / azure-cli-extensions

Public Repository for Extensions of Azure CLI.
https://docs.microsoft.com/en-us/cli/azure
MIT License
382 stars 1.22k forks source link

Question: Installing extensions in offline environments #2484

Open NenoLoje opened 4 years ago

NenoLoje commented 4 years ago

(Note: This is a cross-post from https://github.com/Azure/azure-devops-cli-extension/issues/1055)

How to set up an Azure CLI extension in an offline environment?

I see that the Azure CLI supports installing from a local source like this: az extension add –source …

… but this doesn't seem to be enough. (I'm trying to install the Azure DevOps extension and it fails when it runs "pip", which tries to connect to public sources…).

Any tips on how an offline / or x-copy-like deployment looks like?

yungezz commented 4 years ago

hi @fengzhou-msft could you pls help on this?

DevOpsBoondoggles commented 3 years ago

I'm having same problem due to trying to go through corporate proxy and I just keep hitting more and more stuff that wants whitelisted. I'd really love to be able to just download the extensions and required packages offline and distribute them internally as I won't get this past security in current state. Azure Devops cli extension seems to be only way for universal package uploads for instance ?

NenoLoje commented 3 years ago

@gabrielmccoll Specifically for the case you mentioned regarding uploading/downloading universal packages, the workaround I used is to:

Hope it helps!

DevOpsBoondoggles commented 3 years ago

@gabrielmccoll Specifically for the case you mentioned regarding uploading/downloading universal packages, the workaround I used is to:

  • install an 🚀 Azure Pipelines agent on that machine (the corporate firewall in my case had the neccessary execptions it already configured)

  • and use the Universal Package task (which supports up- and downloading). No need to install Azure CLI or the Azure DevOps extension at all.

Hope it helps!

That is a nice wee work around thank you

JariSal commented 3 years ago

Also I'm trying to install Azure DevOps extension into a separate development machine, but corporate proxy prevents the pip to fetch the required modules from pypi.org. I've installed those modules manually, but DevOps extension does not check the currently installed modules and tries to fetch those from pypi.org every time. Any possibilities to make DevOps installation to just use already installed modules?

fengzhou-msft commented 3 years ago

@JariSal the extension is not installed in standard python package location, you can check with az --version. By default it's ~/.azure/cliextensions. Please install its dependency packages under ~/.azure/cliextensions/azure-devops/

fengzhou-msft commented 3 years ago

azure-devops currently specifies 3 dependencies, only distro is not in azure-cli (the version requirement for python-dateutil is different, not sure if it will cause problems). @NenoLoje you need to install azure-devops with --no-deps and then install the distro package with --target ~/.azure/cliextensions/azure-devops

https://github.com/Azure/azure-cli-extensions/blob/3e711c42dbe336230ba3274fe3cf77a43b25c48b/src/index.json#L3066-L3068

ghost commented 3 years ago

Thanks for the feedback! We are routing this to the appropriate team for follow-up. cc @narula0781, @ashishonce, @romil07.

Issue Details
(Note: This is a cross-post from https://github.com/Azure/azure-devops-cli-extension/issues/1055) How to set up an Azure CLI extension in an **offline environment**? I see that the Azure CLI supports installing from a local source like this: `az extension add –source …` … but this doesn't seem to be enough. (I'm trying to install the Azure DevOps extension and it fails when it runs "pip", which tries to connect to public sources…). **Any tips on how an offline / or x-copy-like deployment looks like?**
Author: NenoLoje
Assignees: fengzhou-msft
Labels: `DevOps`, `Packaging`, `Service Attention`, `question`
Milestone: -
fengzhou-msft commented 3 years ago

Route to service team to see if they can remove the msrest and python-dateutil dependencies which are already installed with the azure-cli package. distro is a very simple package, you may also considering vendoring its source code.

dimalyshev commented 3 years ago

Hope it helps command from https://docs.microsoft.com/en-us/cli/azure/extension?view=azure-cli-latest az extension add --source ~/anextension-0.0.1-py2.py3-none-any.whl --pip-proxy https://user:pass@proxy.server:8080

as for me this works first dowload what you need from https://azcliextensionsync.blob.core.windows.net/index1/index.json

to install devops extension python.exe -m pip install --target "~\.azure\cliextensions\azure-devops" azure_devops-0.12.0-py2.py3-none-any.whl --proxy "http://proxy_to_pip_repo/" -vv --disable-pip-version-check --no-cache-dir --trusted-host pypi.org --trusted-host files.pythonhosted.org

to install devops login dependency python.exe -m pip install --target "~\.azure\cliextensions\azure-devops" keyring~=17.1.1 --proxy "http://proxy_to_pip_repo/" -vv --disable-pip-version-check --no-cache-dir --trusted-host pypi.org --trusted-host files.pythonhosted.org

TheOnlyWei commented 5 months ago

Hi @fengzhou-msft, are there any updates for this? We need to install Azure CLI extensions on disconnected environments. Would be good if there is a work-around or script to set up an environment so that customers can run Azure CLI extension commands in an offline environment without differences in user-experience.

sonnykt commented 2 months ago

Using the suggestion from @dimalyshev, I am able to manually install the Azure DevOps extension on an offline Linux VM:

    # Install the azure-devops extension
    /opt/az/bin/python3 -m pip instal --disable-pip-version-checkl --target ~/.azure/cliextensions/azure-devops --no-deps distro-1.3.0-py2.py3-none-any.whl
    /opt/az/bin/python3 -m pip instal --disable-pip-version-checkl --target ~/.azure/cliextensions/azure-devops --no-deps azure_devops-1.0.1-py2.py3-none-any.whl