Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow deployment slot settings #862

Draft
wants to merge 107 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
107 commits
Select commit Hold shift + click to select a range
f1ae6f1
Add support for ip-restrictions for webApp/Functions.
viktorvan Dec 5, 2021
b78a545
allow slot_settings
nargiz Dec 9, 2021
f529e22
update slotSettingNames to be set
nargiz Dec 10, 2021
849db95
Add support for multiple custom domains
r30e Jan 21, 2022
106596d
Use domainName as certificate name
r30e Jan 21, 2022
de2b2e8
update docs + release notes
r30e Jan 21, 2022
edc6aae
Only turn on "auto" extension for Windows
isaacabraham Jan 23, 2022
48626d1
Release notes
isaacabraham Jan 23, 2022
8b9f7d9
Merge remote-tracking branch 'origin/master' into fix-linux-extension
isaacabraham Jan 23, 2022
de2fb64
Expanded description of custom_domain operator
r30e Jan 24, 2022
3a882b7
Merge pull request #867 from CompositionalIT/fix-linux-extension
isaacabraham Jan 25, 2022
7c8fcfc
Fix host name binding error when deploying multiple custom domains
Jan 28, 2022
6c136c2
Add support for custom docker port for web apps
stevebelskie Jan 30, 2022
aa9c093
Update web app documentation for docker_port
stevebelskie Jan 30, 2022
47f8b38
Fix typo in App Setting (WEBSITE_PORT -> WEBSITES_PORT)
stevebelskie Jan 30, 2022
8518bb5
Make connection_string and connections_strings available for azure fu…
amine-mejaouel Feb 6, 2022
87a72a1
Add connection string docs for Azure Functions
amine-mejaouel Feb 6, 2022
934eaaf
ZoneRedundant for service plan
nargiz Feb 11, 2022
f9de8d4
more test cases for service plan
nargiz Feb 11, 2022
5dab8e7
Tiny cleanup
isaacabraham Feb 11, 2022
63673cd
Merge pull request #870 from stevebelskie/master
isaacabraham Feb 11, 2022
db67331
Fix release notes
isaacabraham Feb 11, 2022
04d33a8
Merge branch 'master' of github.com:CompositionalIT/farmer into add-i…
ninjarobot Feb 13, 2022
41864e0
Support for CIDR network blocks on WebApp IP address restrictions
ninjarobot Feb 13, 2022
561d3b7
Appending webapp restriction rules to end of list
ninjarobot Feb 14, 2022
31ff0ca
Update RELEASE_NOTES.md
ninjarobot Feb 14, 2022
c3515dc
Clean up 1.6.26 release notes entries.
ninjarobot Feb 14, 2022
e5e4e70
Merge branch 'master' into azurefunction-connectionstrings
ninjarobot Feb 14, 2022
3d0f1eb
Moving to correct version in release notes
ninjarobot Feb 14, 2022
cf09dfd
Merge branch 'master' of github.com:CompositionalIT/farmer into add-i…
ninjarobot Feb 14, 2022
774e2d4
Merge branch 'master' into comItZoneRedundant
nargiz Feb 14, 2022
2168606
use FeatureFlag for ZoneRedundant
nargiz Feb 14, 2022
04bc033
update docs
nargiz Feb 14, 2022
e5943be
Merge pull request #835 from viktorvan/add-iprestrictions
ninjarobot Feb 15, 2022
672ca19
Merge branch 'master' into azurefunction-connectionstrings
ninjarobot Feb 16, 2022
f773c44
Merge pull request #874 from amine-mejaouel/azurefunction-connections…
ninjarobot Feb 16, 2022
d23098f
Update RELEASE_NOTES for version 1.6.27
ninjarobot Feb 16, 2022
7b0610b
1.6.27 release updates
ninjarobot Feb 16, 2022
a619428
Bundle LICENSE and README in nuget
ninjarobot Feb 16, 2022
97fec9a
Merged from master
r30e Feb 16, 2022
ec78c6a
Merge pull request #866 from codatio/multiple-custom-domains
ninjarobot Feb 16, 2022
868787b
Cleanup release notes for 1.6.27 release
ninjarobot Feb 16, 2022
07e5284
Re-applied changes following pull from remote farmer master.
michaelwade-c5 Feb 2, 2022
8403226
Removed un-intended change
michaelwade-c5 Feb 17, 2022
c676c74
Removed un-intended change 2
michaelwade-c5 Feb 17, 2022
1647db4
Merge branch 'master' into comItZoneRedundant
nargiz Feb 21, 2022
5a8c297
Merge pull request #876 from nargiz/comItZoneRedundant
ninjarobot Mar 1, 2022
6e80b44
1.6.28 release
ninjarobot Mar 1, 2022
c554b65
Allow adding an IP with CIDR as a string to a web app
theprash Mar 4, 2022
696806e
Use --only-show-errors - fixes #884
forki Mar 7, 2022
9afadfb
fix core and memory
tforkmann Mar 7, 2022
bbb7d87
add hint to turn on ressource provider
tforkmann Mar 7, 2022
8c8b484
Merge pull request #885 from forki/master
isaacabraham Mar 7, 2022
2de2c8b
Merge pull request #886 from tforkmann/fix-containerapp-script
isaacabraham Mar 7, 2022
dcd0910
Merge pull request #887 from tforkmann/hint-resource-provider
isaacabraham Mar 7, 2022
004ef55
Merge pull request #880 from ninjarobot/nuget-updates
isaacabraham Mar 7, 2022
0ae6dea
1.6.29 release
ninjarobot Mar 7, 2022
a06cae7
Added support for WebApp vnet integration
r30e Mar 9, 2022
062fb5c
Added tests
r30e Mar 9, 2022
b60cc2a
docs
r30e Mar 9, 2022
ccc6404
merge
r30e Mar 9, 2022
2099a5d
cleanup
r30e Mar 9, 2022
1aa19ef
Merge branch 'master' into ip-cidr-as-string
theprash Mar 11, 2022
3e2592b
IP with CIDR: Add test and release notes
theprash Mar 11, 2022
5cb9a58
Merge pull request #883 from CompositionalIT/ip-cidr-as-string
isaacabraham Mar 11, 2022
3bd6686
App Insights now supports Log Analytics
isaacabraham Mar 12, 2022
4754169
add VM Priority and Spot Instance
bigjonroberts Mar 12, 2022
8d2053b
update tests for vm prioirity
bigjonroberts Mar 12, 2022
6fea7c3
add documentation for vm priority and spot instance
bigjonroberts Mar 12, 2022
de90ac8
add sample for vm spot instance
bigjonroberts Mar 12, 2022
c45f736
Update release notes to include VM Priority and Spot Instance
bigjonroberts Mar 12, 2022
1363c91
update release notes to 1.6.31 correctly
bigjonroberts Mar 12, 2022
540a71e
cleanup comments
bigjonroberts Mar 12, 2022
019a1ee
Add docs & samples.
isaacabraham Mar 13, 2022
522b3cf
Small rename
isaacabraham Mar 13, 2022
9dcf395
Merge remote-tracking branch 'origin/master' into feature/871-connect…
michaelwade-c5 Mar 14, 2022
42c2da0
Merge pull request #872 from mike-wade/feature/871-connection-string-…
isaacabraham Mar 14, 2022
78233b3
Merge branch 'master' into vm-spot-instance
bigjonroberts Mar 14, 2022
a9f32a4
Fix test
isaacabraham Mar 14, 2022
6578a0f
rename route_via_vnet -> vnet
r30e Mar 15, 2022
6407710
Added validation
r30e Mar 15, 2022
9fce32a
merged from master
r30e Mar 15, 2022
f9d8cd8
Updated release notes
r30e Mar 15, 2022
77c2b5b
Update release notes and simplify tests.
isaacabraham Mar 15, 2022
68a0fc1
Merge remote-tracking branch 'origin/master' into ai-workspaces
isaacabraham Mar 15, 2022
7e281ce
Merge pull request #895 from CompositionalIT/ai-workspaces
isaacabraham Mar 15, 2022
d8cf05e
Merge branch 'master' into vm-spot-instance
bigjonroberts Mar 16, 2022
9058d23
only allow one spot_instance or prioirity setting in VM
bigjonroberts Mar 17, 2022
cef4e04
correct some text on tests
bigjonroberts Mar 17, 2022
c9bc1c8
Add docs about what spot_instance actually does.
bigjonroberts Mar 17, 2022
c680a99
Update release notes changes to match tag on PR
bigjonroberts Mar 17, 2022
19a03d0
Merge pull request #894 from bigjonroberts/vm-spot-instance
ninjarobot Mar 17, 2022
bcdf853
1.6.30 release
ninjarobot Mar 17, 2022
7917662
update to resemble to vm builder instead of AKS builder
r30e Mar 18, 2022
65b614c
merge
r30e Mar 18, 2022
b012a44
- update docs
r30e Mar 18, 2022
fd24ceb
Add validation for functions
r30e Mar 18, 2022
3ac3498
AzureFirewall supports AvailabilityZones
Mar 22, 2022
e8ae29e
Release notes
Mar 22, 2022
5f3ada6
Fix test failure due to increased validation
r30e Mar 22, 2022
5e34581
Adds JSON selection test for zonal AzFirewall
ninjarobot Mar 22, 2022
bf094e5
Merge pull request #888 from codatio/vnet-integration
ninjarobot Mar 22, 2022
5737fc1
fix resource id for resource group config
Mar 21, 2022
6a4233d
Merge branch 'master' into ersoler/multiaz-firewall
ericsoler1 Mar 22, 2022
1d4eeb6
Merge pull request #900 from ericsoler1/ersoler/multiaz-firewall
ninjarobot Mar 22, 2022
a2eed20
merge with latest
nargiz Mar 23, 2022
a2bce2c
improvements for slot settings
nargiz Mar 24, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Farmer.sln
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "scripts", "scripts", "{C399
samples\scripts\storage.fsx = samples\scripts\storage.fsx
samples\scripts\template.json = samples\scripts\template.json
samples\scripts\vm.fsx = samples\scripts\vm.fsx
samples\scripts\vm-spot-instance.fsx = samples\scripts\vm-spot-instance.fsx
samples\scripts\vnet-gateway.fsx = samples\scripts\vnet-gateway.fsx
samples\scripts\vnet-hub-and-spoke.fsx = samples\scripts\vnet-hub-and-spoke.fsx
samples\scripts\vnet.fsx = samples\scripts\vnet.fsx
Expand Down
28 changes: 27 additions & 1 deletion RELEASE_NOTES.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,33 @@
Release Notes
=============
## vNext
* WebApp/Functions: Support for deployment slot settings with `slot_setting` and `slot_settings`

