I have built, as a proof of concept, an ASP.NET MVC 4.5.2 website with an MySQL database and have deployed this to Azure using an Azure Resource Group project (based on https://azure.microsoft.com/en-us/documentation/articles/vs-azure-tools-resource-groups-deployment-projects-create-deploy/>), which works very well.
I have, however, tried the same with an ASP.NET Core 1.0 website, which doesn't work, at least out-of-the-box - adding a reference from the ARG project to the website project doesn't seem to work properly and no WebDeploy package of the website is created upon deploy. I'm guessing that this will work sometime (perhaps when the Visual Studio tooling for .NET Core graduates) but maybe it is possible today by modifying the generated JSON and Powershell scripts?
Use Visual Studio to create and deploy an ASP.NET Core web app to Azure App Service on Windows. Use the command line to create and deploy an ASP.NET Core web app to Azure App Service on Linux. See the ASP.NET Core on App Service Dashboard for the version of ASP.NET Core available on Azure App service.
ASP.NET web apps are cross-platform and can be hosted on Linux or Windows. When you're finished, you'll have an Azure resource group consisting of an App Service hosting plan and an App Service with a deployed web application. Azure PowerShell is recommended for creating apps on the Windows hosting platform.
In Solution Explorer, right-click the MyFirstAzureWebApp project and select Publish. In Publish, select Azure and then Next. Choose the Specific target, either Azure App Service (Linux) or Azure App Service (Windows). Then, click Next. When targeting ASP.NET Framework 4.8, use Azure App Service (Windows).
ASP.NET Core 3.0 is supported on Azure App Service. To deploy a preview release of a .NET Core version later than .NET Core 3.0, use one of the following techniques. These approaches are also used when the runtime is available but the SDK hasn't been installed on Azure App Service.
ASP.NET Core tooling has graduated but there is still no support for ASP.NET Core applications in Azure Resource Group projects. Since I use Visual Studio Team Services för build and release I solved this by simply creating an Azure Web App with the Azure Resource Group project and instead of linking my ASP.NET Core project to the resource group project (which works with ASP.NET 4.5) I let VSTS handle deploying the actual code to the Azure Web App. My release definition has two task:
As per @david-nordvall's answer the support isn't quite there. The issue I have hit is that when you add a reference to an ASP.NET Core project to an Azure Resource Group project, the Visual Studio build fails with:
[error]Deployment.targets(57,5): Error MSB3030: Could not copy the file "obj\Release\ProjectReferences\MyAspDotNetCoreProject\package.zip" because it was not found.
This is the part of the .deployproj
file with the reference:
<ProjectReference Include="..\MyAspDotNetCoreProject\MyAspDotNetCoreProject.csproj">
<Targets>
</Targets>
<AdditionalProperties>WebPublishMethod=Package;DeployOnBuild=true;Configuration=Release;PublishProfile=Default;DesktopBuildPackageLocation=..\MyAzureDeployProject\$(ProjectReferencesOutputPath)\MyAspDotNetCoreProject\package.zip</AdditionalProperties>
<IncludeFilePath>$(ProjectReferencesOutputPath)\MyAspDotNetCoreProject\package.zip</IncludeFilePath>
</ProjectReference>
The problem seems to be the missing targets. Here is a reference to a "classic" ASP.NET project:
<ProjectReference Include="..\MyClassicAspNetProject\MyClassicAspNetProject.csproj">
<Targets>Build;Package</Targets>
<AdditionalProperties>PackageLocation=..\MyAzureDeployProject\$(ProjectReferencesOutputPath)\MyClassicAspNetProject\package.zip</AdditionalProperties>
<IncludeFilePath>$(ProjectReferencesOutputPath)\MyClassicAspNetProject\package.zip</IncludeFilePath>
</ProjectReference>
I thought I'd be clever and manually create the reference to the ASP.NET Core project using the same definition as the "classic" ASP.NET project (substituting the names), but then the build fails with:
error MSB4057: The target "Package" does not exist in the project.
So I simply removed the Package
target:
<Targets>Build</Targets>
And the build failed again! Back to the first error:
error MSB3030: Could not copy the file "obj\Debug\ProjectReferences\MyAspNetCoreProject\package.zip" because it was not found.
But by some off chance, the build had already kicked off in Azure DevOps (got to love building on Pull Requests) and it had succeeded!
The difference in my Azure DevOps build is some extra parameters for MSBuild:
/p:DeployOnBuild=true /p:WebPublishMethod=Package /p:PackageAsSingleFile=true /p:SkipInvalidConfigurations=true /p:PackageLocation="C:\temp" /p:RunOctoPack=true /p:platform="Any CPU" /p:configuration="Release" /p:VisualStudioVersion="15.0"
I could even run MSBuild locally and it succeeded. I haven't worked out exactly why it's working with the extra parameters.
Hope that helps.
[Update]
It's worth noting that if you've got this far with ASP.NET Core via ARM deployment, you'll need to set the AppOffline
property in your MSDeploy
to true
:
"resources": [
{
"apiVersion": "2016-03-01",
"name": "MSDeploy",
"type": "Extensions",
"dependsOn": [
"[concat('Microsoft.Web/Sites/', parameters('appName'))]"
],
"properties": {
"packageUri": "https://mystorageblob.blob.core.windows.net/package/my_webdeploy_package.zip",
"dbType": "None",
"connectionString": "",
"AppOffline": true,
"setParameters": {
"IIS Web Application Name": "[parameters('appName')]"
}
}
}
],
(From here)
The problem is that in ASP.NET Core the files are locked.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With