print(location)

resource_group = core.ResourceGroup('my_pulumi_resource_group',
                                    location=location)

# Create an Azure resource (Storage Account)
account = storage.Account(
    'storage',
    # The location for the storage account will be derived automatically from the resource group.
    resource_group_name=resource_group.name,
    account_tier='Standard',
    account_replication_type='LRS')

# play around with some resource groups and maybe a function?
appService = appservice.Plan("appServicePlan",
                             resource_group_name=resource_group.name,
                             sku={
                                 "tier": "free",
                                 "size": "F1"
                             })

example_function = appservice.FunctionApp(
    "MyTestFunction",
    resource_group_name=resource_group.name,
    app_service_plan_id=appService.id,
    app_settings={"runtime": "python"},
    storage_connection_string=account)

# Export the connection string for the storage account
pulumi.export('connection_string', account.primary_connection_string)
http_signed_blob_url = Output.all(
    http_storage_account.name, http_storage_account.primary_connection_string,
    http_container.name, http_zib_blob.name).apply(get_sas)

http_plan = appservice.Plan(
    "http",
    resource_group_name=resource_group.name,
    kind="Linux",
    sku=appservice.PlanSkuArgs(tier="Dynamic", size="Y1"),
    reserved=True,
)

http_function_app = appservice.FunctionApp(
    "http",
    resource_group_name=resource_group.name,
    app_service_plan_id=http_plan.id,
    storage_account_name=http_storage_account.name,
    storage_account_access_key=http_storage_account.primary_access_key,
    version="~3",
    app_settings={
        "FUNCTIONS_WORKER_RUNTIME": "python",
        "WEBSITE_RUN_FROM_PACKAGE": http_signed_blob_url,
    },
)

export(
    "endpoint",
    http_function_app.default_hostname.apply(
        lambda endpoint: "https://" + endpoint + "/api/HelloPython?name=Pulumi"
    ))
Beispiel #3
0
httpdotnet_signed_blob_url = Output.all(httpdotnet_storage_account.name, httpdotnet_container.name, httpdotnet_zib_blob.name, account_sas.sas) \
    .apply(lambda args: f"https://{args[0]}.blob.core.windows.net/{args[1]}/{args[2]}{args[3]}")

httpdotnet_plan = appservice.Plan("http-dotnet",
                                  resource_group_name=resource_group.name,
                                  kind="FunctionApp",
                                  sku={
                                      "tier": "Dynamic",
                                      "size": "Y1"
                                  })

httpdotnet_function_app = appservice.FunctionApp(
    "http-dotnet",
    resource_group_name=resource_group.name,
    app_service_plan_id=httpdotnet_plan.id,
    storage_connection_string=httpdotnet_storage_account.
    primary_connection_string,
    version="~2",
    app_settings={
        "runtime": "dotnet",
        "WEBSITE_NODE_DEFAULT_VERSION": "8.11.1",
        "WEBSITE_RUN_FROM_PACKAGE": httpdotnet_signed_blob_url,
    },
)

export(
    "dotnet_endpoint",
    httpdotnet_function_app.default_hostname.apply(
        lambda endpoint: "https://" + endpoint + "/api/HelloDotnet?name=Pulumi"
    ))
                                 kind="FunctionApp",
                                 reserved=True,
                                 sku={
                                     "tier": "Dynamic",
                                     "size": "Y1"
                                 })

scheduler_app = appservice.FunctionApp(
    "serverless-scheduler",
    name="serverless-scheduler",
    resource_group_name=resource_group.name,
    app_service_plan_id=scheduler_plan.id,
    https_only=True,
    os_type="linux",  # doesn't work??
    storage_connection_string=scheduler_account.primary_connection_string,
    version="~3",
    app_settings={
        "FUNCTIONS_WORKER_RUNTIME": "dotnet",
        "APPINSIGHTS_INSTRUMENTATIONKEY": app_insights.instrumentation_key,
        "ServiceBusConnection": sbnamespace.default_primary_connection_string,
        "TwitterAPIKey": "",
        "TwitterAPISecret": "",
        "TwitterAccessToken": "",
        "TwitterAccessTokenSecret": ""
    })

# Export the connection string for the storage account
pulumi.export('storage account constr',
              scheduler_account.primary_connection_string)
pulumi.export('function app kind', scheduler_app.kind)