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.
最新文章
- 苹果允许预装软件可卸载 或因遭受安卓手机阵型冲击
- 德国考虑立法强迫IT公司公布软件源代码
- 微软推绿色IT挑战新网站促进IT节能环保
- 软件定义存储VS硬件定义存储
- 软硬件一体化模式席卷IT业:厂商策略各有不同
- DIY台式电脑被逼走高端路线
- react native - Handling loginlogout without user undefined errors - Stack Overflow
- open source - Langgraph State not being passed properly with Ollama - Stack Overflow
- swift - How do I know how many times a thread context switch happens on an xcode Instruments? - Stack Overflow
- github - How do if fix theses syntax errors with this bash script - Stack Overflow
- shell - Does the `hash` builtin command in Bash has an `-l` option? - Stack Overflow
- python - Steps approximation for time series scatter with mean changing every K number of steps using BIC - Stack Overflow
- windows - Significant 600 ms lag between TwinCAT 3 and Simulink using TCSymbol interface (TE1410). How can I reduce this latency
- sublimetext3 - Sublime Text 34: copypaste all text excluding comments - Stack Overflow
- excel - Add a rule to the VBA to remove filters - Stack Overflow
- c# - Instantiated gameObject in Unity will not update the transform.position - Stack Overflow
- javascript - useState rerenders bindings increment when key added to object but not removed - Stack Overflow