-
Notifications
You must be signed in to change notification settings - Fork 880
/
MyStack.cs
52 lines (44 loc) · 1.78 KB
/
MyStack.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
// Copyright 2016-2022, Pulumi Corporation. All rights reserved.
using System;
using Pulumi;
using AzureNative = Pulumi.AzureNative;
using Resources = Pulumi.AzureNative.Resources;
using Sql = Pulumi.AzureNative.Sql;
using Pulumi.Random;
class MyStack : Stack
{
public MyStack()
{
var resourceGroup = new Resources.ResourceGroup("resourceGroup");
var password = new Pulumi.Random.RandomPassword("admin-password", new Pulumi.Random.RandomPasswordArgs { Length = 20 });
Sql.Server server = new Sql.Server(
"server",
new Sql.ServerArgs
{
AdministratorLogin = "admin-user",
AdministratorLoginPassword = password.Result,
ResourceGroupName = resourceGroup.Name,
ServerName = $"{Pulumi.Deployment.Instance.StackName}",
MinimalTlsVersion = "1.2",
PublicNetworkAccess = "Enabled"
});
this.ServerName = server.Name.Apply(servername => $"{servername}.database.windows.net");
Sql.Database database = new Sql.Database(
"db",
new Sql.DatabaseArgs
{
DatabaseName = "database",
ServerName = server.Name,
Collation = "SQL_Latin1_General_CP1_CI_AI",
ResourceGroupName = resourceGroup.Name,
Sku = new AzureNative.Sql.Inputs.SkuArgs
{
Capacity = 2,
Family = "Gen5",
Name = "GP_S", /*Serverless*/
}
});
}
[Output("serverName")]
public Output<string> ServerName { get; set; }
}