Skip to content

Instantly share code, notes, and snippets.

@hibri
Created October 5, 2022 10:55
Show Gist options
  • Save hibri/feea23d9101049b25f968ab6786ec66f to your computer and use it in GitHub Desktop.
Save hibri/feea23d9101049b25f968ab6786ec66f to your computer and use it in GitHub Desktop.

Revisions

  1. hibri created this gist Oct 5, 2022.
    68 changes: 68 additions & 0 deletions Cdktfdotnet1.cs
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,68 @@
    class Program
    {
    public static void Main(string[] args)
    {
    App app = new App();
    MyStack stack = new MyStack(app, "datafactory");
    new LocalBackend(stack);
    app.Synth();
    }
    }

    public class MyStack : TerraformStack
    {
    public MyStack(Construct scope, string id) : base(scope, id)
    {
    var azurermProviderConfig = new AzurermProviderConfig() { Features = new AzurermProviderFeatures() };

    var azurermProvider = new AzurermProvider(this, "AzureRm", azurermProviderConfig);

    ResourceGroup rg = new ResourceGroup(this, "hibri-test", new ResourceGroupConfig
    {
    Location = "uksouth",
    Name = "hibri-test"
    });

    var storageAccountConfig = new StorageAccountConfig
    {
    Name = "hibrifuncstr",
    ResourceGroupName = rg.Name,
    Location = rg.Location,
    AccountReplicationType = "LRS",
    AccountTier = "Standard"


    };
    var functionStorageAccount = new StorageAccount(this, "hibrifuncstr", storageAccountConfig);

    var appServicePlanConfig = new ServicePlanConfig
    {
    Name = "test-plan",
    ResourceGroupName = rg.Name,
    Location = rg.Location,
    OsType = "Linux",
    SkuName = "B1"
    };
    var appServicePlan = new ServicePlan(this, "test-plan", appServicePlanConfig);
    var functionAppConfig = new LinuxFunctionAppConfig
    {
    Name = "hibrifuncapp",
    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"
    }

    }
    };
    var functionApp = new LinuxFunctionApp(this, "functionapp", functionAppConfig);

    }
    }