I have the following code which I use to acquire a secret, use secret to log into portal and download a csv table. This works ok outside a function.
import pandas as pd
import pandas as pd
from arcgis.gis import GIS
from azure.identity import DefaultAzureCredential
from azure.keyvault.secrets import SecretClient
credential = DefaultAzureCredential()
secret_client = SecretClient(vault_url="https://xxxx-dev-vault.vault.azure.net/", credential=credential)
secret = secret_client.get_secret("Secret")
#Log into portal
gis = GIS("https://url.com", "Username", secret.value)
#Extracting Table
item=gis.content.get('content_id')
table=item.layers[0].query().sdf
I need to include this bit of code in in my httptrigger so that the function logs into portal, extracts csv/table so that the table is returned as a json body of the trigger response or is stored into a blob. How can I achieve this?
I initially thought I could achieve this by integrating the vault in the http trigger in this post. However, I ended up with the Secret being returned instead and I have been unable to use the secret within the function.
I dont mind, even an example logging into an email account or any other portal will suffice provided the secret password is acquired within the function runtime. Ultimately, I am interested in understanding how to retrieve a secret and use it within a function to power/resource a function output.