OiO.lk Community platform!

Oio.lk is an excellent forum for developers, providing a wide range of resources, discussions, and support for those in the developer community. Join oio.lk today to connect with like-minded professionals, share insights, and stay updated on the latest trends and technologies in the development field.
  You need to log in or register to access the solved answers to this problem.
  • You have reached the maximum number of guest views allowed
  • Please register below to remove this limitation

Azure App Service Flask Deployment Error: "Failed to Respond to HTTP Pings on Port 8000; Site Start Failed. Check Container Logs for Debugging." [clos

  • Thread starter Thread starter riddhi
  • Start date Start date
R

riddhi

Guest
I am Deploying the Flask Web app with Immersive Reader and I am deploying it by a ZIP file mentioned over the link below:

https://learn.microsoft.com/en-us/a...l,terminal-bash,deploy-instructions-zip-azcli

So, I have gone through each step mentioned there and applied it and showing me the result(look at the attached image).

https://i.sstatic.net/iVyZfxOj.png

so I check my logs on azure app service where i find the error as given below : https://i.sstatic.net/QsqmMdnZ.png

I am expecting the web page for the application i am trying to deploy.

Something like this

here is my app.py code

Code:
from flask import Flask, render_template, jsonify
import requests
import os

app = Flask(__name__)

AZURE_CLIENT_ID = os.environ['AZURE_CLIENT_ID']
AZURE_CLIENT_SECRET = os.environ['AZURE_CLIENT_SECRET']
AZURE_TENANT_ID = os.environ['AZURE_TENANT_ID']
AZURE_RESOURCE = 'https://cognitiveservices.azure.com/.default'

@app.route('/')

def index():
    return render_template('index.html')


@app.route('/get_token', methods=['GET'])

def get_token():

    url = f'https://login.microsoftonline.com/{AZURE_TENANT_ID}/oauth2/v2.0/token'
    
    headers = {
        'Content-Type': 'application/x-www-form-urlencoded'
    }
    data = {
        'client_id': AZURE_CLIENT_ID,
        'client_secret': AZURE_CLIENT_SECRET,
        'scope': AZURE_RESOURCE,
        'grant_type': 'client_credentials'
    }

    response = requests.post(url, headers=headers, data=data)
    if response.status_code == 200:
        token = response.json().get('access_token')
        return jsonify({'access_token': token})
    else:
        return jsonify({'error': 'Unable to fetch token'}), 500

if __name__ == '__main__':
    app.run(debug=True)
<p>I am Deploying the Flask Web app with Immersive Reader and I am deploying it by a ZIP file mentioned over the link below:</p>
<p><a href="https://learn.microsoft.com/en-us/a...l,terminal-bash,deploy-instructions-zip-azcli" rel="nofollow noreferrer">https://learn.microsoft.com/en-us/a...l,terminal-bash,deploy-instructions-zip-azcli</a></p>
<p>So, I have gone through each step mentioned there and applied it and showing me the result(look at the attached image).</p>
<p><a href="https://i.sstatic.net/iVyZfxOj.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/iVyZfxOj.png" alt="https://i.sstatic.net/iVyZfxOj.png" /></a></p>
<p>so I check my logs on azure app service where i find the error as given below :
<a href="https://i.sstatic.net/QsqmMdnZ.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/QsqmMdnZ.png" alt="https://i.sstatic.net/QsqmMdnZ.png" /></a></p>
<p>I am expecting the web page for the application i am trying to deploy.</p>
<p>Something like this</p>
<p>here is my app.py code</p>
<pre><code>from flask import Flask, render_template, jsonify
import requests
import os

app = Flask(__name__)

AZURE_CLIENT_ID = os.environ['AZURE_CLIENT_ID']
AZURE_CLIENT_SECRET = os.environ['AZURE_CLIENT_SECRET']
AZURE_TENANT_ID = os.environ['AZURE_TENANT_ID']
AZURE_RESOURCE = 'https://cognitiveservices.azure.com/.default'

@app.route('/')

def index():
return render_template('index.html')


@app.route('/get_token', methods=['GET'])

def get_token():

url = f'https://login.microsoftonline.com/{AZURE_TENANT_ID}/oauth2/v2.0/token'

headers = {
'Content-Type': 'application/x-www-form-urlencoded'
}
data = {
'client_id': AZURE_CLIENT_ID,
'client_secret': AZURE_CLIENT_SECRET,
'scope': AZURE_RESOURCE,
'grant_type': 'client_credentials'
}

response = requests.post(url, headers=headers, data=data)
if response.status_code == 200:
token = response.json().get('access_token')
return jsonify({'access_token': token})
else:
return jsonify({'error': 'Unable to fetch token'}), 500

if __name__ == '__main__':
app.run(debug=True)
</code></pre>
 

Latest posts

Top