Skip to content

Commit

Permalink
Update some .NET examples to Azure 2.1 (pulumi#603)
Browse files Browse the repository at this point in the history
Update some .NET examples to Azure 2.1
  • Loading branch information
mikhailshilkov committed Mar 16, 2020
1 parent ff4cee2 commit d825b81
Show file tree
Hide file tree
Showing 17 changed files with 71 additions and 82 deletions.
18 changes: 18 additions & 0 deletions Examples.sln
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,12 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Digitalocean.K8s", "digital
EndProject
Project("{6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705}") = "Azure.Aci", "azure-fs-aci\Azure.Aci.fsproj", "{9F646ECF-9CD3-4686-8C4C-FE6AAAD29FEC}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Azure.AKS.PrivateContainerRegistry", "azure-cs-aks-private-container-registry\Azure.AKS.PrivateContainerRegistry.csproj", "{23099098-BEE1-4199-B1AB-8864DE7276DA}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "azure-cs-static-website", "azure-cs-static-website\azure-cs-static-website.csproj", "{4DEEF787-D589-44C5-AAB1-570D2D920043}"
EndProject
Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "Azure.Aks", "azure-fs-aks\Azure.Aks.fsproj", "{555DED90-15AE-4620-ACEE-B53EC237C62B}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -87,6 +93,18 @@ Global
{9F646ECF-9CD3-4686-8C4C-FE6AAAD29FEC}.Debug|Any CPU.Build.0 = Debug|Any CPU
{9F646ECF-9CD3-4686-8C4C-FE6AAAD29FEC}.Release|Any CPU.ActiveCfg = Release|Any CPU
{9F646ECF-9CD3-4686-8C4C-FE6AAAD29FEC}.Release|Any CPU.Build.0 = Release|Any CPU
{23099098-BEE1-4199-B1AB-8864DE7276DA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{23099098-BEE1-4199-B1AB-8864DE7276DA}.Debug|Any CPU.Build.0 = Debug|Any CPU
{23099098-BEE1-4199-B1AB-8864DE7276DA}.Release|Any CPU.ActiveCfg = Release|Any CPU
{23099098-BEE1-4199-B1AB-8864DE7276DA}.Release|Any CPU.Build.0 = Release|Any CPU
{4DEEF787-D589-44C5-AAB1-570D2D920043}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{4DEEF787-D589-44C5-AAB1-570D2D920043}.Debug|Any CPU.Build.0 = Debug|Any CPU
{4DEEF787-D589-44C5-AAB1-570D2D920043}.Release|Any CPU.ActiveCfg = Release|Any CPU
{4DEEF787-D589-44C5-AAB1-570D2D920043}.Release|Any CPU.Build.0 = Release|Any CPU
{555DED90-15AE-4620-ACEE-B53EC237C62B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{555DED90-15AE-4620-ACEE-B53EC237C62B}.Debug|Any CPU.Build.0 = Debug|Any CPU
{555DED90-15AE-4620-ACEE-B53EC237C62B}.Release|Any CPU.ActiveCfg = Release|Any CPU
{555DED90-15AE-4620-ACEE-B53EC237C62B}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
8 changes: 4 additions & 4 deletions azure-cs-aks/Azure.AKS.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Pulumi.Azure" Version="1.14.0-preview" />
<PackageReference Include="Pulumi.AzureAD" Version="1.5.0-preview" />
<PackageReference Include="Pulumi.Random" Version="1.5.0-preview" />
<PackageReference Include="Pulumi.Tls" Version="1.4.0-preview" />
<PackageReference Include="Pulumi.Azure" Version="2.1.0-preview" />
<PackageReference Include="Pulumi.AzureAD" Version="1.6.0-preview" />
<PackageReference Include="Pulumi.Random" Version="1.6.0-preview" />
<PackageReference Include="Pulumi.Tls" Version="1.5.0-preview" />
</ItemGroup>

</Project>
2 changes: 1 addition & 1 deletion azure-cs-appservice/Azure.AppService.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Pulumi.Azure" Version="1.8.0-preview" />
<PackageReference Include="Pulumi.Azure" Version="2.1.0-preview" />
</ItemGroup>

</Project>
6 changes: 3 additions & 3 deletions azure-cs-appservice/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,12 @@ static Task<int> Main()
ContainerAccessType = "private",
});
var blob = new ZipBlob("zip", new ZipBlobArgs
var blob = new Blob("zip", new BlobArgs
{
StorageAccountName = storageAccount.Name,
StorageContainerName = container.Name,
Type = "block",
Content = new FileArchive("wwwroot"),
Type = "Block",
Source = new FileArchive("wwwroot"),
});
var codeBlobUrl = SharedAccessSignature.SignedBlobReadUrl(blob, storageAccount);
Expand Down
6 changes: 3 additions & 3 deletions azure-cs-botservice/Azure.BotService.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Pulumi.Azure" Version="1.8.0-preview" />
<PackageReference Include="Pulumi.AzureAD" Version="1.4.0-preview" />
<PackageReference Include="Pulumi.Random" Version="1.4.0-preview" />
<PackageReference Include="Pulumi.Azure" Version="2.1.0-preview" />
<PackageReference Include="Pulumi.AzureAD" Version="1.6.0-preview" />
<PackageReference Include="Pulumi.Random" Version="1.6.0-preview" />
</ItemGroup>

</Project>
9 changes: 4 additions & 5 deletions azure-cs-botservice/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
using Pulumi.Azure.AppService;
using Pulumi.Azure.AppService.Inputs;
using Pulumi.Azure.Bot;
using Pulumi.Azure.Cognitive.Inputs;
using Pulumi.Azure.Core;
using Pulumi.AzureAD;
using Pulumi.Random;
Expand Down Expand Up @@ -49,12 +48,12 @@ static Task<int> Main()
ContainerAccessType = "private",
});
var blob = new Storage.ZipBlob("zip", new Storage.ZipBlobArgs
var blob = new Storage.Blob("zip", new Storage.BlobArgs
{
StorageAccountName = storageAccount.Name,
StorageContainerName = container.Name,
Type = "block",
Content = new FileArchive("bot/publish")
Type = "Block",
Source = new FileArchive("bot/publish")
});
var codeBlobUrl = Storage.SharedAccessSignature.SignedBlobReadUrl(blob, storageAccount);
Expand All @@ -75,7 +74,7 @@ static Task<int> Main()
{
Kind = "CognitiveServices", // includes LUIS
ResourceGroupName = resourceGroup.Name,
Sku = new AccountSkuArgs { Name = "S0", Tier = "Standard" }
SkuName = "S0"
});
var msa = new Application("msapp", new ApplicationArgs
Expand Down
2 changes: 1 addition & 1 deletion azure-cs-functions-raw/Azure.FunctionsRaw.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Pulumi.Azure" Version="1.8.0-preview" />
<PackageReference Include="Pulumi.Azure" Version="2.1.0-preview" />
</ItemGroup>

<PropertyGroup>
Expand Down
6 changes: 3 additions & 3 deletions azure-cs-functions-raw/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,12 @@ static Task<int> Main()
ContainerAccessType = "private",
});
var blob = new ZipBlob("zip", new ZipBlobArgs
var blob = new Blob("zip", new BlobArgs
{
StorageAccountName = storageAccount.Name,
StorageContainerName = container.Name,
Type = "block",
Content = new FileArchive("./functions/bin/Debug/netcoreapp3.0/publish"),
Type = "Block",
Source = new FileArchive("./functions/bin/Debug/netcoreapp3.1/publish"),
});
var codeBlobUrl = SharedAccessSignature.SignedBlobReadUrl(blob, storageAccount);
Expand Down
4 changes: 2 additions & 2 deletions azure-cs-functions-raw/functions/Functions.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<AzureFunctionsVersion>v3-preview</AzureFunctionsVersion>
<AzureFunctionsVersion>v3</AzureFunctionsVersion>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Sdk.Functions" Version="1.0.30-beta2" />
<PackageReference Include="Microsoft.NET.Sdk.Functions" Version="3.0.5" />
</ItemGroup>

<ItemGroup>
Expand Down
4 changes: 2 additions & 2 deletions azure-cs-msi-keyvault-rbac/Azure.KeyVault.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Pulumi.Azure" Version="1.8.0-preview" />
<PackageReference Include="Pulumi.Random" Version="1.4.0-preview" />
<PackageReference Include="Pulumi.Azure" Version="2.1.0-preview" />
<PackageReference Include="Pulumi.Random" Version="1.6.0-preview" />
</ItemGroup>

<PropertyGroup>
Expand Down
12 changes: 6 additions & 6 deletions azure-cs-msi-keyvault-rbac/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@ static Task<int> Main()
{
StorageAccountName = storageAccount.Name,
StorageContainerName = storageContainer.Name,
Type = "block",
Source = "./README.md",
Type = "Block",
Source = new FileAsset("./README.md"),
});
// A plan to host the App Service
Expand All @@ -82,12 +82,12 @@ static Task<int> Main()
});
// ASP.NET deployment package
var blob = new ZipBlob("zip", new ZipBlobArgs
var blob = new Blob("zip", new BlobArgs
{
StorageAccountName = storageAccount.Name,
StorageContainerName = storageContainer.Name,
Type = "block",
Content = new FileArchive("./webapp/bin/Debug/netcoreapp2.2/publish"),
Type = "Block",
Source = new FileArchive("./webapp/bin/Debug/netcoreapp2.2/publish"),
});
var clientConfig = await Pulumi.Azure.Core.Invokes.GetClientConfig();
Expand Down Expand Up @@ -119,7 +119,7 @@ static Task<int> Main()
KeyVaultId = vault.Id,
Value = SharedAccessSignature.SignedBlobReadUrl(blob, storageAccount),
});
var secretUri = Output.Format($"{secret.VaultUri}secrets/{secret.Name}/{secret.Version}");
var secretUri = Output.Format($"{vault.VaultUri}secrets/{secret.Name}/{secret.Version}");
// The application hosted in App Service
Expand Down
44 changes: 9 additions & 35 deletions azure-cs-static-website/Program.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
using System.Collections.Generic;
using System.Threading.Tasks;
using Microsoft.Azure.Storage;
using Microsoft.Azure.Storage.Blob;
using Microsoft.Azure.Storage.Shared.Protocol;
using Pulumi;
using Pulumi.Azure.Core;
using Pulumi.Azure.Storage;
using Pulumi.Azure.Storage.Inputs;

