I would like to call an azure function from other Function. To do this job I have this code:
public static class Function1
{
[FunctionName("Function1")]
public static void Run(
[HttpTrigger(AuthorizationLevel.Function, "get", Route = null)] HttpRequest req,
ILogger log)
{
Uri m;
string t;
var data = new
{
name = "master"
};
string result = string.Empty;
var askForlicenseURL = "https://<myFunctionname>/api/HttpTrigger_StartOrchestrator";
var content = new StringContent(data.ToString(), Encoding.UTF8, "application/json");
using (HttpClient client = new HttpClient())
{
client.DefaultRequestHeaders.Add("x-functions-key", "Md5xxxxxxxxxxxxxxxxxxxxx0ij5A==");
using (HttpResponseMessage response = client.PostAsync(askForlicenseURL, content).Result)
using (HttpContent respContent = response.Content)
{
// ... Read the response as a string.
var tr = respContent.ReadAsStringAsync().Result;
// ... deserialize the response, we know it has a 'result' field
dynamic azureResponse = JsonConvert.DeserializeObject(tr);
// ... read the data we want
result = azureResponse.statusQueryGetUri;
var Header = response.Headers.Location;
}
}
}
In sted of Azure Function key I would like to use system assignedmanaged Identity. (The manaagement Identity of caller is authorized as contributer in target azure function
AND I know alternatively I can use Durable Function, but in this case I dont want to use it :)
.PostAsync().ResultInstead make the entire Function async and useawait