Deploy and Run Angular 17 Universal SSR to Azure Service

280 Views Asked by At

I am trying to set up an Angular Universal SSR build and deploy it to Azure App Service. I have already configured the project and the pipeline, as a result I got two folders that are deployed to Azure App Service.

I can open the browser folder through the domain that Azure gave me, but the server-side rendering doesn't work there.

The question is how to run the main.js file and point the Azure domain to the port localhost:4000

I don't know where I can run the main.js file and how to point the azure domain to the port localhost:4000

1

There are 1 best solutions below

0
Petro Sych On

I found out that these two tasks from the pipeline don't change the file structure after deployments

- task: CopyFiles@2
  displayName: 'Copy browser directory from dist directory to the root'
  inputs:
    SourceFolder: '$(Build.SourcesDirectory)/dist/browser'
    Contents:  '**'
    TargetFolder: '$(Build.ArtifactStagingDirectory)/dist/browser'
        
- task: CopyFiles@2
  displayName: 'Copy main.js to the root'
  inputs:
    SourceFolder: '$(System.DefaultWorkingDirectory)/dist/server'
    Contents:  '**'
    TargetFolder: '$(Build.ArtifactStagingDirectory)/dist'

- upload: $(Build.ArtifactStagingDirectory)/$(Build.BuildId).zip
  artifact: drop

- task: PublishBuildArtifacts@1
  inputs:
    PathtoPublish: 'dist'
    ArtifactName: 'dist'
    publishLocation: 'Container'

file structure in /site/wwwroot