-
Notifications
You must be signed in to change notification settings - Fork 4.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement AppServiceFeature (#47269)
- Loading branch information
1 parent
a24e586
commit a0363ff
Showing
9 changed files
with
151 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
70 changes: 70 additions & 0 deletions
70
sdk/provisioning/Azure.Provisioning.CloudMachine/src/AzureSdkExtensions/AppServiceFeature.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License. | ||
|
||
using Azure.Provisioning.CloudMachine; | ||
using Azure.Provisioning.Expressions; | ||
using Azure.Provisioning.AppService; | ||
using Azure.Provisioning.Primitives; | ||
using Azure.Provisioning.Resources; | ||
|
||
namespace Azure.CloudMachine.AppService; | ||
|
||
public class AppServiceFeature : CloudMachineFeature | ||
{ | ||
public AppServiceSkuDescription Sku { get; set; } | ||
|
||
public AppServiceFeature(AppServiceSkuDescription? sku = default) | ||
{ | ||
if (sku == default) | ||
{ | ||
sku = new AppServiceSkuDescription { Tier = "Free", Name = "F1" }; | ||
} | ||
Sku = sku; | ||
} | ||
|
||
protected override ProvisionableResource EmitCore(CloudMachineInfrastructure infrastructure) | ||
{ | ||
//Add a App Service to the CloudMachine infrastructure. | ||
AppServicePlan hostingPlan = new("cm_hosting_plan") | ||
{ | ||
Name = infrastructure.Id, | ||
Sku = Sku, | ||
Kind = "app" | ||
}; | ||
infrastructure.AddResource(hostingPlan); | ||
|
||
WebSite appService = new("cm_website") | ||
{ | ||
Name = infrastructure.Id, | ||
Kind = "app", | ||
Tags = { { "azd-service-name", infrastructure.Id } }, | ||
Identity = new() | ||
{ | ||
ManagedServiceIdentityType = ManagedServiceIdentityType.UserAssigned, | ||
UserAssignedIdentities = { { BicepFunction.Interpolate($"{infrastructure.Identity.Id}").Compile().ToString(), new UserAssignedIdentityDetails() } } | ||
}, | ||
AppServicePlanId = hostingPlan.Id, | ||
IsHttpsOnly = true, | ||
IsEnabled = true, | ||
SiteConfig = new() | ||
{ | ||
IsHttp20Enabled = true, | ||
MinTlsVersion = AppServiceSupportedTlsVersion.Tls1_2, | ||
IsWebSocketsEnabled = true, | ||
AppSettings = new() | ||
{ | ||
// This is used by the CloudMachineWorkspace to detect that it is running in a deployed App Service. | ||
// The ClientId is used to create a ManagedIdentityCredential so that it wires up to our CloudMachine user-assigned identity. | ||
new AppServiceNameValuePair | ||
{ | ||
Name = "CLOUDMACHINE_MANAGED_IDENTITY_CLIENT_ID", | ||
Value = infrastructure.Identity.ClientId | ||
}, | ||
} | ||
} | ||
}; | ||
infrastructure.AddResource(appService); | ||
|
||
return appService; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters