How to publish Blazor webapp to Azure - azure

Can anyone please help with the following.
I am just starting out with Blazor (using Visual Studio 2019). I have followed an online tutorial and have a trival app working locally (just selected the Blazor project type when I created a new project in Visual Studio and built it and now it's running at https://localhost:44311/ on IIS (as long as the project is debugging) ).
If I now right click on the project and select "Publish", and then I select "Azure App Service" and then I click "Publish", then Visual Studio hangs forever with a spinning wait cursor saying "Loading subscriptions". If I look under View -> Cloud Explorer and click the Account Management icon, I see my account is there, so that's fine.
I normally develop my webapps with Node and my preferred workflow is to write the Javascript code in Visual Studio and then use git cli to update a git repository which is linked to an Azure webapp which automatically builds when I commit code. Could I do the same with my razor app? If so, which files from the Razor app directory (wwwroot?) would I need to add to a new github repository and commit in order to then create a new web service through the Azure portal to then link to that github project?
As long as I get one way working to publish the app that would be great.
Thanks for any help,
Mitch.

Related

How to publish asp.net core web job to azure app service

I have started with asp.net core 2 web app and I can publish it to App Service from Visual Studio using web deploy.
I've created new clean .net core 2 console app. I'm able to upload it as webjob and run using Azure Portal, but how do I publish it from local command line or Visual Studio?
Basically, I don't care whether it will be published alongside the Web Application or as standalone.
EDIT: I've somehow managed to get the publish dialog by right clicking the project and selecting Publish (not Publish as Azure WebJob) as menioned in the docs. But I still don't know what did the trick. Installing Azure SDK? Adding webjob-publish-settings.json? Adding Setting.job?
Publish .net core as webjob with Azure portal:
As you know:
A WebJob looks for specific file type, for example (.cmd, .bat, .exe, etc…)
To run a .NET Core console application you use the DOTNET command
Therefore, you need to create a file with an extension which is WebJob looking for that executes.
1.You could create a .net core conosole application. After running it, you will have the follow file in your projectname/bin/Debug/netcoreapp2.0
2.Create a run.cmd file under it. And the run.cmd content is as below:
#echo off
dotnet ConsoleApp7.dll
3.To deploy the .NET Core console application to an Azure App Service Web App Web Job access the Azure portal and navigate to the Azure App Service where you will host the WebJob.
Click on the WebJobs link and the Add button.
4.Upload the netcoreapp2.0.zip
5.Once the WebJob is successfuly uploaded, it will render in the WebJob blade. Click on it and you will see the Run button.
6.When you write output to the console using the WriteLine() method, it will show in the Run Details window on KUDU/SCM.
For more detail, you could refer to this article and this one.
Update:(publish with command line)
1.First, download your publish settings file of your webapp from Azure Portal.
2.Prepare the .zip folder you have created.
As David said, you could use WAWSDeploy to publish webjob with command line.
You could download WAWSDeploy with this link.
3.Then go to WAWSDeploy/bin/Debug folder to open the local command line.
Try the following command to deploy the webjob:
WAWSDeploy.exe DotNetCoreWebJobSample.zip [WEBSITE_NAME].PublishSettings /t app_data\jobs\triggered\DotNetCoreWebJobSample /v
Target directory will be app_data\jobs\triggered\[WEBJOB_NAME]. If this web job is a continuously running one, replace triggered with continuous.
Note:you could put the WAWSDeploy.exe and publish settings file and the .zip into a folder. If not, you should give the full path of publish settings and .zip file. So that you could publish webjob successfully.
For more detail about WAWSDeploy, refer to this article.
Make sure your csproj includes correct SDK's:
<Project Sdk="Microsoft.NET.Sdk;Microsoft.NET.Sdk.Publish">
Then just right click on the project in Visual Studio and click publish, select Microsoft Azure App Service and you should see the WebJob publish options:
Also notice that you should use Microsoft.NET.Sdk and not Microsoft.NET.Sdk.Web
If you are using Microsoft.NET.Sdk.Web, Visual Studio assumes that you are deploying to WebSite and not WebJob. The publish dialogs are slightly different for WebSite and WebJob. For example, for WebJob project you can specify WebJob Name.
You might be interested in:
github/aspnet/websdk/issue: WebJob publishing for Microsoft.NET.Sdk.Web
github/aspnet/Mvc/issue: How to publish console app as a WebJob rather than Web App
There is a great articel about Develop and deploy WebJobs using Visual Studio - Azure App Service that covers your question.
Basically after installing the prerequisites (depending on your VS version) you can
Right-click the Console Application project in the Solution Explorer, and then click Publish as Azure WebJob.

Add Azure WebJob to mobile service hosted in App Service

With the new Azure Mobile App Services in Azure the mobile services apparently gains the same WebJob support as Websites have had for a while.
Following the article Deploy WebJobs using Visual Studio according to the section 'Enable automatic WebJobs deployment with a web project' we should be able to add a web job from a right click on the project. None of these options show up for my mobile service project in VS.
I can add a WebJob project to the solution manually, but this does not add the webjobs-list.json file to my mobile service project as the article suggests.
Does anyone know why the add web job context menu doesn't show when right-clicking on the mobile service project? Or the manual steps required to configure the project and appropriate webjobs-list.json file?
Update:
I have manually added the webjobs-list.json file to the main project by copying the format from another initial template project and adjusted the web job project path in it. Even deploying the mobile service to an azure web app doesn't pick up the web job.
It should work. I just created a new Mobile App, downloaded the quickstart, right-clicked the web project (appname-code), and was able to associate a webjob to the web project. Deployment worked as planned. Did you try that workflow? Did you try adding the webjob through the portal?

Converted MVC app to Azure Cloud Service Project - cant get latest

I converted an MVC5 app to an Azure Cloud service project and it created the Azure project (used this page for instructions http://msdn.microsoft.com/en-us/library/azure/hh420322.aspx#ProjectTemplates
)
I checked in the newly added project to TFS by right-clicking the project and selecting Check-in. When I tried to get latest from another dev machine, the Azure project does not show up in the solution explorer. What am I missing? Does each dev machine need to create the Azure project independently? I can see the files in TFS and they were copied down to my local drive, but the project doesn't show up under the solution.
thanks,
Andy
You need to checkin the changes to the sln file also, and ensure your workspace mapping includes the solution file.

Azure Continuous Deployment from Visual Studio Team Services with multiple projects

While using Github (or anything other than Visual Studio Team Services) I can use the following page to customize deployment: https://github.com/projectkudu/kudu/wiki/Customizing-deployments
I'd like to customize my deployment as I currently have both a web app and a web api project. I want the web app to be deployed, as default it deploys the web api project. Using project Kudu the settings (.deployment file or even better, the app settings on Azure itself) works great, but not when you deploy from Visual Studio Team Services.
I've spoken with David Ebbo from Project Kudu, and he explained that VS Team Services doesn't use Kudu at all, but probably MS Build. So my question is, how to specifically deploy the web app.
I managed to change the Build Definition and specify the web app .csproj as the Projects To Build. This works. However, I also want to deploy my web api.
Deploying the web api project with Kudu is easy as I can create a separate website, connect to the some repository (and solution) and specify the Project App setting so that it deploys the correct .csproj. How should we do this for MS Build? When I change the Build Definition, it will always deploy the project specified in there.
Just saw another answer on Stackoverflow that looks to solve this problem: Publish Multiple Projects to Different Locations on Azure Website

How to migrate a VS2012 Azure Cloud Service Project to VS2013

I have two ASP.NET MVC 4 projects created in VS2012. For each, I created an Azure deployment project and they are both deployed successfully to Azure. I got a new dev machine and started fresh with only VS2013 installed, hoping that, as advertised, I wouldn't have to go through the pain of migrations that would make the projects tied to this version. Well, that didn't turn out true, as Azure projects must be upgraded to v2.2 of the Azure .NET tools and API to be opened in VS2013.
On the first project, I installed the 2.2 tools and with a few other relatively minor adjustments, the project works fine. Now, on the second project, however, I can find no way to perform the upgrade. When I opened the project in VS2013, it gave me a migration report saying that the Azure project was incompatible and the only solution offered was to install the 2.2 tools, which of course, has already been installed. I then decided to remove the existing azure deployment project and create a new one as I did before on vs2012, by right-clicking on the web project and choosing "Add Azure deployment project", which wires everything up automatically. Well, that menu item does not appear in the context menu on the web project.
Now, I'm at a loss for how to resolve this, other than installing VS2012 and forego taking advantage of the advances in VS2013. Does anyone have any suggestions how i can get an Azure deployment project working with this project?
(BTW, this is a must, because I am using the azure api to get config items out of the azure config.)
I had the same issue. I solved it by installing the 2013 version of the Azure 2.2 SDK (found here). After doing this I was able to build and run the solution (without any conversion) in both VS2012 and VS2013.
UPDATE:
Try to add a new Azure Cloud Service project to your solution by right-clicking the solution > Add > New Project.
Under templates there should be a section named 'Cloud' with a project template named Windows Azure Cloud Service. When you select this template you should get a dialog where you can add Azure roles to your solution.
If you select ASP.NET web role, a new Web project will be created in your solution. If you don't select anything, you will get an empty Azure project to which you can add your existing MVC project (WebRole Project > Right click Roles > Web role project in solution).

Resources