class Program
{
Expand All @@ -23,13 +21,12 @@ static Task<int> Main()
EnableHttpsTrafficOnly = true,
AccountReplicationType = "LRS",
AccountTier = "Standard",
AccountKind = "StorageV2"
AccountKind = "StorageV2",
StaticWebsite = new AccountStaticWebsiteArgs
{
IndexDocument = "index.html"
}
});
// We can't enable static sites using Pulumi (it's not exposed in the ARM API).
// Therefore we have to invoke the Azure SDK from within the Pulumi code to enable the static sites
// The code in the Apply method must be idempotent.
var containerName = storageAccount.PrimaryBlobConnectionString.Apply(async v => await EnableStaticSites(v) );
// Upload the files
var files = new[]{"index.html", "404.html"};
Expand All @@ -39,41 +36,18 @@ static Task<int> Main()
{
Name = file,
StorageAccountName = storageAccount.Name,
StorageContainerName =containerName,
StorageContainerName = "$web",
Type = "Block",
Source = $"./wwwroot/{file}",
Source = new FileAsset($"./wwwroot/{file}"),
ContentType = "text/html",
});
}
// Export the Web address string for the storage account
return new Dictionary<string, object>
return new Dictionary<string, object?>
{
{ "staticEndpoint", storageAccount.PrimaryWebEndpoint },
};
});


