blob: b2e96424f72e702d028db7abdfb354f771fbcc95 (
plain)
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
|
---
title: 'Simple Url Shortner With Powershell and Azure Functions'
date: 2022-02-07T15:03:12+01:00
draft: true
---
In this article we're going to setup a simple url shortner written in Powershell, hosted with Azure Functions and Azure Table Storage for persistence.
<!--more-->
## 1. Creating our resources in Azure
### 1.1 Connect to Azure
```pwsh
Connect-AzAccount
```
### 1.1 Resource Group
```powershell
$resourceGroup = New-AzResourceGroup -Name "simple-url-shortner" -Location "westeurope"
```
### 1.2 Azure Storage Account
```powershell
$storageAccount = New-AzStorageAccount -ResourceGroupName $resourceGroup.ResourceGroupName `
-Name "simpleurlshorner001" `
-SkuName "Standard_LRS" `
-Location "westeurope"
```
### 1.3 Azure Functions
```powershell
$funcApp = New-AzFunctionApp -Name "simpleurlshortner001" `
-ResourceGroupName $resourceGroup.ResourceGroupName `
-StorageAccount $storageAccount.StorageAccountName `
-Runtime "Powershell" `
-FunctionsVersion 3 `
-Location "westeurope"
```
## 2. Building our function
```bash
func init simpleurlshortner --powershell
cd simpleurlshortner
func new --name URLHandler --template "HTTP Trigger" --authlevel "anonymous"
```
### 2.1 Create short url
### 2.2 Lookup short url
## 3. Testing
```bash
func start
```
## Resources
- [https://docs.microsoft.com/en-us/azure/azure-functions/create-first-function-cli-powershell?tabs=azure-powershell%2Cbrowser](https://docs.microsoft.com/en-us/azure/azure-functions/create-first-function-cli-powershell?tabs=azure-powershell%2Cbrowser)
|