Project

General

Profile

Azure VPS setup notes » History » Version 23

Jon Goldberg, 06/04/2021 04:52 PM

1 12 Jon Goldberg
{{last_updated_at}} by {{last_updated_by}}
2
3 14 Jon Goldberg
# Microsoft Azure - Setup
4 6 Jon Goldberg
5 14 Jon Goldberg
## For the Client
6 6 Jon Goldberg
7 22 Jon Goldberg
Hi there!  If I've directed you to this page, the part that concerns you are the first three sections only.  It's a bit convoluted, so feel free to ask me if you run into trouble! -Jon
8 14 Jon Goldberg
9 1 Jon Goldberg
[**NOTE**: Most of Microsoft's pages break with an ad blocker enabled.]
10 6 Jon Goldberg
11
### Get a Sponsorship
12
* [Go to the Nonprofit Microsoft Getting Started page](https://nonprofit.microsoft.com/en-us/getting-started).  Fill out the paperwork to be approved as a 501c3.  Approval can take 1 day or 3-4 weeks - I've seen both multiple times.
13
* Once approved, go to https://www.microsoft.com/en-us/nonprofits/azure to claim credits (or go directly to [Claiming Your Credits](https://nonprofit.microsoft.com/en-us/offers/azure).
14 14 Jon Goldberg
* You'll know your successful because you'll see a sponsorship listed on the [Sponsorship Page](https://www.microsoftazuresponsorships.com/Balance).
15 6 Jon Goldberg
16
### Create a Subscription
17
18 1 Jon Goldberg
* Check that you have credits in your sponsored account: https://www.microsoftazuresponsorships.com/Balance
19
* Visit the [Azure Portal](https://portal.azure.com).  
20
* Click the **Subscriptions** icon.
21
* Click the **Add** button.
22
* Add a subscription of type "Microsoft Azure Sponsorship" from the Azure portal. You will likely need to select **Show other subscription types** to see it.
23
 * **Note**: Even sponsored subscriptions require a credit card, make sure you have one available.
24
25 22 Jon Goldberg
### Grant access to other users
26
Microsoft is now enforcing two-factor authentication, so you need to create a separate user for me as your web vendor.
27
[Source](https://docs.microsoft.com/en-us/azure/cost-management-billing/manage/add-change-subscription-administrator) for instructions
28
* Open the new subscription (by clicking on it from the **Subscriptions** page.
29
* Click **Access Control (IAM)** in the left navigation bar.
30
* Under *Grant access to this resource*, click **Add role assignments**.
31
* *Role* should be **Owner**.  In *Search by name or email address*, put the email of the new user and press **Save**.
32
At this point, they'll receive an email to either log in with an existing Microsoft account or to create a new one.
33
34 16 Jon Goldberg
## Technical Configuration
35
To set up a free account, you must:
36
* Get a Sponsorship (see above)
37
* Create a Subscription linked to the Sponsorship (see above)
38
* (Strongly recommended) Grant access to the subscription to other users.
39
* Create a Resource Group linked to the Subscription
40
* Create a Virtual Machine (and associated resources) linked to the Resource Group
41 14 Jon Goldberg
42
### Create a resource group
43 6 Jon Goldberg
* Select "Resource Group" from the main Azure portal.  
44 23 Jon Goldberg
* Select **New** and give it a name.
45 1 Jon Goldberg
* Your subscription should be pre-selected since you only have the one.
46 23 Jon Goldberg
* Click **Review and Create**, then **Create**.
47 6 Jon Goldberg
48 1 Jon Goldberg
### Create a virtual machine
49 14 Jon Goldberg
* Click on your new resource group in the Azure Portal.
50 23 Jon Goldberg
* Click **Add » Marketplace**.
51
* Search for the name of the image you want (e.g. `Debian 10 "Buster"`).
52
 * If you picked an image that shows an hourly cost, it's probably the wrong one.
53
* See the screenshots below for configuration of the "Basics" and "Disk" tabs.  The other tabs I keep with the defaults.  My standard VPS type is now `D2as_v4`.
54 9 Jon Goldberg
* I've attached a downloaded template for this VM, which as of now I haven't used yet, not sure how it works.
55
56
![Create a VM - Basics Tab](https://hq.megaphonetech.com/attachments/download/1771/Selection_999(010).png)
57
58 15 Jon Goldberg
![Create a VM - Disks Tab](Selection_1016.png)
59 6 Jon Goldberg
60 14 Jon Goldberg
### Post-provisioning configuration
61 10 Jon Goldberg
62 14 Jon Goldberg
#### Partition and format the attached disk
63 10 Jon Goldberg
Your VM (if it's D2s v3) will have an "OS disk" of 30GB it ships with.  Your attached disk is unformatted.  Partition and format the new disk with:
64
65
```shell
66 18 Jon Goldberg
sudo parted --script -a optimal /dev/sdc mklabel gpt -- mkpart primary ext4 '0%' '100%'
67
sudo mkfs -t ext4 /dev/sdc1 
68 1 Jon Goldberg
```
69 18 Jon Goldberg
70
**NOTE** At different times, Azure may attach the disk as `/dev/sdb` or /dev/sdc`.  Use `fdisk -l` to determine the correct disk to work with.
71 17 Jon Goldberg
72 1 Jon Goldberg
#### Mount the attached disk
73 20 Jon Goldberg
```shell
74
# install lsof and rsync
75
sudo apt install lsof rsync
76 1 Jon Goldberg
# Ensure that no files are open in /var.
77
# This should come back empty:
78 20 Jon Goldberg
sudo lsof | grep /var
79
80 1 Jon Goldberg
sudo mount /dev/sdc1 /mnt
81 20 Jon Goldberg
sudo rsync -va /var/* /mnt
82 23 Jon Goldberg
sudo pkill waagent
83
sudo mv /var /var.old
84 1 Jon Goldberg
sudo umount /mnt
85 21 Jon Goldberg
sudo mkdir /var
86 20 Jon Goldberg
sudo mount /dev/sdc1 /var
87
vi /etc/fstab
88
```
89
Add the following line to `/etc/fstab`:
90
```
91 23 Jon Goldberg
/dev/sdc1       /var     ext4    defaults    0 1
92 20 Jon Goldberg
```
93 10 Jon Goldberg
94 14 Jon Goldberg
#### Modify Firewall Rules
95 6 Jon Goldberg
* Click on your new virtual machine in the Azure portal.
96
* Click **Networking** in the side navigation.
97
* You should see your firewall settings.  They should look like the screenshot below, except they'll be missing the two items circled.
98
* Add the "allow_ping" and "Port_5665" rules to the *Inbound Port Rules* as shown in the screenshot.
99
100 8 Jon Goldberg
![Firewall Rules](https://hq.megaphonetech.com/attachments/download/1772/Selection_999(012).png)
101
102 14 Jon Goldberg
#### Add a swapfile
103 6 Jon Goldberg
[Complete instructions are here](https://support.microsoft.com/en-us/help/4010058/how-to-add-a-swap-file-in-linux-azure-virtual-machines) but in short, add this to `/etc/waagent.conf` for an 8GB swapfile:
104
105
```
106
    ResourceDisk.Format=y
107
    ResourceDisk.EnableSwap=y
108
    ResourceDisk.SwapSizeMB=8192
109
```
110
111
Then run `service walinuxagent restart`.