Created
October 5, 2022 14:39
-
-
Save hibri/1ae582a7dfeacf190c2f8827420e23e3 to your computer and use it in GitHub Desktop.
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
public class Function | |
{ | |
private readonly TerraformStack _stack; | |
private ServicePlan _appServicePlan; | |
private ResourceGroup _rg; | |
private StorageAccount _functionStorageAccount; | |
private string _functionName; | |
public Function(TerraformStack stack) | |
{ | |
_stack = stack; | |
} | |
public LinuxFunctionApp Build() | |
{ | |
WithName(_functionName); | |
var functionAppConfig = new LinuxFunctionAppConfig | |
{ | |
Name = _functionName, | |
ResourceGroupName = _rg.Name, | |
Location = _rg.Location, | |
ServicePlanId = _appServicePlan.Id, | |
AppSettings = new Dictionary<string, string>(), | |
StorageAccountName = _functionStorageAccount.Name, | |
StorageAccountAccessKey = _functionStorageAccount.SecondaryAccessKey, | |
SiteConfig = new LinuxFunctionAppSiteConfig | |
{ | |
ApplicationStack = new LinuxFunctionAppSiteConfigApplicationStack | |
{ | |
DotnetVersion = "6.0" | |
} | |
} | |
}; | |
return new LinuxFunctionApp(_stack, _functionName, functionAppConfig); | |
} | |
public Function WithName(string functionName) | |
{ | |
_functionName = functionName; | |
return this; | |
} | |
public Function UsingAppServicePlan(ServicePlan appServicePlan) | |
{ | |
_appServicePlan = appServicePlan; | |
return this; | |
} | |
public Function InResourceGroup(ResourceGroup rg) | |
{ | |
_rg = rg; | |
return this; | |
} | |
public Function WithStorageAccount(StorageAccount functionStorageAccount) | |
{ | |
_functionStorageAccount = functionStorageAccount; | |
return this; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment