@Huu Nguyen Thanks for reaching out to Microsoft Q&A, apologize for any inconvenience caused on this.
Based on the shared information, I understand that you want to pull the runtime version of app service that is running on Linux with runtime php8.2.
To achieve your requirement, follow the below steps and use the python code.
- Create a service principal and assign the contributor access to it at resource group level.
- create a
.env
file in your application root directory. Set the environment variable values with values obtained from the service principal creation.
AZURE_CLIENT_ID=00000000-0000-0000-0000-000000000000
AZURE_TENANT_ID=11111111-1111-1111-1111-111111111111
AZURE_CLIENT_SECRET=abcdefghijklmnopqrstuvwxyz
- Create an .py file and use the below code to fetch the runtime version of the app service.
Python Code:
from azure.mgmt.web import WebSiteManagementClient
from azure.identity import DefaultAzureCredential
import os
from dotenv import load_dotenv
subscription_id = "<subscriptionId>"
load_dotenv(".env")
token_credential = DefaultAzureCredential()
Client= WebSiteManagementClient(token_credential, subscription_id)
app=Client.web_apps.get("<ResourceGroupName>", "<WebAppName>")
print(app.site_config.linux_fx_version)
Note: In the above python code, we are using service principals to authenticate, here is the reference documentation for it. Also, Make the changes to above code based on your requirement.
Feel free to reach back to me if you have any further questions on this.