forked from pulumi/examples
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request pulumi#1155 from chetta19/azure-cs-sqlserver
Azure cs sqlserver
- Loading branch information
Showing
6 changed files
with
125 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<OutputType>Exe</OutputType> | ||
<TargetFramework>netcoreapp3.1</TargetFramework> | ||
<Nullable>enable</Nullable> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="Pulumi" Version="3.*" /> | ||
<PackageReference Include="Pulumi.AzureNative" Version="1.*" /> | ||
<PackageReference Include="Pulumi.Docker" Version="2.*" /> | ||
<PackageReference Include="Pulumi.Random" Version="4.*" /> | ||
</ItemGroup> | ||
|
||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,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; } | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
// Copyright 2016-2021, Pulumi Corporation. All rights reserved. | ||
|
||
using System.Threading.Tasks; | ||
using Pulumi; | ||
|
||
class Program | ||
{ | ||
static Task<int> Main() => Deployment.RunAsync<MyStack>(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
name: azure-cs-sqlserver | ||
runtime: dotnet | ||
description: An example of a SQLServer on Azure PaaS |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
[![Deploy](https://get.pulumi.com/new/button.svg)](https://app.pulumi.com/new?template=https://github.com/pulumi/examples/blob/master/azure-cs-sqlserver/README.md) | ||
|
||
# A SQLServer on Azure PaaS | ||
|
||
This example configures [An example of a SQLServer on Azure PaaS](https://docs.microsoft.com/en-us/azure/azure-sql/database/logical-servers). | ||
|
||
In addition to the server itself, a database is configured | ||
|
||
## Running the App | ||
|
||
1. Create a new stack: | ||
|
||
``` | ||
$ pulumi stack init dev | ||
``` | ||
|
||
1. Login to Azure CLI (you will be prompted to do this during deployment if you forget this step): | ||
|
||
``` | ||
$ az login | ||
``` | ||
1. Set the Azure region location to use: | ||
|
||
``` | ||
$ pulumi config set azure-native:location westus | ||
``` | ||
|
||
1. Run `pulumi up` to preview and deploy changes: | ||
|
||
``` | ||
$ pulumi up | ||
Previewing changes: | ||
... | ||
Performing changes: | ||
... | ||
Resources: | ||
+ 5 created | ||
Duration: 3m16s | ||
``` | ||
|
||
1. Check the deployed sql server and database |