-
Notifications
You must be signed in to change notification settings - Fork 162
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
SQL Azure - add support for AD admin #1047
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks again for your continued work on this. I made some recommendations to try to reduce the code complexity a bit. The compiler can deal with it, but it's getting a bit difficult to follow some of the logic for building the various auth settings records.
RELEASE_NOTES.md
Outdated
@@ -1,5 +1,8 @@ | |||
Release Notes | |||
============= | |||
## 1.7.26 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will be in the next release - 1.7.25
src/Farmer/Arm/Sql.fs
Outdated
| Some Tls12 -> "1.2" | ||
| None -> null | ||
|} | ||
let props = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All the logic here has grown in complexity beyond just building a record - now the record is built then copies are modified a couple of times. This is too much to do in the implementation of the properties
field, so if this level of complexity is needed, please move it to a separate function or a private member method.
src/Farmer/Builders/Builders.Sql.fs
Outdated
Password = this.AdministratorCredentials.Password | ||
|} | ||
match this.ActiveDirectoryAdmin with | ||
| Some (x) when x.AdOnlyAuth -> Unchecked.defaultof<_> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This particular check is in here many times so it would clarify the code to make this an active pattern. For example,
let (|ActiveDirAuth|AdOnlyAuth|StandardAuth|) activeDirAdmin =
match activeDirAdmin with
| Some x when x.AdOnlyAuth -> AdOnlyAuth
| Some x -> ActiveDirAuth
| None -> StandardAuth
and then the code expresses the intent without having to read through the options and boolean logic:
match this.ActiveDirectoryAdmin with
| ActiveDirAuth -> // whatever happens for AD auth
| AdOnlyAuth -> // whatever happens when it's AD only
| StandardAuth -> // whatever happens when not using AD auth (not sure if it's called standard, this was just an example)
@ninjarobot I have made further changes to hopefully simplify the code. Please do let me know if it can be made better. Thanks again. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great, thanks for simplifying the code a bit!
Maybe the wrong place to add this but I just tested this feature and found an issue when changing from an existing Azure AD admin to a new one. It seems like this is not supported in ARM/Bicep: |
Does it work in json, just not in bicep? Or is this impacted by the bug regardless? |
As far as I understand the comments on the issue, the Microsoft SQL team allows the value to be set but not changed via the ARM template that is generated in this PR:
It might be to complex for Farmer to handle this case but perhaps it should be mentioned in the documentation? |
This PR closes Azure/bicep#1036
The changes in this PR are as follows:
ActiveDirectoryAdminSettings
I have read the contributing guidelines and have completed the following:
Below is a minimal example configuration that includes the new features, which can be used to deploy to Azure:
Issues
I have found that ARM templates need modification to switch SQL server configuration among following -
Please refer this blog post - https://www.codez.one/azure-sql-with-managed-identities-part-2/
One possible way forward is to make
AdOnlyAuth
member optional and let the user write correct farmer template by detecting existence of SQL server out of band (using AZ cli or powershell etc)