Blazor on Azure Linux App Services failing - azure-web-app-service

I am using Azure DevOps to deploy my Blazor WASM to a Linux Web App in Azure AppService.
The deployments succeeded, but the website is not showing the deployed content. I used the same pipeline to deploy to a Windows Web App in App Service and it worked. Is there any issues with Blazor WASM and Azure App Service (Linux). I Ensured that I selected the correct .NET Stack in both Web Apps.
azor
dependsOn: Build_Blazor_App
condition: and(eq(variables['Build.Reason'], 'Manual'), eq('${{parameters.DeployBlazor}}', true) ) # We need deployment to happen only for manual one.
jobs:
- job: Deploy
displayName: Deploy To Azure
steps:
- task: DownloadPipelineArtifact#2
displayName: Downloading Artifacts
inputs:
buildType: 'current'
artifactName: 'blaze'
targetPath: '$(Pipeline.Workspace)'
- task: AzureRmWebAppDeployment#4
displayName: Deploying to Dev
inputs:
ConnectionType: 'AzureRM'
azureSubscription: 'Az_VS_Enterprise'
appType: 'webAppLinux'
WebAppName: 'smartlytics'
packageForLinux: '$(Pipeline.Workspace)/Smarter.Blazor.zip'

Is there any issues with Blazor WASM and Azure App Service (Linux).
Followed by Microsoft Documentation :
Currently ,To deploy a Standalone Blazor WebAssembly app to Azure app
service on Linux is not supported. A Linux server image to host
the app isn't available at this moment.
We can deploy Blazor WebAssembly apps to Azure App Services on
Windows, which host the apps on IIS .

Related

Node Express Webpack API Release to Azure Dev Ops

I'm trying to release my project using Nodejs Express on Azure Dev Ops and Deploy on Release, but when I try to open the link. I'm getting a "The page cannot be displayed because an internal server error has occurred." error.
YAML:
pool:
name: Azure Pipelines
steps:
task: NodeTool#0
displayName: 'Use Node 14.x'
inputs:
versionSpec: 14.x
task: Npm#1
displayName: 'npm install'
inputs:
verbose: false
task: Npm#1
displayName: 'npm custom'
inputs:
command: custom
verbose: false
customCommand: 'run build'
task: PublishBuildArtifacts#1
displayName: 'Publish Artifact: drop'
inputs:
PathtoPublish: '$(System.DefaultWorkingDirectory)'
Package Script
Webpack.config
and on Azure Pipeline
the default setting of npm install and build
and on Azure Release
All are working fine, on the build and release.
Blank Page
I'm starting to guess the problem was from the azure portal, or on the way it was setup. Because I didn't create the portal. I'm only the Contributor.
Please help clarify this.
I try to build all files on SCM \wwwroot
Make sure the index.js file is deployed to your azure app service
As you have some issues with your existing application Create the new application using this MS-DOC
Sign into Azure Pipelines. Your browser will go to to display your Azure DevOps dashboard.
Create New pipeline under the pipeline's menu of your project
Select GitHub as the source code location.
If the code is placed in GitHub, then login with Git Creds
When the list of repositories appears, select your sample Node.js repository.
Azure Pipelines analyzes the code in your repository and automatically gives a Node.js template for your pipeline. Select this template.
Azure Pipelines will automatically generates a YAML file in your pipeline. Click on Save and Run > Commit Directly to Master Branch and then choose Save ad Run again.
A new run begins. Wait for the run to complete.
The link is used to create a pipeline is azure devops Deploying a Node JS App to Azure App Service using Azure Dev-ops (Part 1)
The link will be used to deploy the Nodejs app to Azure portal using azure pipelines Deploying a Node JS App to Azure App Service using Azure Dev-ops (Part 2)
This error is a common description of the IIS server error 500. It will be difficult to find the root cause of the question with just a general description.
For more details, please Reference the SO-Thread

Application Error trying to deploy site to Azure

