cancel
Showing results forย 
Search instead forย 
Did you mean:ย 
Data Engineering
Join discussions on data engineering best practices, architectures, and optimization strategies within the Databricks Community. Exchange insights and solutions with fellow data engineers.
cancel
Showing results forย 
Search instead forย 
Did you mean:ย 

Access Azure App service failed with 403 response

johnp
New Contributor III

We have an Azure app service written in Django.  From databricks notebook we sent curl command to test the connection between databricks and Azure AppService.  We got the following repsonse:

Error 403 - Forbidden

The web app you have attempted to reach has blocked your access.

How do I setup the the Django web service so Databrick notebook can access it?

 

1 ACCEPTED SOLUTION

Accepted Solutions

Kaniz_Fatma
Community Manager
Community Manager

Hi @johnp

Certainly! To set up your Django web service so that Databricks notebooks can access it, follow these steps:

  1. Sample Application:

  2. Create a Web App in Azure:

    • To host your application in Azure, create an Azure App Service web app:
      • You can use the Azure CLI, VS Code, Azure Tools extension pack, or the Azure portal.
      • Azure CLI commands:
        • Install the Azure CLI if you havenโ€™t already.
        • Log in to Azure using az login.
        • Create the web app and other resources, then deploy your code to Azure using:
          az webapp up --runtime PYTHON:3.9 --sku B1 --logs
          
          (Replace --runtime with the appropriate Python version if needed.)
  3. Configure Access:

    • Ensure that your Django app allows access from Databricks by configuring CORS (Cross-Origin Resource Sharing) settings.
    • In your Django appโ€™s settings, add the following middleware:
      MIDDLEWARE = [
          # ...
          'corsheaders.middleware.CorsMiddleware',
          # ...
      ]
      
    • Set the CORS_ALLOW_ALL_ORIGINS setting to True:
      CORS_ALLOW_ALL_ORIGINS = True
      
    • You can also specify specific origins if needed:
      CORS_ALLOWED_ORIGINS = [
          "https://your-databricks-url",
          # Add other allowed origins here
      ]
      
  4. Deploy to Azure:

    • Deploy your Django app to Azure using the same steps as mentioned earlier.
    • Once deployed, your Databricks Notebooks should be able to access your Azure App Service.

Remember to replace placeholders like your-databricks-url with the actual URLs relevant to your setup. If you encounter any issues, feel free to ask for further assistance! ๐Ÿš€๐ŸŒ

 

View solution in original post

1 REPLY 1

Kaniz_Fatma
Community Manager
Community Manager

Hi @johnp

Certainly! To set up your Django web service so that Databricks notebooks can access it, follow these steps:

  1. Sample Application:

  2. Create a Web App in Azure:

    • To host your application in Azure, create an Azure App Service web app:
      • You can use the Azure CLI, VS Code, Azure Tools extension pack, or the Azure portal.
      • Azure CLI commands:
        • Install the Azure CLI if you havenโ€™t already.
        • Log in to Azure using az login.
        • Create the web app and other resources, then deploy your code to Azure using:
          az webapp up --runtime PYTHON:3.9 --sku B1 --logs
          
          (Replace --runtime with the appropriate Python version if needed.)
  3. Configure Access:

    • Ensure that your Django app allows access from Databricks by configuring CORS (Cross-Origin Resource Sharing) settings.
    • In your Django appโ€™s settings, add the following middleware:
      MIDDLEWARE = [
          # ...
          'corsheaders.middleware.CorsMiddleware',
          # ...
      ]
      
    • Set the CORS_ALLOW_ALL_ORIGINS setting to True:
      CORS_ALLOW_ALL_ORIGINS = True
      
    • You can also specify specific origins if needed:
      CORS_ALLOWED_ORIGINS = [
          "https://your-databricks-url",
          # Add other allowed origins here
      ]
      
  4. Deploy to Azure:

    • Deploy your Django app to Azure using the same steps as mentioned earlier.
    • Once deployed, your Databricks Notebooks should be able to access your Azure App Service.

Remember to replace placeholders like your-databricks-url with the actual URLs relevant to your setup. If you encounter any issues, feel free to ask for further assistance! ๐Ÿš€๐ŸŒ

 

Connect with Databricks Users in Your Area

Join a Regional User Group to connect with local Databricks users. Events will be happening in your city, and you wonโ€™t want to miss the chance to attend and share knowledge.

If there isnโ€™t a group near you, start one and help create a community that brings people together.

Request a New Group