0

I am trying to deploy my sample application to azure app service in linux. my application is a simple flask application that get's a key from the user and retrieves it's value from azure key vault.

from azure.keyvault.secrets import SecretClient
from azure.identity import DefaultAzureCredential

my requirements.txt is as follows:

azure-mgmt-resource
Flask==2.0.2
azure-identity==1.10.0
azure-keyvault-secrets==4.6.0

I have tried adding only azure but it throws me the following error and now I have no idea how to exit this loop:

  │ exit code: 1
  ╰─> [25 lines of output]
      Traceback (most recent call last):
        File "<string>", line 2, in <module>
        File "<pip-setuptools-caller>", line 34, in <module>
        File "/tmp/pip-install-x2lo6n9j/azure_e4ab6d93138d4411b0a31c7f2ffe6ad2/setup.py", line 60, in <module>
          raise RuntimeError(message)
      RuntimeError:
      
      Starting with v5.0.0, the 'azure' meta-package is deprecated and cannot be installed anymore.
      Please install the service specific packages prefixed by `azure` needed for your application.
      
      The complete list of available packages can be found at:
      https://aka.ms/azsdk/python/all
      
      Here's a non-exhaustive list of common packages:
      
      -  azure-mgmt-compute (https://pypi.python.org/pypi/azure-mgmt-compute) : Management of Virtual Machines, etc.
      -  azure-mgmt-storage (https://pypi.python.org/pypi/azure-mgmt-storage) : Management of storage accounts.
      -  azure-mgmt-resource (https://pypi.python.org/pypi/azure-mgmt-resource) : Generic package about Azure Resource Management (ARM)
      -  azure-keyvault-secrets (https://pypi.python.org/pypi/azure-keyvault-secrets) : Access to secrets in Key Vault
      -  azure-storage-blob (https://pypi.python.org/pypi/azure-storage-blob) : Access to blobs in storage accounts
      
      A more comprehensive discussion of the rationale for this decision can be found in the following issue:
      https://github.com/Azure/azure-sdk-for-python/issues/10646
      
      
      [end of output]
  
  note: This error originates from a subprocess, and is likely not a problem with pip.
error: metadata-generation-failed

× Encountered error while generating package metadata.
╰─> See above for output.

note: This is an issue with the package mentioned above, not pip.
hint: See above for details.
##[error]Bash exited with code '1'.

The pip install code I use in my azure pipeline is as follows:

  - script: |
      python -m venv env
      source env/bin/activate
      python -m pip install --upgrade pip
      python -m pip install -r requirements.txt
    displayName: 'Install dependencies'
Eli m
  • 83
  • 1
  • 7

1 Answers1

0

Cause of the error: Azure meta-package cannot be installed in the current application. Instead, install the specific provider packages that your application requires.

Install the required packages with the latest versions in the visual studio code terminal using below pip commands.

pip install azure-keyvault-secrets==4.7.0
pip install azure-identity
pip install azure-mgmt-resource
pip install Flask

Once it is updated all the required packages, use below pip command to update the requirements.txt file.

pip install -r requirements.txt

You can find all the Azure SDK's here in Azure SDK releases.

Installed & updated successfully:

enter image description here

To check whether the flask is running fine, I created a sample application, and it ran successfully as shown:

enter image description here

Refer key vault secret client library for more relevant information as per your requirement.

Jahnavi
  • 3,076
  • 1
  • 3
  • 10
  • Hello @Jahnavi and thank you for your answer, I am not working with vs code and the issue happens after deployment (I have edited the question and added the pipeline part - I am using the same sample app that you shared but instead of inserting my name, I insert the key i want to retrieve the value from key vault (have a try) - locally it worked for me but after deploy not – Eli m Mar 28 '23 at 10:57
  • Make sure that you are running `pip install -r requirements.txt` before running the script of the pipeline itself and add the required packages with the pip command in your pipeline script as I detailed in the above answer. @Elim – Jahnavi Mar 29 '23 at 08:07
  • If still the issue persists, try deleting a virtual environment and create a new virtual environment of python and run the script. @Elim – Jahnavi Mar 29 '23 at 08:09