python - Deploy Flask, Pyspark code in azure app service - Stack Overflow
Below code which i was used to deploy the code for testing the azure app service working or not. But the code not working as expected, home_page was working but process_data is not working facing the 500 error. So my question is whether we can able to run the app service for the spark. Finally it is working in my local system but not in the azure for the spark.
spark = SparkSession.builder \
.appName("PySparkApp") \
.master("local[*]") \
.config("spark.driver.bindAddress", "0.0.0.0") \
.config("spark.ui.enabled", "false") \
.config("spark.python.worker.reuse", "true") \
.getOrCreate()
spark.sparkContext.setLogLevel("ERROR") # Suppress non-critical logs
@app.route('/')
def home_page():
return "Welcome To Home Page..."
@app.route('/process')
def process_data():
# Create a DataFrame with some example data
df = spark.createDataFrame([
Row(id=1, rate=2.0, description='string1', date=date(2000, 1, 1),datetime=datetime(2000, 1, 1, 12, 0)),
Row(id=2, rate=3.0, description='string2', date=date(2000, 2, 1), datetime=datetime(2000, 1, 2, 12, 0)),
Row(id=4, rate=5.0, description='string3', date=date(2000, 3, 1), datetime=datetime(2000, 1, 3, 12, 0))
])
# Convert to JSON without pandas
data = df.rdd.map(lambda row: row.asDict()).collect()
# Return data as JSON
return jsonify(data)
I tried configure all the spark, java and hadoop but still no luck.
最新文章
- SaaS 的历史与变革
- 拥抱安卓的诺基亚能否逆势崛起?
- 苹果兜售没用软件脸不红心不跳
- maven - How can I get the dependencies about the master code of mule? - Stack Overflow
- frontend - Rescript and Fetch with Post Request - Stack Overflow
- c# - Loading data to dataGridView freezes the window during loading, why threading does not work here? - Stack Overflow
- python - Plotting a list of integer 3d values into Axes3d.voxels - Stack Overflow
- OpenAI Assistant: File Search tool stops working when I enable custom function calling - Stack Overflow
- overlap - Canvas3D obscures JMenuBar - Stack Overflow
- c - sorry, unimplemented: Thumb-1 ‘hard-float’ VFP ABI - arm-linux-gnueabihf-gcc - targeting armv6 - Stack Overflow
- flutter - Retrieving tokens from aad_b2c_webview - Stack Overflow
- VS Code extension for collapsing sub-folders - Stack Overflow
- imagemagick - How to add annotations in Right-To-Left (RTL) languages (like Arabic and Persian) to images using R's magi
- php - Add Algorithm to the XML tag generated by SOAP - Stack Overflow
- swift - Infinite Update Loop with .onGeometryChange and Padding - Stack Overflow
- How to Use GraalVM to Execute JavaScript Code Making REST Calls Using Java? - Stack Overflow
- python - How to optimise this simulation of a lottery? - Stack Overflow