static async Task<string> EnableStaticSites(string connectionString)
{
if (!Deployment.Instance.IsDryRun)
{
var sa = CloudStorageAccount.Parse(connectionString);

var blobClient = sa.CreateCloudBlobClient();
var blobServiceProperties = new ServiceProperties
{
StaticWebsite = new StaticWebsiteProperties
{
Enabled = true,
IndexDocument = "index.html",
ErrorDocument404Path = "404.html"
}
};
await blobClient.SetServicePropertiesAsync(blobServiceProperties);
}

return "$web";
}
}
}
6 changes: 2 additions & 4 deletions azure-cs-static-website/azure-cs-static-website.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,12 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp3.0</TargetFramework>
<TargetFramework>netcoreapp3.1</TargetFramework>
<Nullable>enable</Nullable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Pulumi.Azure" Version="1.4.0-preview" />
<PackageReference Include="Microsoft.Azure.Storage.Blob" Version="11.1.2" />
<PackageReference Include="Microsoft.Azure.Storage.Common" Version="11.1.2"/>
<PackageReference Include="Pulumi.Azure" Version="2.1.0-preview" />
</ItemGroup>

</Project>
2 changes: 1 addition & 1 deletion azure-cs-webserver/Azure.WebServer.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Pulumi.Azure" Version="1.8.0-preview" />
<PackageReference Include="Pulumi.Azure" Version="2.1.0-preview" />
</ItemGroup>

