Run PowerShell script for each tenant

(Qasim Ishaq) #1

Hi,

We have 100+ tenants which are ASP.NET sites for each of our client. Each site has web.config file with its own connection string and other client specific settings. I want to make modifications in web.config file using PowerShell script. If I run Post Deployment Script in a Step, will it run for each tenant? Can I write relative path of web.config in my script like this?

[xml]$result = Get-Content \Web.config
$httpErrorNode = $result.configuration.'system.webServer'.httpErrors.SetAttribute('Key','Value')
$result.Save('\Web.config')
(Kenneth Bates) #3

Hi Qasim,

Thanks for getting in touch! When performing tenanted deployments, it executes a deployment task per tenant, so it will run for each. You can also write a relative path to the config file as it exists in your package, so your solution looks like it would work.

An alternative could be to perform config transformations on each of your tenants. This would work if you have tenant-specific transform files in your package, and Octopus will also run them automatically if the transform file names follow the convention *.<TenantName>.config. More information on configuration transforms feature and the conventions (and the order in which they’re executed) Octopus follows can be found in our documentation.

I hope this helps! Let me know if there’s anything else I can assist with moving forward. :slight_smile:

Best regards,

Kenny