Skip to content

Commit

Permalink
Fix Azure Python Functions Raw example (pulumi#586)
Browse files Browse the repository at this point in the history
  • Loading branch information
mikhailshilkov authored Mar 3, 2020
1 parent c13f8f5 commit 7dd5f56
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 35 deletions.
56 changes: 24 additions & 32 deletions azure-py-functions-raw/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,42 +19,35 @@

httpdotnet_zib_blob=storage.ZipBlob(
"http-dotnet",
resource_group_name=resource_group.name,
storage_account_name=httpdotnet_storage_account.name,
storage_container_name=httpdotnet_container.name,
type="block",
content=asset.AssetArchive({
".": asset.FileArchive("./dotnet/bin/Debug/netcoreapp2.1/publish")
".": asset.FileArchive("./dotnet/bin/Debug/netcoreapp3.1/publish")
}))

account_sas=storage.get_account_sas(
connection_string=httpdotnet_storage_account.primary_connection_string,
start="2019-01-01",
expiry="2029-01-01",
services={
"blob": "true",
"queue": "false",
"table": "false",
"file": "false"
},
resource_types={
"service": "false",
"container": "false",
"object": "true"
},
permissions={
"read": "true",
"write": "false",
"delete": "false",
"add": "false",
"list": "false",
"create": "false",
"update": "false",
"process": "false"
},
)
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]}")
def get_sas(args):
blob_sas = storage.get_account_blob_container_sas(
connection_string=args[1],
start="2020-01-01",
expiry="2030-01-01",
container_name=args[2],
permissions={
"read": "true",
"write": "false",
"delete": "false",
"list": "false",
"add": "false",
"create": "false"
}
)
return f"https://{args[0]}.blob.core.windows.net/{args[2]}/{args[3]}{blob_sas.sas}"

httpdotnet_signed_blob_url = Output.all(
httpdotnet_storage_account.name,
httpdotnet_storage_account.primary_connection_string,
httpdotnet_container.name, httpdotnet_zib_blob.name
).apply(get_sas)

httpdotnet_plan=appservice.Plan(
"http-dotnet",
Expand All @@ -71,10 +64,9 @@
resource_group_name=resource_group.name,
app_service_plan_id=httpdotnet_plan.id,
storage_connection_string=httpdotnet_storage_account.primary_connection_string,
version="~2",
version="~3",
app_settings={
"runtime": "dotnet",
"WEBSITE_NODE_DEFAULT_VERSION": "8.11.1",
"WEBSITE_RUN_FROM_PACKAGE": httpdotnet_signed_blob_url,
},
)
Expand Down
6 changes: 3 additions & 3 deletions azure-py-functions-raw/dotnet/functionapp-dotnet.csproj
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp2.1</TargetFramework>
<AzureFunctionsVersion>v2</AzureFunctionsVersion>
<TargetFramework>netcoreapp3.1</TargetFramework>
<AzureFunctionsVersion>v3</AzureFunctionsVersion>
<RootNamespace>functionapp_dotnet</RootNamespace>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.NET.Sdk.Functions" Version="1.0.24" />
<PackageReference Include="Microsoft.NET.Sdk.Functions" Version="3.0.4" />
</ItemGroup>
<ItemGroup>
<None Update="host.json">
Expand Down

0 comments on commit 7dd5f56

Please sign in to comment.