You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
- Upload the .cer file to your subscription [here][https://manage.windowsazure.com/]
20
-
- Upload the .pfx file to the certificates under Assets in the automation account that you want to use on Azure. You will use the password you gave in the previous step to authenticate it.
21
-
2. Create new a new credentials asset to authenticate your server with.
22
-
- Under assets, click on Credentials, and then click on Add a credential.
23
-
- Name the credential and give the username and password that you will be logging into the server with.
24
-
3. Create a new variable asset to pass the storage key of the Azure storage account you will be using.
25
-
- Under assets, click on variables and then Add a variable.
26
-
- Give the value of the storage key and you can make it encrypted so that only Azure Automation can read the variable and it won't show the key in plaintext if someone looks at the variable.
27
-
4. Set Up Log Analytics (OMS) and Alerts
28
-
- If you don't have Log Analytics set up on your Azure account, follow [these][https://azure.microsoft.com/en-us/documentation/articles/automation-manage-send-joblogs-log-analytics/] instructions for setting it up.
11
+
## Prerequisite Set Up
12
+
13
+
1. Create and set up your Azure Automation Account
14
+
- Create an Azure Automation Account by [following the instructions here](https://docs.microsoft.com/en-us/azure/automation/automation-sec-configure-azure-runas-account).
15
+
2. Add Azure Automation Credential assets for your SQL Azure servers
16
+
- Create your Automation Credential for each of your SQL Azure servers you intend to export by [following the instructions here](https://docs.microsoft.com/en-us/azure/automation/automation-credentials#creating-a-new-credential-asset).
17
+
3. Create the Azure Storage Account to hold your bacpac files
18
+
- Create the Storage Account by [following the instructions here](https://docs.microsoft.com/en-us/azure/storage/storage-create-storage-account#create-a-storage-account).
19
+
- Create the Blob Storage Container
20
+
- Go to your Storage Account
21
+
- Click the Blobs tile
22
+
- Click the Add Container button
23
+
- Name the container, keep the access type as Private, and click the Create button
24
+
- Copy your Storage Account access keys by [following the instructions here](https://docs.microsoft.com/en-us/azure/storage/storage-create-storage-account#view-and-copy-storage-access-keys).
25
+
- Create an Azure Automation string Variable asset for your Storage Account access key by [following the instructions here](https://docs.microsoft.com/en-us/azure/automation/automation-variables#creating-an-automation-variable).
26
+
4. Set Up Log Analytics (OMS) and Alerts (optional for alerting)
27
+
- If you don't have Log Analytics set up on your Azure account, [follow these](https://docs.microsoft.com/en-us/azure/automation/automation-manage-send-joblogs-log-analytics) instructions for setting it up.
29
28
5. Set Up Log Analytics Alerts
30
29
- To send yourself an email if an error occurs or one of the jobs fails, you need to set up alerts.
31
30
- Select your log analytics account that you want to use in the azure portal and click on the OMS Portal box under Management.
@@ -36,18 +35,33 @@ Provides the scripts and lists the steps to set up automatically exporting your
36
35
37
36
## Script Set Up
38
37
38
+
Save the AutoExport.ps1 and AutoExportBlobRetention.ps1 files locally to make these edits
39
+
39
40
1. In the AutoExport.ps1 script, here are the values that need to be modified:
40
-
- $databaseServerPairs: This is where you put in the names of the databases you want to export along with the name of the server they are on.
41
-
- $serverCredentialsDictionary: If you are backing up from multiple servers, you can setup all of the credentials here and look them up by the server’s name later.
42
-
- $batchingLimit: This tells the script how many databases can be worked on at the same time (basically, the maximum number of database copies that there will be at once).
43
-
- $retryLimit: This tells the script how many times it can retry an operation.
44
-
- $waitTimeInMinutes: This tells the script how long it can wait for an operation to complete before it fails.
45
-
- $storageKeyVariableName: This is the AutomationAccount you created the StorageKey variable under (probably the same one you are running the RunBook under) and -Name is the name of the variable.
46
-
- $storageAccountName: This is the name of the storage account you are exporting to.
47
-
- $automationCertificateName for Get-AutomationCertificate: This is the name of the certificate you setup to authenticate with Azure.
48
-
- $subId: The ID of the subscription you are using. This will be used to tell Azure Automation which subscription to use.
49
-
- $subName: The name of the subscription you are using. This will be used to tell Azure Automation which subscription to use.
41
+
- **$databaseServerPairs:** This is where you put in the names of the databases you want to export along with the name of the server they are on.
42
+
Add them in the format: `[pscustomobject]@{serverName="SAMPLESERVER1";databaseName="SAMPLEDATABASE1"}` make sure to comma separate the items
43
+
- **$serverCredentialsDictionary:** If you are backing up from multiple servers, you can setup all of the credentials here and look them up by the server’s name later.
44
+
Add a $serverCred variable in the format `$serverCred1 = Get-AutomationPSCredential -Name 'NAMEOFSERVERCREDENTIAL1';` for each Azure Automation Credential you created. Increment the variable name (eg. $serverCred2 $serverCred3) for each one.
45
+
Add the $serverCreds to the dictionary in the format `'SAMPLESERVERNAME1'=$serverCred1;`
46
+
- **$batchingLimit:** This tells the script how many databases can be worked on at the same time (basically, the maximum number of database copies that there will be at once).
47
+
- **$retryLimit:** This tells the script how many times it can retry an operation.
48
+
- **$waitTimeInMinutes:** This tells the script how long it can wait for an operation to complete before it fails.
49
+
- **$storageKeyVariableName:** This is the Azure Automation string Variable name you created to store your Storage Key.
50
+
- **$storageAccountName:** This is the name of the storage account you are exporting to.
51
+
- **$connectionAssetName:** Connection Asset Name for Authenticating (Keep as AzureClassicRunAsConnection if you created the default RunAs accounts)
50
52
2. In AutoExportBlobRetention, here are the values that need to be modified:
51
-
- -Name for Get-AzureAutomationVariable: This is the AutomationAccount you created the StorageKey variable under (probably the same one you are running the RunBook under) and -Name is the name of the variable.
52
-
- $storageContainer: This is the name of the storage container where you will be monitoring the exported blobs.
53
-
- $retentionInDays: This is how many days you want to keep the exported blobs stored for before deleting.
53
+
- **$storageKeyVariableName:** This is the Azure Automation string Variable name you created to store your Storage Key.
54
+
- **$storageAccountName:** This is the name of your Storage Account you exported your bacpacs to.
55
+
- **$storageContainerName:** This is the name of the storage container where you will be monitoring the exported blobs.
56
+
- **retentionInDays:** This is how many days you want to keep the exported blobs stored for before deleting.
57
+
58
+
## Adding the Script to Azure Automation
59
+
60
+
1. Import the scripts as Azure Automation Runbooks
61
+
- Create runbooks from the scripts you editted above by [following the instructions here](https://docs.microsoft.com/en-us/azure/automation/automation-creating-importing-runbook#to-import-a-runbook-from-a-file-with-the-azure-portal) for both scripts.
62
+
- [Make sure to publish the runbook.](https://docs.microsoft.com/en-us/azure/automation/automation-creating-importing-runbook#to-publish-a-runbook-using-the-azure-portal)
63
+
2. Add a schedule for your Automated Export runbook
64
+
- Create a recurring schedule by [following the instructions here](https://docs.microsoft.com/en-us/azure/automation/automation-schedules#to-create-a-new-schedule-in-the-azure-portal).
65
+
- Link the schedule(s) you created to the runbooks by [following the instructions here](https://docs.microsoft.com/en-us/azure/automation/automation-schedules#to-link-a-schedule-to-a-runbook-with-the-azure-portal).
66
+
67
+
You should now be all set up for Automated Exports into blob storage of your selected SQL Azure databases.
0 commit comments