I looked at this in the portal and it is quite simple. First go through the list and click Add Mask for all of them. Note that the only thing that happens here is that columns are moved to the upper part of the screen. Nothing is saved until you press the Save icon (which you should not.)
One you have done this, place the cursor to the upper left of the table and select all lines. Copy and paste into Excel. Once you are in Excel there are multiple ways to go. What I did was to save the data has a UTF-8 csv file.
Then I created this table:
CREATE TABLE guest.MaskingRecommendations(schema_name sysname NOT NULL,
table_name sysname NOT NULL,
colum_name sysname NOT NULL,
mask nvarchar(200) NOT NULL)
I used the guest schema to separate it from other table, but you can do as you like.
Then I loaded the file with BCP:
bcp guest.MaskingRecommendations in MaskingRules.csv -c -t; -C 65001 -S MyServer.databases.windows.net -d MyDatabase -U MyLogin -P MyPassword
My separator is semicolon, since that is the European standard. Yours may be comma.
On first attempt it failed with a NOT NULL error, because there were blank lines in the Excel file which resulted in lines with only semicolons. I used a text editor to remove these lines, and I was able to load the table.
I'm uncertain about the mask field. I appears that it only says Default value (0, xxxx, 01-01-1900)
, but maybe that is my database.
You could use the table to generate the ALTER TABLE ALTER COLUMN commands.
You may also prefer to stay in Excel to make a manual review of which columns to mask and how to mask them, and only when you are done load it into the database.
.