Azure App Service ARM Templates - Run Command in the Console - azure

I am currently building an ARM Template that deploys the following.
App Service Plan
App Service
MS Deploy .NET Core Application on the App Service
The problem is that after the .NET Core Application is deployed I want to execute a command in the console. I have tried a couple of different ways to do it via the CustomScriptExtension, but I keep getting :
"No route registered for '/CustomScriptExtension?api-version=2015-06-15'"
Which makes me think that the Custom Script Extensions are supported for VMs only and not for App Services (I am a bit new to ARM Templating and there is nothing useful I could find in the Azure Quickstart Templates).
Any suggestions on how I can execute a simple command in the App Service command promt via an ARM Template ?

I use the runcommand option of msdeploy to run a command after deployment.
In my case I added a manifest.xml to the root of the zip file that will be deployed:
<MSDeploy.iisApp>
<runcommand path="move D:\home\site\wwwroot\applicationHost.xdt D:\home\site\" dontUseCommandExe="true" MSDeploy.MSDeployKeyAttributeName="path" />
</MSDeploy.iisApp>
The "MSDeploy.MSDeployKeyAttributeName="path"" is important. More details here.
The content of the path attribute will be executed on the remote mashine.
I hope this helps,
KirK

Related

creating azure webapp for php web application

I uploaded folder Called Chat contains index.php for chat application to azure from the cloud power shell. now if I change the directory to Chat and run the command (az webapp up --runtime "PHP|7.3") I get the following error:
Could not auto-detect the runtime stack of your app.
HINT: Are you in the right folder?
For more information, see 'https://go.microsoft.com/fwlink/?linkid=2109470'
how can I deploy this php app from the cloud shell??
As mentioned in the link referenced in the error message, the current support for az webapp up includes apps targeting:
Python
Node
ASP .NET and - .NET Core
As part of the execution of az webapp up command it performs a best effort detection to match your code (in your local directory) with a supported runtime in your Web App. If you want to set the runtime manually you can use the az webapp create command.
For a detailed walkthrough on how to deploy a PHP app to Azure App Service, please follow this quickstart depending on your desired hosting platform (Windows/Linux).

Trying to get Azure Devops pipeline to run the app dll

I have azure devops publishing a dotnet core web app to an AWS server, but the app serilog logs are not kicking in because even though the DLLS etc are updated the myapp.dll is not re-started, so the logging setup code in program.cs is not executed.
If I run the app in powershell using "dotnet myapp.dll" then the logging file appears but that starts a seperate process on a different port... so it doesnt help.
The app runs under IIS on the server and Im not sure if this is a devops issue or something i need to do in IIS..
I added this as the last step to the pipeline but I get an error
You misspelled a built-in dotnet command.
You intended to execute a .NET Core program, but dotnet-.\myWork.dll does not exist.
You intended to run a global tool, but a dotnet-prefixed executable with this name could not be found on the PATH.
The pipeline doesn't start your application. Even if it worked, you would have an app running on the Agent that's executing the pipeline, not on your server.
If you want the app hosted on your server, I'd start with Publish an ASP.NET Core app to IIS tutorial.
Get it deployed on your server manually and ensure it's running correctly. But don't do right-click publish - use commandline all the way.
Once you know what are the necessary steps (and what might go wrong), you can start automating it.

How FTP deploy .NET Core WebApp to Azure Linux App Service plan

I want do deploy code to Linux App service plan over FTP but I fail because I am missing a step how to "say to app service to use app DLL instead of default one".
Code is copied, I even uploaded test zip file and I can't download it, getting error 404 so how did Microsoft imagine to deploy code over FTP? I couldn't find any info in their documentation regarding this exact case.
I want to avoid using docker file, If this can't be done I'll simply switch to using Windows based App service plan.
In application setting screen of your WebApp mention the startup file name
dotnet

Azure Devops - How to run a powershell script on an App Service post-deploy?

I'm struggling to understand how to run a powershell script (it just runs an exe) on the App Service after deployment using Azure Devops.
FYI - the exe just reads some config info in the web.config and does some database updates. So it needs access to the transformed web.config and the SQL Server database that the App Service has.
I've tried adding a Powershell step using a Release Pipeline deployment task, but it seems to only run on the Agent, which does not have the context that the exe needs.
I can run the script manually using the Kudu command line window tool, but I need to automate this thing.
I've seen a few SO articles like this: How to add a custom post deployment script to azure websites? or Kudu post-deployment commands not running but I think that only works when you use the inbuilt deployment mechanism for App Services. ie - I couldn't get it to trigger the script in post-deploy from Azure Devops.
This is in the comments above, but if people find it useful, the answer to this is
Using the Azure App Service Deploy task, expand Post Deployment Action, there's an option to run a script (or inline write one).
This will be executed as part of the app service deployment and should allow you to do what you want. It's run at the wwwroot folder so the files need to be present in your actual deployment (zip/folder).

Can I publish a ASP.NET Core app into an Azure AppService on a Linux Service Plan from Visual Studio?

I just need to deploy a aspnet core app into a Linux Service Plan.
I tried pre-creating the Linux service plan (into it's own Resource Group) from portal, and then starting the publish profile creating process in VS, but it does not show the linux Resource Group or Service Plan.
I can only find references to doing this from a Linux machine using Git-integration.
Thanks in advance,
Jose Parra
Unfortunately, for now we cannot deploy web app to Azure linux service plan through VS. It's by design that we can only see windows service plan in VS publish process.
However there are alternatives for us to choose.
FTP-- Upload pre-compiled files(under ~/bin/Debug(Release) folder) to website. Here's the reference.
Local Git--You may have read this tutorial. Note that Git bash can also be used in Windows.
GitHub--Follow this reference to connect VS with your GitHub, then config Deployment option in portal. After that your code will be deployed automatically once pushed to GitHub.
There are some other deployment ways like CI/CD aka Continuous Delivery in portal and another source control tool BitBucket. I recommend you to use GitHub as it's simple to operate in VS after configuration.

Resources