</Project>
10 changes: 5 additions & 5 deletions azure-fs-aks/Azure.Aks.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@
<Compile Include="Program.fs" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Pulumi.Azure" Version="1.14.0-preview" />
<PackageReference Include="Pulumi.AzureAD" Version="1.5.0-preview" />
<PackageReference Include="Pulumi.FSharp" Version="1.10.1-preview" />
<PackageReference Include="Pulumi.Random" Version="1.5.0-preview" />
<PackageReference Include="Pulumi.Tls" Version="1.4.0-preview" />
<PackageReference Include="Pulumi.Azure" Version="2.1.0-preview" />
<PackageReference Include="Pulumi.AzureAD" Version="1.6.0-preview" />
<PackageReference Include="Pulumi.FSharp" Version="1.12.1-preview" />
<PackageReference Include="Pulumi.Random" Version="1.6.0-preview" />
<PackageReference Include="Pulumi.Tls" Version="1.5.0-preview" />
</ItemGroup>
</Project>
4 changes: 2 additions & 2 deletions azure-fs-appservice/Azure.AppService.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Pulumi.FSharp" Version="1.7.0-preview" />
<PackageReference Include="Pulumi.Azure" Version="1.8.0-preview" />
<PackageReference Include="Pulumi.FSharp" Version="1.12.1-preview" />
<PackageReference Include="Pulumi.Azure" Version="2.1.0-preview" />
</ItemGroup>

</Project>
10 changes: 5 additions & 5 deletions azure-fs-appservice/Program.fs
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,14 @@ let infra () =
(StorageAccountName = io storageAccount.Name,
ContainerAccessType = input "private"))

let archive = FileArchive("wwwroot") :> Archive
let archive = FileArchive("wwwroot") :> AssetOrArchive
let blob =
ZipBlob("zip",
ZipBlobArgs
Blob("zip",
BlobArgs
(StorageAccountName = io storageAccount.Name,
StorageContainerName = io container.Name,
Type = input "block",
Content = input archive))
Type = input "Block",
Source = input archive))

let codeBlobUrl = SharedAccessSignature.SignedBlobReadUrl(blob, storageAccount)

Expand Down

0 comments on commit d825b81

Please sign in to comment.