Start azure project from command line - asp.net

We have an ASP .Net (not CORE) project. There is a different Azure project as startup that starts the Azure emulator and then the website via IISExpress. I want to write some UI tests against the website. How do I start the Azure project from the command line?
Also, I've tried launching the website directly with IISExpress in the command line and getting an error; so I'm trying to take the approach of launching the Azure project from the command line instead.

To invoke the ASP.NET Application using command line via IISExpress, you can use the below command and start IISExpress and then invoke the web request with specific URL and port. And if you are trying to publish the web app to azure , then try to invoke the web request with the Azure Web App URL.
Hope above information helps.

Related

Why az login command does not work on Azure when executed with power shell command that runs from dot net code?

I have an ASP.Net Web Application which tries to log into Azure using power shell commands. The following code is being used for this purpose:
Runspace runspace = RunspaceFactory.CreateRunspace();
runspace.Open();
Pipeline pipeline = runspace.CreatePipeline();
pipeline.Commands.AddScript("az login -u 'vtripathi#hsdyn.com' -p '********'");
pipeline.Commands.Add("Out-String");
var output = pipeline.Invoke();
string result = output[0].ToString();
The problem here is that when I run this application locally on my system, it manages to log into Azure successfully, but when I deploy the same application on Azure app service, I get the below error:
Server Error in '/' Application.
The term 'az' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
Please suggest what might be wrong.
Az Login is a command from the Azure CLI, therefore to run this the CLI needs to be installed on the machine you are running it on. CLI will not be installed on an Azure Web app.
If your writing a .net web app you really want to be using the .net Azure API to talk directly to the Azure REST API, not trying to use CLI.

How to host a console application on Azure by uploading .exe file?

I have an web application (ASP.NET MVC) host on Azure web app service and an console application (C#) as http trigger locally. This Azure web app service will call the .exe once when it's running. They run well this way.
Now I'd like to move the .exe file to Azure and call it from Azure app service. But I only find Azure function app to execute a piece of code written using Azure portal. Is there a possible solution for me to simply upload this exe file to Azure and can be called by Azure app service ?
Thanks in advance.
It seems that you would call your console application as http trigger when web app run. If so, you may need to upload your console application as a Azure webjob.
You could right click your console app and choose "Publish as Azure Webjobs" to publish your console app to the Web app on Azure.
WebJobs is a feature of Azure App Service that enables you to run a program or script in the same context as a web app.
For more details about deploy webjobs you could refer to this article.
Also, if you are using console core application, you could refer to this blog to deploy it.

Jenkins - MSBuild for ASP.NET CI without local IIS

Background: I am doing a POC for CI using Jenkins and MSBuild. I have installed Jenkins, MSBuild plugin and other required components on my machine and configured as well. But I don't have IIS configured on my development machine.
I want build the ASP.NET website and output the published code in a folder "c:\precompiledweb" using MSBuild script. I have
Can someone help me with MSBUild Script.
Make sure you read the prerequisites for functionality.
https://msdn.microsoft.com/en-us/library/1y1404zt.aspx
Walkthrough: Deploying a Web Site Project by Using the Publish Web Site Tool
Prerequisites
In order to complete this walkthrough, you will need the following:
Visual Studio.
*This walkthrough assumes that you selected the Web Development collection of settings when you started Visual Studio the first time. For more information, see How to: Select Web Development Environment Settings.
Access to Microsoft Internet Information Services (IIS) so that you can test the result of publishing a Web site project. In this walkthrough, it is assumed that you have IIS running on your own computer. Alternatively, you can use any instance of IIS for which you have permission to create a virtual directory.*
You need access to some IIS server.
On the flip side....you need to keep this general rule in mind. Jenkins is simply a fancy wrapper for command line calls.
So test the below (article) on your machine without IIS. If you can get the command line to work (outside of jenkins), most likely you can get it working (inside jenkins)
http://www.asp.net/mvc/overview/deployment/visual-studio-web-deployment/command-line-deployment
Configure Source Code Management section, i.e. for TFS:
Add build step "Execute Windows batch command"
Insert msbuild invocation to your solution, i.e.
C:\Windows\Microsoft.NET\Framework64\v4.0.30319\MSBuild.exe
"%WORKSPACE%\{solution_name}.sln"
You can add some optional parameters.
After build you can add another script invocation (batch, powershell, whatever) for copy project output to specific folder, but I would prefer another way: publish to IIS and run application immediately.
in Visual Studio create publish profile with WebDeploy target (help)
enable Web Deploy in IIS on test machine (help - when componentes are already installed go to "USING THE IIS MANAGER TO CONFIGURE WEB DEPLOY FOR A NON-ADMINISTRATOR" section)
add publish parameters to jenkins job from step 2, i.e.:
C:\Windows\Microsoft.NET\Framework64\v4.0.30319\MSBuild.exe
"%WORKSPACE%\ {solution_name}.sln"
/P:DeployOnBuild=true
/p:PublishProfile="{publish_profile_filename}.pubxml"
/p:Configuration=Release
/p:Platform="Any CPU"
/p:Password={Password_for_publish_profile_same_as_used_in_VS}
And now you have jenkins click-once job for build and publish solution to test server. Add Source Code change trigger and you have basic CI.

Can i deploy Azure project on IIS?

I have solution with startup project that have .ccproj format. This is an Azure project that require Azure SDK installed. By default i am able to run it using IIS Express with Azure storage emulator & Azure compute emulator. But when i make some changes i need to recompile entire solution and re-run it. How can i deploy it in IIS server ? Could you advise me alternative deploy method how to run it in simplest way ?
I want to re-compile and attach to process after make some changes in project without restarting IIS Express & Azure emulators, it takes a lot of time.
#DotNetGoose,
should be able to run on IIS but you will need to abstract all the calls that your code read content from RoleEnvironmental and direct them to read from Web.config, and have a copy of corresponding settings in your web.config.
once the abstraction is done, set your web app as default startup project, you should be able to run them as normal web app on iis or iisexpress.

Cannot start service from the command line or debugger. How can I tell which service?

I am trying to debug an ASP VB web site project I recently took over.
I start debug while in the home page.
I recieve the following error:
Cannot start service from the command line or debugger. A windows
Service must first be installed(using installutil.exe) and then
started with the ServerExplorer, Windows Services Administrative tool
or the NET START command.
How do I tell what service the program is trying to start?
I viewed other questions with this error to no avail.
Thanks!
You're trying to debug not an ASP/ASP.NET application, but a Windows Service project - it cannot start from the debugger. If your solution has multiple projects, make sure to set Startup project to the one you're working with.
If you do need to debug the service, compile and install it as the message suggest and then attach Visual Studio debugger to the process running the service.
You are trying to start a window service from vs.net.You have to start the application as a service and the attach the debugger. You can make extra project, commandline with:
public static int Main(string[] args)
{
// Startup as application
}
to start the serice as a commandline application.
Or you can add a brakpoint in de service to attach the debugger with:
Debugger.Break()
Configure and starting a service

Resources