I have created in my VS2015 an azure cloud service with a worker role. These are 2 projects.
I want to know how can I pack and then publish this cloud service with a tool/cli?
When I google for 'deploy azure cloud service' I get only result saying to do it within Visual Studio or Visual Studio Team System.
This is NOT what I want!
We can use the cspack command line tool to package a cloud service. If the application only contains worker role, you could refer to the following command.
cspack D:\xxx\xxx\ServiceDefinition.csdef /role:WorkerRole1;D:\xxx\WorkerRole1\bin;D:\xxx\WorkerRole1\bin\Debug\WorkerRole1.dll
And you could refer to the PublishCloudService.ps1 script template in this article.
cspack could not be found in the powershell commandlets
The cspack could run in Windows PowerShell on my side. I add C:\Program Files\Microsoft SDKs\Azure\.NET SDK\[sdk-version]\bin in Path system environment variables, and I could run the following command to package a cloud service.
Related
I pushed my .net core function application using visual studio and now setting up release pipeline. I can publish and execute the application just fine and it works great on the Azure portal. However when I see the builds for releases in azure-devOps that slot fails with the following error.
2019-06-19T23:21:33.3543380Z ##[error]Error: Deployment of msBuild generated package is not supported. Change package format or use Azure App Service Deploy task. D:\a\r1\a\_...AVFunctionCore.zip
I am not sure where I need to check in my setup to even start diagnosing the issue.
Here are the pipeline steps.
I create a new stage and then select a template of type (Azure app service deployment)
Under tasks
App type is Function App on Windows
Give the app name, resource group , give the slot and
package folder as
$(System.DefaultWorkingDirectory)/**/AVFunctionCore.zip
Everything else on this is left as default.
Azure function app deploy and release pipeline error
According to the error message:
Deployment of msBuild generated package is not supported. Change
package format or use Azure App Service Deploy task.
It seems you are not using the correct task to publish the generated package. Since the generated package is .zip, you can try the suggestion as error message said use Azure App Service Deploy task.
Azure App Service Deploy task:
Use this task in a build or release pipeline to deploy to a range of
App Services on Azure. The task works on cross-platform agents running
Windows, Linux, or Mac and uses several different underlying
deployment technologies.
The task works for ASP.NET, ASP.NET Core, PHP, Java, Python, Go, and
Node.js based web applications.
The task can be used to deploy to a range of Azure App Services such
as:
Web Apps on both Windows and Linux
Web Apps for Containers Function
Apps on both Windows and Linux
Function Apps for Containers
WebJobs
Apps configured under Azure App Service Environments
Check this blog Visual Studio 2017 Tools for Azure Functions and Continuous Integration with VSTS for some more details.
Hope this helps.
I get predefined pipeline from VS integration. So for those you have the same case:
In GUI/Classic mode Release page -> edit pipeline
Edit task in stage section (this is responsible for deploying)
Replace Azure Web App task with Azure App Service deploy
I have more than one project (web api + azure function) in my solution. For the web app I used the zip file, but for the azure function to work I needed to publish the whole folder.
Azure Function
Package or folder:
$(System.DefaultWorkingDirectory)/_Backend/drop
Web Api
Package or folder:
$(System.DefaultWorkingDirectory)/_Backend/drop/ClientAPI.zip
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.
We have an Azure Web App that we have Source Control integration setup with Visual Studio Online via the built in Azure functionality. This, of course, creates a build definition in our Visual Studio Online account. We have had this configured and it has worked just fine for deploying our website by queuing a build.
Our ultimate configuration is to actually create a Virtual Application and use the build to deploy to the Virtual Application instead of the web app site root.
So, we created the Virtual Application in the portal. See screenshot:
Our trouble comes in that we can't get the build definition to actually deploy to this virtual application. The build either fails or the files still end up in the site\wwwroot folder.
Our azure web app name is: inyoforum(staging)
We've tried numerous variations of the following MSBuild arguments:
/p:DeployIisAppPath="inyoforum__Staging/Forum"
/p:DeployIisAppPath="inyoforum__Staging\Forum"
/p:DeployIisAppPath="inyoforum(staging)/Forum"
/p:DeployIisAppPath="inyoforum(staging)\Forum"
We even tried other variations. We tried using a publish profile instead. We can get a publish from our local Visual Studio application to the virtual application, but we've been unable to do it from the build definition.
Any suggestions on other things to try?
You can create a publish profile to publish the website to virtual app and specify the profile in MSBuild Arguments. Steps like following:
Create a publish profile according to the instruction here: Deploying multiple virtual directories to a single Azure Website.
Check in the publish profile.
Create a new build definition and enter following strings in MSBuild arguments:
/p:DeployOnBuild=true /p:PublishProfile=xxxx.pubxml
Queue a new build with the definition, the web app will be deployed to virtual app.
You can also install MSDeploy Package Sync task and use it to deploy to virtual app. Please refer to this article for details: CUSTOM DEPLOY TASK TO DEPLOY VIRTUAL APPLICATIONS TO AZURE
I had this same problem and found virtual directories are not supported by MSDeploy PowerShell scripts. So I created a custom deployment task to support this use case. Give it try -
https://dotnetcatch.com/2016/03/22/vsts-release-custom-deploy-task-to-deploy-virtual-applications-to-azure/
We are creating the azure worker role deployment package via our ci server and deploy the package to the azure cloud service using Azure Powershell cmdlets script.
however the diagnostic configuration does not get apply to the deployment; it only works when we deploy manually from within visual studio.
is there a way to do that in the powershell script to take into account the diagnostic setting (performance counter..etc) ?
You can use Set-AzureServiceDiagnosticsExtension PowerShell Cmdlet to enable diagnostics. You may find this link useful for this purpose: http://azure.microsoft.com/en-in/documentation/articles/cloud-services-dotnet-diagnostics/ (Please see Step 5: Install Diagnostics on your Worker Role).
I have a Web Role in Azure that is under development. I would like to make a package that can be published and tested in staging environment without the help of Visual Studio. Is there a way to publish if just the package is provided?
You can use cspack to actually create the package, but from your question it sounds more like you are asking can you publish an already created package. The answer is yes.
There are multiple ways to do this and I'll provide three:
1) The management portal: you can deploy a package if you have the cspkg and csconfig files. Under the Cloud Services you can select a cloud service and select to deploy to the production or staging slot. You can also do this as part of creating a new cloud service in the portal. http://www.windowsazure.com/en-us/manage/services/cloud-services/how-to-create-and-deploy-a-cloud-service/
2) You can use Windows Azure PowerShell and CLI command line tools to deploy an already packaged deployment. In fact, you can also automate packaging and deploying. http://msdn.microsoft.com/en-us/library/windowsazure/jj883943.aspx
3) Using a tool like Cerebrata's Azure Management Studio you can also deploy already created packages : http://www.cerebrata.com/products/azure-management-studio/features
In additiont to being able to deploy an already created package, for Cloud Services you can also wire up to the hosted TFS service and have it deploy your web app when you do a check in. http://www.windowsazure.com/en-us/develop/net/common-tasks/publishing-with-tfs/