While trying to deploy a simple site in Azure got this error message after deployment:
:( Application Error
If you are the application administrator, you can access the diagnostic resources.
How to solve this problem?
As you are using CI/CD to deploy your application, In the deploy task remove the slot name and replace the package with application file. Below are the samples:
From:
- name: 'Deploy to Azure Web App'
uses: azure/webapps-deploy#v2
with:
app-name: 'hello-world-app-to-delete'
slot-name: 'production'
publish-profile: $
package: .
To:
- name: 'Deploy to Azure Web App'
uses: azure/webapps-deploy#v2
with:
app-name: 'hello-world-app-to-delete'
publish-profile: $
package: ./dist/hello-world-app
For more information refer to this GIT blog
And to figure out what is the problem you can enable diagnostics logs in apps for azure app service. Also we can monitor our apps with Azure Application Insights.

need to deploy to specific server folder using Web App Deploy in Azure DevOps

I'm trying to set up a release pipeline in Azure DevOps Server 2020. I need to deploy my application files, which are contained in a zip file to a specific subfolder on a remote server. I'm having a hard time trying to figure out how to make sure my application files are extracted into the right folder. There isn't an option for this in the Web App Deploy task.
Here is my Web Deploy Task in YAML:
- task: IISWebAppDeploymentOnMachineGroup#0
displayName: 'Deploy to Dev'
inputs:
WebSiteName: 'DevServer'
Package: '$(System.DefaultWorkingDirectory)/_ProdBuild/finalbuild.zip'
TakeAppOfflineFlag: True
XmlVariableSubstitution: True
I also looked on the page where I set up the Deployment Group and there's no setting for deploying to a subfolder.
This is my first time setting up a release pipeline in Azure DevOps. Any help would be appreciated.
To set the deployment path in Pipeline, you need to add the IIS web app manage task(IISWebAppManagementOnMachineGroup#0) before the IISWebAppDeploymentOnMachineGroup task .
You could define the task input: WebsitePhysicalPath: 'localsubfolderpath'
Here is an example:
- task: IISWebAppManagementOnMachineGroup#0
displayName: 'IIS Web App Manage'
inputs:
WebsiteName: test
WebsitePhysicalPath: 'C:\inetpub\wwwroot1'
AddBinding: True
Bindings: '{"bindings":[{"protocol":"http","ipAddress":"All Unassigned","port":"88","hostname":"","sslThumbprint":"","sniFlag":false}]}'
CreateOrUpdateAppPoolForWebsite: true
AppPoolNameForWebsite: test
ParentWebsiteNameForVD: test
ParentWebsiteNameForApplication: test
Please refer to this doc about IIS Web App Manage task

How to set up build and release pipeline for NestJS application to Azure using YAML

I am having trouble understanding and getting the build/release pipelines setup for deploying a NestJS application to Azure DevOps (ADO).
I am deploying to a Linux Web App hosted in Azure.
As far as I understand, if I run the app locally using something like npm run start, it creates a dist folder under my root project directory.
So, when writing the YAML for the build and deployment. My thought process is to:
Run an NPM update.
Run npm run build to build the application and generate the dist folder.
Copy the contents of the application (or just the dist folder?) into the target folder (/home/site/wwwroot)
Run npm run start:prod to start the server.
Here is my YAML so far:
trigger:
- master
pool:
vmImage: 'ubuntu-latest'
steps:
- task: UseNode#1
inputs:
version: '14.x'
checkLatest: true
- task: Npm#0
displayName: Run NPM Update for NestJS
inputs:
cwd: '$(Build.SourcesDirectory)/ProjectName'
command: update
- task: Npm#0
displayName: Build NestJS
inputs:
cwd: '$(Build.SourcesDirectory)/ProjectName'
command: run
arguments: "build"
- task: CopyFiles#2
inputs:
Contents: 'dist/**'
TargetFolder: '$(Build.ArtifactStagingDirectory)'
The issue is after the build process completes, I do not see a dist folder in /home/site/wwwroot/ProjectName. Can someone help me out with what I am missing?
Also, a side noob-y question about Azure DevOps, what does $(Build.SourcesDirectory) and $(Build.ArtifactStagingDirectory) refer to and how and where are those environment variables set?
To deploy your app to the hosted in Azure. You need to use Azure App Service Deploy task or Azure Web App task.
Azure devops is the tool to build and deploy your app to your server(eg. the Linux Web App on Azure), it is not for hosting your app.
$(Build.ArtifactStagingDirectory) refer to the folder of the agent machine which runs your pipeline. (When your run your pipeline, it pick up a agent defined in pool to run your pipeline tasks)
The mapping to the folders in the agent machine is showing as below screenshot. Check the predefined variables for more information.
$(Agent.BuildDirectory) is mapped to c:\agent_work\1
$(Build.ArtifactStagingDirectory) is mapped to c:\agent_work\1\a
$(Build.BinariesDirectory) is mapped to c:\agent_work\1\b
$(Build.SourcesDirectory) is mapped to c:\agent_work\1\s
So back to the question how to deploying a NestJS application to Azure?
First you need to create a service connection in Azure devops to connect to your azure subscription. Check here for detailed steps.
Then add Azure App Service Deploy task/Azure Web App task to the end of your pipeline. See below example:
- task: AzureRmWebAppDeployment#4
inputs:
ConnectionType: 'AzureRM'
azureSubscription: 'SubscriptionServiceConnectionName'
appType: 'webAppLinux'
WebAppName: 'MyWebAppName'
Package: '$(Build.ArtifactStagingDirectory)/dist/'
StartupCommand: 'npm run start:prod'
You can check here for more information.

Azure Devops Change the Deploy Folder

I am using Azure Devops for automatic build & deploy of asp.net core 3.1 web app to Azure App Service.
The problem is that it's deploying the app to strange folder. Instead of the wwwroot folder it is in
/home/site/wwwroot/Content/D_C/a/1/s/ExampleFolder/ExampleFolder2/ExampleFolder3/obj/Staging/netcoreapp3.1/PubTmp/Out
The app service is on Linux if it matters.
How I can just fix/change it to be in the main folder?
You should share your Pipeline with us, otherwise, we can't tell you what you have to change/fix.
However, here an example that uses the AzureWebApp#1 Task to deploy a .NET Core 3.1 application to an Azure Web App.
trigger:
branches:
include:
- master
stages:
- stage: Build
jobs:
- job: 'BuildArtifact'
pool:
vmImage: 'ubuntu-latest'
steps:
- task: UseDotNet#2
inputs:
packageType: sdk
version: 3.1.x
- task: DotNetCoreCLI#2
displayName: Build
inputs:
command: 'build'
projects: PATH/TO/YOUR/Project.csproj
arguments: --output $(System.DefaultWorkingDirectory)/publish_output --configuration Release
- task: ArchiveFiles#2
displayName: 'Archive files'
inputs:
rootFolderOrFile: '$(System.DefaultWorkingDirectory)/publish_output'
includeRootFolder: false
archiveType: zip
archiveFile: $(Build.ArtifactStagingDirectory)/$(Build.BuildId).zip
replaceExistingArchive: true
- publish: $(Build.ArtifactStagingDirectory)/$(Build.BuildId).zip
artifact: drop
- stage: Deploy
dependsOn: Build
condition: succeeded()
jobs:
- deployment: 'Deploy'
pool:
vmImage: 'ubuntu-latest'
environment: Development
strategy:
runOnce:
deploy:
steps:
- task: AzureWebApp#1
displayName: Azure Web App Deploy
inputs:
azureSubscription: YourAzureSubscription
appName: YourAppName
package: $(Pipeline.Workspace)/drop/$(Build.BuildId).zip
appType: webAppLinux
I solved my issue by creating new Pipeline which is using dotnet agents instead of Visual Studio build agents. When you are deploying to Linux App Service make sure to use CLI. You can see #martin-brandl answer for example pipeline.
You can also refer to this Devops SE question. The problem is similiar:
https://devops.stackexchange.com/questions/9598/azure-devops-artifact-zip-folder-structure-for-net-core-3-0-application
I'm looking this fact:
I have an ASP.NET Core 3.0 application for which I have a full CI/CD setup in Azure DevOps. The Application is hosted on a Ubuntu 18.04 server machine.
Therefore I can safely assume that you are developing ASP.NET Core 3.0 app to be hosted in Ubuntu. Any .NET Core 3.0 (or later) application means that you should rely on the dotnet build instead of using VSBuild.
Also you had stated that you will host the app on Ubuntu 18.x, then you should also run the build on Azure DevOps agent that runs on Ubuntu. This means you should only use dotnet build in DotNetCoreCLI#2 task, because VSBuild task only runs on Windows based agent, not Ubuntu and it is intended to compile .NET Framework and other platform other than .NET Core.
Please consult the official doc of DotNetCoreCLI#2 task at https://learn.microsoft.com/en-us/azure/devops/pipelines/tasks/build/dotnet-core-cli?view=azure-devops
After you use dotnet build, use dotnet publish to publish your artifact. It is much easier and it's also the best way to publish .NET Core apps.
I have sample usage of dotnet build and dotnet publish of this on my repo: https://github.com/eriawan/dotnetcore-cicd-samples/blob/master/yaml-samples/sample_pipelines_check.yml

Resources