Home > Net >  Airflow connection for Azure
Airflow connection for Azure

Time:12-24

I am learning Airflow for my job and I am stuck in a very simple problem which I can't figure out the solution for.

I want to add a simple azure blob connection via the airflow GUI, but for some reason, whenever I try to test the connection it gets a BAD REQUEST response back, see example below:

enter image description here

I have tried login with SAS token and with service principal, which did not work too.

At some point, I thought it could be caused by some lack of the correct permissions, but when I tried to login in via az cli using the service principal, I can see the resources just fine (works fine as well using the authentication via Python).

I am running airflow on a docker image, so I thought it could be that the azure provider was not installed, so I opened a shell session in the docker image via docker exec -it airflow-webserver /bin/bash and manually installed the providers via pip, which did not resolve the problem either.

Does anyone have an idea of what I can try next?

CodePudding user response:

The current implementation of the Test Connection button in the UI is either enabled/disabled relative only to the enablement of Airflow REST APIs within an environment. Meaning if REST APIs are enabled, the Test Connection button is enabled for all connection types even if a selected type doesn't actually support testing connectivity in this way.

This button is really only functional if the underlying hook has a test_connection() method and unfortunately the WasbHook (which is used by the Azure Blob Storage connection type) does not. This is why you are seeing the "BAD REQUEST" error. It is not because your connection is misconfigured, per se, but just that the testing functionality isn't built in.

There was an PR to fix this but it has not been released yet.

If you find it helpful, there is some Airflow documentation on creating Azure Blob Storage connections: https://airflow.apache.org/docs/apache-airflow-providers-microsoft-azure/stable/connections/wasb.html

  • Related