Нам нужно получить исполняемый файл, а затем выполнить его. Возьмите пример триггера v2 c # http.
public static async Task<IActionResult> Run(
[HttpTrigger(AuthorizationLevel.Function, "get", "post", Route = null)] HttpRequest req,
ILogger log)
{
//Download file first
CloudStorageAccount storageAccount = CloudStorageAccount.Parse("StorgeConnectionString");
CloudBlobClient cloudBlobClient = storageAccount.CreateCloudBlobClient();
CloudBlobContainer cloudBlobContainer = cloudBlobClient.GetContainerReference("mycontainer");
string fileName = "Console.exe";
CloudBlockBlob cloudBlockBlob = cloudBlobContainer.GetBlockBlobReference(fileName);
// Use this path to store file in case the Azure site is read-only
string path = "D:\\home\\data";
if (!Directory.Exists(path))
{
Directory.CreateDirectory(path);
}
string wholePath = Path.Combine(path, fileName);
await cloudBlockBlob.DownloadToFileAsync(wholePath, FileMode.OpenOrCreate);
// Execute
System.Diagnostics.Process process = new System.Diagnostics.Process();
process.StartInfo.FileName = wholePath;
process.StartInfo.UseShellExecute = false;
process.StartInfo.CreateNoWindow = true;
process.StartInfo.RedirectStandardOutput = true;
process.StartInfo.RedirectStandardError = true;
process.Start();
process.WaitForExit();
string output = process.StandardOutput.ReadToEnd();
string error = process.StandardError.ReadToEnd();
int exitcode = process.ExitCode;
if (exitcode == 0)
{
log.LogInformation($"Executed, output: {output}");
return new OkObjectResult($"Executed, output: {output}");
}
else
{
log.LogError($"Fail to process due to: {error}");
return new ObjectResult($"Fail to process due to: {error}")
{
StatusCode = StatusCodes.Status500InternalServerError
};
}
}