0

I'm using this step in an Azure pipeline, to deploy a Blazor WebAssemby application.

I need to set some configuration values in the application, so I used this technique to inject some custom value (variable substitution using 'JSONFiles', I added the arrow, of course):

- task: AzureRmWebAppDeployment@4
  displayName: 'Deploy BlazorAssemblyClient'
  inputs:
    ConnectionType: 'AzureRM'
    azureSubscription: '...'
    appType: 'webApp'
    WebAppName: $(blazorAppName)
    packageForLinux: '$(System.ArtifactsDirectory)/tempBlazorAssemblyClient/**/*.zip'
 -> JSONFiles: '**/appsettings.json'

I created variables matching what's inside the appsettings.json, so everything is fine, and I can check that the file has been correctly updated.

But, I see two problems, now: first, I get an error when browsing the application because the integrity of the file is not satisfied anymore.

Failed to find a valid digest in the 'integrity' attribute for resource 'https://.../appsettings.json' with computed SHA-256 integrity 'JqjyXWM4+hDsLD0kOHuOpJoNBrAMz5mlgQ7EuAbQb2M='. The resource has been blocked.

Second, there are two compressed (generated) corresponding files (extensions .br and .gz) that I can see not having been updated (of course, I can think, because they have been generated before updating the original appsettings.json.

It looks like this is not the correct way to inject custom values inside a configuration file (at least for a Blazor WebAssembly application): probably I should update the appsettings.json file before the application is generated. Any idea about how to solve this problem, or some other viable approach to it?

Thank you in advance.

Andrea
  • 555
  • 5
  • 28

1 Answers1

1

I solved, at least for the moment, with a very simple solution, maybe not too elegant, but it works.
Before publishing and deploying, I run a powershell script that replaces the content of appsettings.json:

- powershell: |
    Remove-Item '...path.../wwwroot/appsettings.json'
    Set-Content '...path.../wwwroot/appsettings.json' '{"BaseApiAddress":"https://remoteapi.azurewebsites.net/api/"}'
    $content= Get-Content -Path '...path.../wwwroot/appsettings.json'
    Write-Host 'Content:'
    Write-Host $content
    Write-Host 'End of content'

And it works (yes, I will use variables... :-))

P.S.: There must be some further minor problems with the code page, because I see some extra characters at the end of the file, that shouldn't be there. I will investigate, but in general, it works.

Andrea
  • 555
  • 5
  • 28