Skip to content

Instantly share code, notes, and snippets.

@hibri
Created October 5, 2022 14:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hibri/1ae582a7dfeacf190c2f8827420e23e3 to your computer and use it in GitHub Desktop.
Save hibri/1ae582a7dfeacf190c2f8827420e23e3 to your computer and use it in GitHub Desktop.
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