## 1.6.31
* AzureFirewall: Supports availability zones
* WebApps/Functions: Add support for vnet integration

## 1.6.30
* WebApps/Functions: Specify connection string types
* WebApps/Functions: Allow adding IP restriction string with CIDR
* Application Insights: Support for Workspace-enabled instances.
* VMs: Priority and Spot Instance Settings

## 1.6.29
* CLI: include `--only-show-error` option when executing Azure CLI commands.

## 1.6.28
* ServicePlan/WebApp: Support for enabling ZoneRedundant

## 1.6.27
* Functions: Make `connection_string` available for Azure Functions in addition to WebApps.
* WebApps/Functions: Add support for ip-restriction rules
* WebApps/Functions: Don't turn on Logging Extension for Linux App Service.
* WebApps: Allow multiple custom domains
* WebApps: Support custom port for docker container with `docker_port`

## 1.6.26
* WebApp/Functions: Fix .NET on Linux deployments
* WebApps/Functions: Fix .NET 5/6 on Linux deployments.

## 1.6.25
* CosmosDb: Add support for serverless capacity mode.
Expand Down
4 changes: 4 additions & 0 deletions docs/content/api-overview/resources/app-insights.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,16 @@ The App Insights builder is used to create Application Insights accounts. Use th

* Application Insights (`Microsoft.Insights/components`)

