Open ZavenLepedjian opened 2 years ago
@ZavenLepedjian Is it possible to share the release pipeline yml and if possible, also share a repro, so that we can understand the issue better?
I do not have the whole yaml file of the release as I'm using the classic release pipeline. What I have is the yaml of each task. Please find below the tasks in yaml in order
1- Setup the config file pf a custom tool that will generate my appsettings.json
- task: jakkaj.vsts-yaml-writer.custom-build-release-task.YamlWriter@0 displayName: 'Update static web wettings' inputs: file: '$(System.DefaultWorkingDirectory)/_deployments/tools/StaticWebMultitenantConfig/appsettings.json' set: 'Tenants="$(Host)",ApiUrl="$(HostApi)",AuthorityUrl="$(AuthUrl)",InputSettings="$(System.DefaultWorkingDirectory)/_deployments/web/Client/wwwroot/appsettings.json",OutputFile="$(System.DefaultWorkingDirectory)/_deployments/web/Client/wwwroot/tenantsettings.json"' json: true
2- Run the custom tool to generate the settings and replace it
- script: 'dotnet StaticWebMultitenantConfig.dll'
workingDirectory: '$(System.DefaultWorkingDirectory)/_deployments/tools/StaticWebMultitenantConfig'
displayName: 'Set static web settings'
3- Deploy the built app using the Azure Static Web App (Preview) Task
- task: AzureStaticWebApp@0 displayName: 'Deploy static web app' inputs: app_location: '_deployments/web/Client/wwwroot' config_file_location: '_deployments/web/Client/wwwroot' skip_app_build: true skip_api_build: true is_static_export: false verbose: true azure_static_web_apps_api_token: '$(StaticWebApi)'
After step 2, if I echo the "_deployments/web/Client/wwwroot/appsettings.json" file, I get the right configuration but after the third step the appsettings.json is empty
@ZavenLepedjian Thanks for the tasks yaml. Not completely sure on what's going wrong here, but is it possible that the file generated in task 2 is not accessible by task 3? To verify that, in task 3, can you try removing the static web app related steps and add a simple command to access the generated appsettings.json and see if you can see the contents?
And if the issue is happening only with static web app task, is it possible to provide a repro which I can access or provide me with access so that I can understand the issue better?
@vivekjilla Thanks for the help. After trying to get the file content after task 2, I got permission denied. /home/vsts/work/_temp/0b45eaf9-a2f1-4266-8e5b-55544d98e394.sh: line 3: /home/vsts/work/r1/a/_deployments/web/Client/wwwroot/appsettings.json: Permission denied
This result was predicted by you.
Knowing that this is an hosted "ubuntu-latest" agent, How do you think we can tackle this?
@ZavenLepedjian thanks for trying it out. Not sure what's happening here but seems like something to do with azure devops pipelines. One thing we can do is to try a minimal repro where one task writes contents to a file and the next task reads it. And maybe follow up with the azure devops team on this - https://github.com/MicrosoftDocs/azure-devops-docs/issues
Can you please try that and see.
@vivekjilla , After running chmod -R 777 .
to give access on the file, I was able to read the content of the file.
But after the static web task, the appsettings is still not filled with the data I was waiting for.
@ZavenLepedjian Oh okay. Then, is it possible to give me access to your pipeline or provide an accessible repro, where I can look into further to get to the bottom of this? Thanks!
@vivekjilla it is very difficult for me to give you access to the pipeline as it is the company's release pipeline. maybe we can have a call and share screen so that you can look into it? Also, even though I tried using incognito but, do you think this might be a problem of caching? Maybe the appsettings has been updated but it has been cached?
@ZavenLepedjian sure. Please send a mail to me at vijilla@microsoft.com , We can discuss further there. I can't think of a reason why this could be happening, at this point.
Thanks @vivekjilla , I will contact you soon via email
@vivekjilla I contacted you a week ago via email and didn't get any response.
@ZavenLepedjian I'm really sorry about that but I didn't see any mail or can't seem to find. Can you please check again and also send me the subject I can search for.
@vivekjilla here's the subject of the email sent. Azure static web app appsettings.json file modification Hope to hear from you soon.
@vivekjilla do you have any updates?
@ZavenLepedjian sorry, didn't get chance to look into this further yet.
But to summarize our last discussion, ado tasks updating an already existing file in the repo is not working for some reason and the updated changes are not reflected.
Workaround is to have a file with different name in the repo and let the task create a new file with name appsettings.json.
Hello. I'm having the same issue. I have a full demo.
I unzip a build artifact for a Blazor WASM project and then copy an environment specific appsetings file to overwrite the wwwroot/appsettings.json
. However, when everything completes, I can load the appsettings on the deployed app and still get the appsettings that was a part of the build steps.
Someone else also had this issue on SO
Hi @vivekjilla Was my demo helpful? This is a blocking issue for me on a real project (and the demo)
@Eonasdan apologies for the delay. But can you try this work-around
Workaround is to have a file with different name in the repo and let the task create a new file with name appsettings.json.
Basically either don't keep the wwwroot/appsettings.json
file in the repo or rename it to somethine else like wwwroot/_appsettings.json
.
This way, your custom appsettings.json won't get replaced by the initial appsettings.json file during the deploy step.
And for us to investigate this further, is it also possible for you to share the deployment run logs. Thanks!
Based on your workaround, what I ended up doing was deleting the wwwroot/appsettings.json
file before doing a publish in my build pipeline. In the deploy pipeline, I copy the environment specific file into the wwwroot
folder. This seemed to work for the demo, I'll have to try it in the real project when I can get to it.
- task: PowerShell@2
displayName: 'Delete Config'
inputs:
pwsh: true
targetType: 'inline'
script: |
$destination = "BlazorDemo/BlazorDemo.Web/wwwroot/appsettings.json"
Remove-Item -Path $destination -Force
I'm using Deploy Azure Static Web App (Preview) task in my Release pipeline and I'm facing issue by not being able to replace appsettings.json values.
Here are the steps I'm doing.
In the build pipeline
Release pipeline
Result:
Debug Results: