C# Push Files to Bitbucket repository from an Azure App Service? C# Push Files to Bitbucket repository from an Azure App Service? azure azure

C# Push Files to Bitbucket repository from an Azure App Service?


In case of Azure Apps you can still bundle embedded exes, There a portable Git available on below link

https://github.com/sheabunge/GitPortable

You should bundle that with your app and create a batch file as well. And then you should launch it using C# code

static void ExecuteCommand(string command){    var processInfo = new ProcessStartInfo("cmd.exe", "/c " + command);    processInfo.CreateNoWindow = true;    processInfo.UseShellExecute = false;    processInfo.RedirectStandardError = true;    processInfo.RedirectStandardOutput = true;    var process = Process.Start(processInfo);    process.OutputDataReceived += (object sender, DataReceivedEventArgs e) =>        Console.WriteLine("output>>" + e.Data);    process.BeginOutputReadLine();    process.ErrorDataReceived += (object sender, DataReceivedEventArgs e) =>        Console.WriteLine("error>>" + e.Data);    process.BeginErrorReadLine();    process.WaitForExit();    Console.WriteLine("ExitCode: {0}", process.ExitCode);    process.Close();}

PS: Credits Executing Batch File in C#

Another SO thread that talk about something similar

Azure App Service, run a native EXE to convert a file

How to run a .EXE in an Azure App Service

Run .exe executable file in Azure Function


I think instead of the local disk of the App Service, you should use Azure storage, because later when you have to scale your service, on scale down, some content might get lost from the D:\home\site\wwwroot\repo folder, of if you scale out, the different instances will have different content in this folder.

And if you check your App Services console:git preinstalledYou can see the git is already preinstalled, so you don't really need any lib or portable git, you can just run your git command with the System.Diagnostics.Process.Start() method.