> This builder supports both "Classic" (standalone) and "Workspace Enabled" (Log Analytics-backed) instances of App Insights. See the `log_analytics_workspace` keyword to see how to create the latter type of instance.

#### Builder Keywords

| Keyword | Purpose |
|-|-|
| name | Sets the name of the App Insights instance. |
| disable_ip_masking | Disable IP masking. |
| sampling_percentage | Define sampling percentage (0-100) |
| log_analytics_workspace | Use a Log Analytics workspace as the backing store for this AI instance. You can supply either a Farmer-generate Log Analytics`WorkspaceConfig` instance that exists in the same resource group, or a fully-qualified Resource ID path to that instance. This will also switch the AI instance over to creating a "workspace enabled" AI instance. |

#### Configuration Members

Expand All @@ -32,5 +35,6 @@ open Farmer.Builders

let ai = appInsights {
name "myAI"
log_analytics_workspace myWorkspace // use to activate workspace-enabled AI instances.
}
```
5 changes: 5 additions & 0 deletions docs/content/api-overview/resources/container-apps.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@ The Container Apps builder is used to create Azure Container Apps.
* Container Environment (`Microsoft.Web/kubeEnvironments`)
* Container App (`Microsoft.Web/containerApps`)

### Turn on Resource Provider
Before you deploy your container app, you need to turn on the Container Apps resource provider in your Azure subscription.

Get sure you have the following providers registered: `Microsoft.Kubernetes` and `Microsoft.ContainerService`.

#### Container Environment Builder
The Container Environment builder (`containerEnvironment`) defines settings for the Kubernetes envirionment that hosts the container apps.

Expand Down
9 changes: 8 additions & 1 deletion docs/content/api-overview/resources/functions.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ The Functions builder is used to create Azure Functions accounts. It abstracts t
| setting | Sets an app setting of the web app in the form "key" "value". |
| secret_setting | Sets a "secret" app setting of the function. You must supply the "key", whilst the value will be supplied as a secure parameter or an ARM expression. |
| settings | Sets a list of app setting of the web app as tuples in the form of ("key", "value"). |
| connection_string | Creates a connection string whose value is supplied as secret parameter, or as an ARM expression in the tupled form of ("key", expr). |
| connection_strings | Creates a set of connection strings whose values will be supplied as secret parameters. |
| depends_on | [Sets dependencies for the web app.](../../dependencies/) |
| enable_cors | Enables CORS support for the app. Either specify AllOrigins or a list of valid URIs. |
| enable_cors_credentials | Allows CORS requests with credentials. |
Expand All @@ -45,8 +47,13 @@ The Functions builder is used to create Azure Functions accounts. It abstracts t
| publish_as | Specifies whether to publish function as code or as a docker container. |
| add_slot | Adds a deployment slot to the app |
| add_slots | Adds multiple deployment slots to the app |
| slot_setting | Sets a deployment slot setting of the function in the form "key" "value". |
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder whether it's possible to piggy back on the existing setting keywords? Also, there's also the secret_setting keyword for adding secure settings - this should probably be migrated as well if we keep with separate keywords.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How does this really differ from including config when adding a slot with add_slot and using the SlotBuilder with addSlot? I see this PR adds slotconfignames when you add these - is the purpose of this just for sticky config?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To make settings sticky, their names should be specified in webapp(sites) child resource, slotconfignames. We usually add settings in webapp, so the idea was to have slot_setting which adds the setting and creates child resource slotconfignames.

The alternative solution was something similar to this:

let myWebApp = webApp {
    name "test"
    add_slot deploymentSlot

    settings ["my_setting", "test value"
                  "my_slot_setting", "sticky value"]

    slot_setting_names ["my_slot_setting" ]
}

Where slot_setting_names was only marking the settings as sticky by adding slotconfignames, But we thought the current solution with slot_setting will make things clearer.

| slot_settings | Sets a list of deployment slot setting of the function as tuples in the form of ("key", "value"). |
| health_check_path | Sets the path to your functions health check endpoint, which Azure load balancers will ping to determine which instances are healthy.|

| add_allowed_ip_restriction | Adds an 'allow' rule for an ip |
| add_denied_ip_restriction | Adds an 'deny' rule for an ip |
| link_to_vnet | Enable the VNET integration feature in azure where all outbound traffic from the function with be sent via the specified subnet. Use this operator when the given VNET is in the same deployment |
| link_to_unmanaged_vnet | Enable the VNET integration feature in azure where all outbound traffic from the function with be sent via the specified subnet. Use this operator when the given VNET is *not* in the same deployment |
#### Post-deployment Builder Keywords
The Functions builder contains special commands that are executed *after* the ARM deployment is completed.

Expand Down
4 changes: 3 additions & 1 deletion docs/content/api-overview/resources/virtual-machine.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
title: "Virtual Machine"
date: 2020-02-05T08:53:46+01:00
date: 2022-03-17T09:33:27+05:00
chapter: false
weight: 21
---
Expand All @@ -24,6 +24,8 @@ In addition, every VM you create will add a SecureString parameter to the ARM te
|diagnostics_support|Turns on diagnostics support using an automatically created created storage account.|
|diagnostics_support_external|Turns on diagnostics support using an existing storage account.|
|vm_size|Sets the size of the VM.|
|priority|Sets the VM Priority. Only one `spot_instance` or `priority` setting is allowed per VM.|
|spot_instance|Makes the VM a spot instance. Shorthand for `priority (Spot (<EvictionPolicy>, <maxPrice>)`. Only one `spot_instance` or `priority` setting is allowed per VM.|
|username|Sets the admin username of the VM (note: the password is supplied as a securestring parameter to the generated ARM template).|
|password_parameter|Sets the name of the parameter which contains the admin password for this VM. defaults to "password-for-<VM-name>"|
|operating_system|Sets the operating system of the VM. A set of samples is provided in the `CommonImages` module.|
Expand Down
12 changes: 10 additions & 2 deletions docs/content/api-overview/resources/web-app.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ The Web App builder is used to create Azure App Service accounts. It abstracts t
| Web App | setting | Sets an app setting of the web app in the form "key" "value". |
| Web App | secret_setting | Sets a "secret" app setting of the web app. You must supply the "key", whilst the value will be supplied as a secure parameter. |
| Web App | settings | Sets a list of app setting of the web app as tuples in the form of ("key", "value"). |
| Web App | connection_string | Creates a connection string whose value is supplied as secret parameter, or as an ARM expression in the tupled form of ("key", expr). |
| Web App | connection_string | Creates a connection string whose value is supplied as secret parameter, or as an ARM expression in the tupled form of ("key", expr), or with the connection string type ("key", expr, SQLAzure). |
| Web App | connection_strings | Creates a set of connection strings of the web app whose values will be supplied as secret parameters. |
| Web App | ftp_state | Allows to enable or disable FTP and FTPS. |
| Web App | https_only | Disables http for this webapp so that only HTTPS is used. |
Expand All @@ -55,14 +55,22 @@ The Web App builder is used to create Azure App Service accounts. It abstracts t
| Web App | add_private_endpoints | Adds private endpoints for this Webapp to the given subnets |
| Web App | add_slot | Adds a deployment slot to the app |
| Web App | add_slots | Adds multiple deployment slots to the app |
| Web App | add_slot_setting | Sets a deployment slot setting of the web app in the form "key" "value". |
| Web App | add_slot_settings | Sets a list of deployment slot setting of the web app as tuples in the form of ("key", "value"). |
| Web App | health_check_path | Sets the path to your functions health check endpoint, which Azure load balancers will ping to determine which instances are healthy.|
| Web App | custom_domain | Adds custom domain to the app, containing an app service managed certificate |
| Web App | custom_domain | Adds a custom domain to the app. By default this will produce an AppService-managed SSL certificate for your domain as well. Through the overloads of this operator, you can provide a custom certificate thumbprint or choose not to use SSL. You can use this operator multiple times to add multiple custom domains. |
| Web App | add_allowed_ip_restriction | Adds an 'allow' rule for an ip |
| Web App | add_denied_ip_restriction | Adds an 'deny' rule for an ip |
| Web App | docker_port | Adds `WEBSITES_PORT` setting to map custom docker port to app service port 80 |
| Web App | link_to_vnet | Enable the VNET integration feature in azure where all outbound traffic from the web app with be sent via the specified subnet. Use this operator when the given VNET is in the same deployment |
| Web App | link_to_unmanaged_vnet | Enable the VNET integration feature in azure where all outbound traffic from the web app with be sent via the specified subnet. Use this operator when the given VNET is *not* in the same deployment |
| Service Plan | service_plan_name | Sets the name of the service plan. If not set, uses the name of the web app postfixed with "-plan". |
| Service Plan | runtime_stack | Sets the runtime stack. |
| Service Plan | operating_system | Sets the operating system. If Linux, App Insights configuration settings will be omitted as they are not supported by Azure App Service. |
| Service Plan | sku | Sets the sku of the service plan. |
| Service Plan | worker_size | Sets the size of the service plan worker. |
| Service Plan | number_of_workers | Sets the number of instances on the service plan. |
| Service Plan | zone_redundant | Enables ZoneRedundant on the service plan. |

> **Farmer also comes with a dedicated Service Plan builder** that contains all of the above keywords that apply to a Service Plan.
>
Expand Down
26 changes: 26 additions & 0 deletions samples/scripts/appinsights-loganalytics.fsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#r @"nuget:Farmer"

open Farmer
open Farmer.Builders

let workspace = logAnalytics {
name "loganalytics-workspace"
}

let myAppInsights = appInsights {
name "appInsights"
log_analytics_workspace workspace
}

let myFunctions = functions {
name "functions-app"
link_to_app_insights myAppInsights.Name
}

let template = arm {
location Location.NorthEurope
add_resources [ workspace; myAppInsights; myFunctions ]
}

template
|> Deploy.execute "deleteme" Deploy.NoParameters
4 changes: 2 additions & 2 deletions samples/scripts/container-app.fsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ let env =
container {
name "queuereaderapp"
public_docker_image "mcr.microsoft.com/azuredocs/containerapps-queuereader" ""
cpu_cores 1.0<VCores>
memory 1.0<Gb>
cpu_cores 0.25<VCores>
memory 0.5<Gb>
}
]
replicas 1 10
Expand Down
26 changes: 26 additions & 0 deletions samples/scripts/vm-spot-instance.fsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#r "nuget:Farmer"

open Farmer
open Farmer.Builders
open Farmer.Vm

let myVm = vm {
name "isaacsVM"
username "isaac"
spot_instance Deallocate
vm_size Standard_A2
operating_system WindowsServer_2012Datacenter
os_disk 128 StandardSSD_LRS
add_ssd_disk 128
add_slow_disk 512
diagnostics_support
system_identity
}

let deployment = arm {
location Location.NorthEurope
add_resource myVm
}

deployment
|> Deploy.execute "my-resource-group-name" Deploy.NoParameters
2 changes: 2 additions & 0 deletions samples/scripts/webapp-storage.fsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ let myWebApp = webApp {
sku WebApp.Sku.S1
app_insights_off
setting "storage_key" myStorage.Key
add_allowed_ip_restriction "allow everything" "0.0.0.0/0"
add_denied_ip_restriction "deny" "1.2.3.4/31"
}

let deployment = arm {
Expand Down
15 changes: 15 additions & 0 deletions src/Farmer/Aliases.fs
Original file line number Diff line number Diff line change
@@ -1,4 +1,19 @@
[<AutoOpen>]
module Farmer.Aliases

[<AutoOpen>]
module BuilderExtensions =
open Farmer.Builders
open Farmer.Arm.Network
type IPrivateEndpoints<'TConfig> with
member this.AddPrivateEndpoint(state:'TConfig, subnetId:LinkedResource) = this.AddPrivateEndpoint (state, SubnetReference.create subnetId)
member this.AddPrivateEndpoint(state:'TConfig, subnet:SubnetConfig) = this.AddPrivateEndpoint (state, SubnetReference.create subnet)
member this.AddPrivateEndpoint(state, (subnetRef:LinkedResource,epName)) = this.AddPrivateEndpoint (state, (SubnetReference.create subnetRef, epName))
member this.AddPrivateEndpoint(state:'TConfig, (vnetRef, subnetName):LinkedResource * ResourceName) = this.AddPrivateEndpoint (state, SubnetReference.create (vnetRef,subnetName))
member this.AddPrivateEndpoint(state, (vnetRef,subnetName,epName):LinkedResource * ResourceName * string) = this.AddPrivateEndpoint (state, ((SubnetReference.create (vnetRef, subnetName)), epName))
member this.AddPrivateEndpoint(state:'TConfig, (vnet, subnetName):VirtualNetworkConfig * ResourceName) = this.AddPrivateEndpoint (state, SubnetReference.create (vnet,subnetName))

member this.AddPrivateEndpoints(state:'TConfig, subnetIds:LinkedResource list) = this.AddPrivateEndpoints (state, subnetIds |> List.map SubnetReference.create |> Set)
member this.AddPrivateEndpoints(state:'TConfig, subnets:SubnetConfig list) = this.AddPrivateEndpoints (state, subnets |> List.map SubnetReference.create |> Set)

let arm = Farmer.Builders.ResourceGroup.DeploymentBuilder ()
2 changes: 2 additions & 0 deletions src/Farmer/Arm/AzureFirewall.fs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ type AzureFirewall =
FirewallPolicy : ResourceId option
VirtualHub : ResourceId option
HubIPAddresses : HubIPAddresses option
AvailabilityZones : string list
Sku : Sku }
interface IArmResource with
member this.ResourceId = azureFirewalls.resourceId this.Name
Expand All @@ -50,5 +51,6 @@ type AzureFirewall =
virtualHub = this.VirtualHub |> Option.map (fun resId -> box {| id = resId.ArmExpression.Eval() |}) |> Option.defaultValue null
firewallPolicy = this.FirewallPolicy |> Option.map (fun resId -> box {| id = resId.ArmExpression.Eval() |}) |> Option.defaultValue null
hubIPAddresses = this.HubIPAddresses |> Option.map (fun x -> box x.JsonModel) |> Option.defaultValue null |}
zones = if this.AvailabilityZones.IsEmpty then null else this.AvailabilityZones |> box
|}

25 changes: 18 additions & 7 deletions src/Farmer/Arm/Compute.fs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ open Farmer.Vm
open System
open System.Text

let virtualMachines = ResourceType ("Microsoft.Compute/virtualMachines", "2018-10-01")
let virtualMachines = ResourceType ("Microsoft.Compute/virtualMachines", "2019-03-01")
let extensions = ResourceType ("Microsoft.Compute/virtualMachines/extensions", "2019-12-01")

type CustomScriptExtension =
Expand Down Expand Up @@ -70,6 +70,7 @@ type VirtualMachine =
Location : Location
StorageAccount : ResourceName option
Size : VMSize
Priority : Priority
Credentials : {| Username : string; Password : SecureParameter |}
CustomData : string option
DisablePasswordAuthentication: bool option
Expand All @@ -93,12 +94,9 @@ type VirtualMachine =
networkInterfaces.resourceId this.NetworkInterfaceName
yield! this.StorageAccount |> Option.mapList storageAccounts.resourceId
]
{| virtualMachines.Create(this.Name, this.Location, dependsOn, this.Tags) with
identity =
if this.Identity = ManagedIdentity.Empty then Unchecked.defaultof<_>
else this.Identity.ToArmJson
properties =
{| hardwareProfile = {| vmSize = this.Size.ArmValue |}
let properties =
{| priority = this.Priority.ArmValue
hardwareProfile = {| vmSize = this.Size.ArmValue |}
osProfile =
{| computerName = this.Name.Value
adminUsername = this.Credentials.Username
Expand Down Expand Up @@ -161,4 +159,17 @@ type VirtualMachine =
| None ->
box {| bootDiagnostics = {| enabled = false |} |}
|}

{| virtualMachines.Create(this.Name, this.Location, dependsOn, this.Tags) with
identity =
if this.Identity = ManagedIdentity.Empty then Unchecked.defaultof<_>
else this.Identity.ToArmJson
properties =
match this.Priority with
| Low | Regular -> box properties
| Spot (evictionPolicy, maxPrice) ->
{| properties with
evictionPolicy = evictionPolicy.ArmValue
billingProfile = {| maxPrice = maxPrice |}
|}
|}
Loading