Azure Monitor subscriptionid as variable

We need to get the SubscriptionID from the selected data source to use it in the Resource URI when querying logs. I can’t seem to see a function that returns the SubscriptionID for the selected azure data source?

Have you tried the built in template variables?
Azure Monitor template variables | Grafana documentation

Subscriptions() Returns subscriptions