Change web.config at runtime in PODS hosted in IIS
We should always do the changes to web.config with the normal process of app code build image and deploy through the pipeline, however in very rare situation where we have fix things very quickly on the fly below method can be adopted.
# Change web.config inside running Windows container
Exec into the running pod
kubectl exec -i <pod_name> -n <app namespace> -- powershell
Go to webapp root folder, find and replace web.confg setting required
cd ../inetpub/wwwroot
$find='<add key="someAppSetting" value="true"/>'
$replace='<add key="someAppSetting" value="false"/>'
(gc web.config).replace($find, $replace) | sc web.config
select-string tracingEnabled web.config
# Do not stop start or iisreset. Be carfeul not to restart IIS because that will terminate the container.
# Instead, recycle the AppPool. This will fix most hangs and is so much more efficient.
stop-iissite "Default Web Site"
start-iissite "Default Web Site"
get-iissite
# Restart default app pool
Restart-WebAppPool -Name "DefaultAppPool"
No comments :
Post a Comment