我试图通过提供用户名和密码来使用Process.Start命令在azure函数(v2)中运行可执行文件
string nwPath = <path/to/bla.exe>
string dirName = Path.GetDirectoryName(nwPath);
var processInfo = new ProcessStartInfo()
{
WorkingDirectory = dirName,
FileName = nwPath,
UserName = <username>,
Password = secureString,
Domain = <domain>,
UseShellExecute = false,
Arguments = @"p1 p3",
Verb = "runas"
};
Process.Start(processInfo);
此功能通过传入的用户名和密码在本地运行。当我将其部署到天蓝色时,我得到以下错误访问被拒绝
我已经通过单击上载按钮在azure函数中上载了可执行文件,并且可执行文件路径为
C:\home\wwwroot\functionname\bla.exe
如果我使用以下命令运行该过程,它将在azure上运行
Proccess.Start(@"path/to/bla.exe")
我假设在用户下运行的进程无权访问可执行文件。
我们可以授予用户访问Azure函数中可执行文件的权限吗?
由于azure func的体系结构,您似乎无法指定用户权限。
尝试使用HostingPath
作为一个WorkingDirectory
在ProcessStartInfo
private static string HostingPath =>
Environment.GetEnvironmentVariable("AzureWebJobsScriptRoot") // local_root
?? (Environment.GetEnvironmentVariable("HOME") == null
? Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location)
: $"{Environment.GetEnvironmentVariable("HOME")}/site/wwwroot");
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句