Target role for dynamically created function app

Hi,

My goal is similar to the dynamic infrastructure scenario from your blog article here and the deployment process steps are as follows:

  1. Deploy ARM Template
  2. Create Deployment Target
  3. Create Deployment Slot
  4. Deploy FunctionApp
  5. Swap Deployment Slot

Pleease note, I am deploying FunctionApp not WebApp and my Deployment step customised version of the already existing template here.

Since I am creating the deployment target on the fly it’s role is not known for the deployment step 4, where I can not use a variable for a “target role” I am deploying to?

I am not sure how to deploy to a dynamically created “target role”… step 4 doesn’t take variable?!

I have already reviewed similar questions like Target role as a variable and Azure Web app deployment - use a variable rather than target role but failed to come-up with modeling solution to acheive my goal…

Thanks for your help in advance!
Emil

Hey there Emil! What about changing the Execution Location to a Worker and running the step there? Azure WebApps are considered targets whereas Functions are not so they won’t necessarily have a Role to use.

Hi Shawn,

yes that will work, however I also want to apply the same deployment process for WebApps. I am looking for workaround that would work for both Function & Web apps…

Is there a workaround for WebApps?

Greetings Emil, thanks for getting back to me. Can you elaborate as to why the role needs to be dynamic?

I want to have parametised deployment process for Azure Functions and Azure WebAps that create any required Azure Infrastructure Resources and also deploys Applications code.

The process defines one standard way to provision Azure Resources and Deploy apps to those resources.

For this to happen I simply use project level parameters that define the ARM PackageId & the Application PackageId.

This also means anyone can copy existing deployment project and change the names of the ARM template packageId & the application packageId and they have a brand new self-contained deployment pipeline that is reusing existing app service plans etc.

I want to avoid the dependency on any predefined config like the target roles. In other words I am trying to drive everything from project variables and the deplyment steps look something like the list below:

  1. Deploy ARM Template - creates any missing Azure resource, template is also source controlled and pushed to Octopus repo at the end of Azure DevOps build that verufies & tests the template.
  2. Create Deployment Target - role will be something like #{AppName}Role
  3. Create Deployment Slot - creates a staging slot to deploy to
  4. Deploy FunctionApp - deploys the prebuild binary for the function or web app
  5. Swap Deployment Slot

I am also open to suggestions how to achieve this - the goal is to have a process that does not know anything about infrastructure & application - the scope is only for function & web apps.

I hope this makes sense - let me know if somehting is not clear.

Thanks,
Emil

I’m talking with my colleagues about this and hope to get back to you soon. In the meantime, have a look at Bob Walkers demo on Infrastructure as Code he did for the KCDC conference. It is similar to what you are wanting to do

Hi Shawn,

thank yo ufor the IaC Demo - this is indeed what we do but we don’t use a storage account for our bootstap script but push them to Octopus package repository after each build triggered by code change. It is more complicated but all changes are source controlled and package pushes are automated.
We use one PowerShell module that is acts as our Octopus deployment scripts library.

Anyway, I will experiment further getting around the issue of the target role as described in earlier post.
It will be good if you guys provide best practice way around this as I can see this question pops up regularly on attempts to automate the deployment process.

Thanks,
Emil

Hey there Emil! I discussed this with my team, we were unable to find a solution that would work in the case of Azure Web Apps. We are working on a Terraform Provider that might be able to help in your case when it is released.

Regards,
Shawn

@Shawn_Sesna,

Thanks for the update, however I honor the principle if there is a will there is a way, so I won’t give up :smile:

Meanwhile please bookmark this thread, I shall wait for an update in near future :+1:

Thanks,
Emil

Sounds good!

Regards,

Shawn

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.