question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Create a WebApp in an existing ServicePlan

See original GitHub issue

Hi I’ve been playing around with trying to create a webApp in an existing ASP. The ASP will be shared and configured manually so I don’t want the ARM template I generate to modify it or try to deploy it in any way.

Is there a good way to do this? If not, have there been discussions thoughts on how this might be possible and would it be something you would be interested in including? (I may, depending on work schedule, and subject to an acceptable design be able to contribute if so)

I have been playing around and the following script produces something very close to what I want.

let webAppName :string = ...
let aspName :string = ...

let sharedServicePlan = 
    sprintf "[concat(resourceGroup().id,'/providers/Microsoft.Web/serverfarms/%s')]" aspName
    |> ResourceName
    |> External

let webApp = webApp {
    name "codat-my-web-app"
    service_plan_name sharedServicePlan
    app_insights_off
}

let deployment = arm{
    location Location.UKSouth
    add_resource webApp
}

However, this outputs an ARM template with an unmet dependency which causes

InvalidTemplate - Long running operation failed with status 'Failed'. Additional Info:'Deployment template validation
failed: 'The resource 'Microsoft.Web/serverfarms/...' is not defined in the template. 

If, however, I remove the single entry in the dependsOn array, it does exactly what I want.

      "dependsOn": [
-        "[concat(resourceGroup().id,'/providers/Microsoft.Web/serverfarms/...')]" 
      ],

Obviously having to include an ARM expression is sub par and it would be good to make this something similar to the following

let sharedServicePlan : ResourceName = ExternalResource.ServicePlan ResourceGroup.Current aspName

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:16 (16 by maintainers)

github_iconTop GitHub Comments

1reaction
isaacabrahamcommented, Aug 11, 2020

@TheRSP Apologies, just saw this. I’ll push out a release today.

1reaction
isaacabrahamcommented, Jul 23, 2020

@rjwpope Great. I have a pull request ready to go and have applied the same changes across other “linkable” resources. In the end I indeed redesigned the types so we effectively have four cases:

  • Create the resource using a name derived from another resource
  • Create the resource using a name supplied by the user
  • Link to an farmer-managed resource and set up dependencies
  • Link to an existing unmanaged resource and don’t set up any dependencies
Read more comments on GitHub >

github_iconTop Results From Across the Web

Manage an App Service plan in Azure
Learn how to perform different tasks to manage an App Service plan, such as create, move, scale, and delete.
Read more >
Use an App Service Environment - Azure
Select Create a resource > Web + Mobile > Web App. Select a subscription. Enter a name for a new resource group, or...
Read more >
Azure - can't create a new web app on an existing service ...
It used to be a case of create new web app -> select service plan -> choose existing -> select from existing app...
Read more >
Create Azure Web App in existing App Hosting Plan using ...
In above line of code, resourceGroup(). Name will provide the name of current azure resource group used for deployment.
Read more >
Step-by-Step Guide to Creating Web Apps and Using App ...
Before creating a web app, you need to set up an App Service Plan. Here's how: ... Choose the existing App Service Plan...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found