Skip to content

Commit bf861f0

Browse files
committed
Add Bicep templates for API infrastructure and configure OpenAPI in Program.cs
1 parent 7acdcad commit bf861f0

File tree

5 files changed

+72
-6
lines changed

5 files changed

+72
-6
lines changed

.github/workflows/api.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
# This workflow will build a .NET project
2-
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-net
31

42
name: API
53

README.md

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,17 @@
1-
# generate-url-shortene
2-
Let's Build It: Url Shortener Project
1+
# Generate-url-shortene
2+
3+
## Let's Build It: Url Shortener Project
4+
5+
## Infrastructure as Code
6+
7+
### Log in into Azure
8+
9+
```bash
10+
az login
11+
```
12+
13+
### Create Resource Group
14+
15+
```bash
16+
az group create --name rg-urlshortener-dev --location EastAsia
17+
```

UrlShortener.Api/Program.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
var builder = WebApplication.CreateBuilder(args);
22

3-
// Add services to the container.
4-
// Learn more about configuring OpenAPI at https://aka.ms/aspnet/openapi
3+
54
builder.Services.AddOpenApi();
65

76
var app = builder.Build();

infrastructure/main.bicep

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
param location string = resourceGroup().location
2+
3+
var uniqueId = uniqueString(resourceGroup().id)
4+
5+
module apiService 'modules/compute/appservice.bicep'= {
6+
name: 'apiDeployment'
7+
params: {
8+
location: location
9+
appName: 'api-${uniqueId}'
10+
appServiceplanName: 'plan-api-${uniqueId}'
11+
}
12+
}
13+
14+
15+
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
param location string = resourceGroup().location
2+
param appServiceplanName string
3+
param appName string
4+
5+
resource appServicePlan 'Microsoft.Web/serverfarms@2023-12-01' = {
6+
name: appServiceplanName
7+
location: location
8+
kind: 'linux'
9+
sku: {
10+
name: 'B1'
11+
}
12+
properties: {
13+
reserved: true
14+
}
15+
}
16+
17+
18+
resource webApp 'Microsoft.Web/sites@2023-12-01' = {
19+
name: appName
20+
location: location
21+
properties: {
22+
serverFarmId: appServicePlan.id
23+
httpsOnly: true
24+
siteConfig: {
25+
linuxFxVersion: 'DOTNETCORE|9.0'
26+
}
27+
}
28+
}
29+
30+
31+
resource webAppConfig 'Microsoft.Web/sites/config@2023-12-01' = {
32+
parent: webApp
33+
name: 'web'
34+
properties: {
35+
scmType: 'GitHub'
36+
}
37+
}
38+
39+
output webAppId string = webApp.id

0 commit comments

Comments
 (0)