Skip to content

Commit

Permalink
Merge pull request pulumi#1155 from chetta19/azure-cs-sqlserver
Browse files Browse the repository at this point in the history
Azure cs sqlserver
  • Loading branch information
guineveresaenger committed Mar 4, 2022
2 parents 828e209 + 4de8678 commit 483b55e
Show file tree
Hide file tree
Showing 6 changed files with 125 additions and 1 deletion.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ Example | Description |
[API Gateway](aws-ts-apigateway) | Deploy a simple REST API that counts the number of times a route has been hit.
[API Gateway HTTP API with routes](aws-ts-apigatewayv2-http-api) | Deploy a HTTP API that invokes a Lambda.
[API Gateway HTTP API quickstart](aws-ts-apigatewayv2-http-api-quickcreate) | Deploy a very simple HTTP API that invokes a Lambda.
[API Gateway V1 with EventBridge and Lambda](aws-ts-apigateway-eventbridge) | Deploy a REST API that uses EventBridge to target a Lambda function. Includes API Gateway model validation and custom integration-response mapping.
[API Gateway V1 with EventBridge and Lambda](aws-ts-apigateway-eventbridge) | Deploy a REST API that uses EventBridge to target a Lambda function. Includes API Gateway model validation and custom integration-response mapping.
[API Gateway V2 with EventBridge and Lambda](aws-ts-apigatewayv2-eventbridge) | Deploy an HTTP API that uses EventBridge to target a Lambda function.
[Apigateway - Auth0](aws-ts-apigateway-auth0) | Deploy a simple REST API protected by Auth0.
[AppSync](aws-ts-appsync) | Deploy a basic GraphQL endpoint in AWS AppSync.
Expand Down Expand Up @@ -220,6 +220,8 @@ Cluster.
[Azure Functions](azure-cs-functions) | Deploy a Node.js serverless function to Azure Functions.
[Static Website](azure-cs-static-website) | Configure static website hosting in Azure Storage.
[Azure Synapse](azure-cs-synapse) | Starting point for enterprise analytics solutions based on Azure Synapse.
[Azure SQL Server](azure-cs-sqlserver) | An example of a SQLServer on Azure PaaS.


## GCP

Expand Down
16 changes: 16 additions & 0 deletions azure-cs-sqlserver/Azure.SQLServer.csproj
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>
52 changes: 52 additions & 0 deletions azure-cs-sqlserver/MyStack.cs
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; }

}
9 changes: 9 additions & 0 deletions azure-cs-sqlserver/Program.cs
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>();
}
3 changes: 3 additions & 0 deletions azure-cs-sqlserver/Pulumi.yaml
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
42 changes: 42 additions & 0 deletions azure-cs-sqlserver/README.md
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

0 comments on commit 483b55e

Please sign in to comment.