Automate exporting of azure sql database as .bacpac to blog storage.

Published Jun 22 2021 07:37 AM 1,530 Views
Microsoft

Login to Azure Portal-->Go to automation account -->Runbooks-->browse gallery -->type backup azure sql databases to blob storage and import the module.

v-pekapa_0-1622648842657.png

  1. Open the run book and click edit.
    v-pekapa_1-1622649125019.png

    v-pekapa_2-1622649175619.png

     

  2. Download the code and replace the with your details as shown below:
    v-pekapa_3-1622649209874.png
    <#
    .OUTPUTS
    	Human-readable informational and error messages produced during the job. Not intended to be consumed by another runbook.
    
    #>
    
    
        $RESOURCEGROUPNAME = '<ResourceGroupName>'
        $DatabaseServerName = '<DatabaseName>'
        $DatabaseAdminUsername = '<AdminAccountHere>'
        $DatabaseAdminPassword = '<YourPasswordHere>'
        $DatabaseNames = '<DatabaseNaem>'
        $StorageAccountName = '<StorageAccountName>'
        $BlobStorageEndpoint = 'https://<StorageAccountName>.blob.core.windows.net/'
        $StorageKey = '<StorageAccessKey>'
        $BlobContainerName = '<ContainerName>'
        $RetentionDays = '10'
    
    
    $ErrorActionPreference = 'stop'
    
    function Login() {
    	$connectionName = "AzureRunAsConnection"
    	try
    	{
    		$servicePrincipalConnection = Get-AutomationConnection -Name $connectionName         
    
    		Write-Verbose "Logging in to Azure..." -Verbose
    
    		Add-AzureRmAccount `
    			-ServicePrincipal `
    			-TenantId $servicePrincipalConnection.TenantId `
    			-ApplicationId $servicePrincipalConnection.ApplicationId `
    			-CertificateThumbprint $servicePrincipalConnection.CertificateThumbprint | Out-Null
    	}
    	catch {
    		if (!$servicePrincipalConnection)
    		{
    			$ErrorMessage = "Connection $connectionName not found."
    			throw $ErrorMessage
    		} else{
    			Write-Error -Message $_.Exception
    			throw $_.Exception
    		}
    	}
    }
    
    function Create-Blob-Container([string]$blobContainerName, $storageContext) {
    	Write-Verbose "Checking if blob container '$blobContainerName' already exists" -Verbose
    	if (Get-AzureStorageContainer -ErrorAction "Stop" -Context $storageContext | Where-Object { $_.Name -eq $blobContainerName }) {
    		Write-Verbose "Container '$blobContainerName' already exists" -Verbose
    	} else {
    		New-AzureStorageContainer -ErrorAction "Stop" -Name $blobContainerName -Permission Off -Context $storageContext
    		Write-Verbose "Container '$blobContainerName' created" -Verbose
    	}
    }
    
    function Export-To-Blob-Storage([string] $RESOURCEGROUPNAME, [string]$databaseServerName, [string]$databaseAdminUsername, [string]$databaseAdminPassword, [string[]]$databaseNames, [string]$storageKey, [string]$blobStorageEndpoint, [string]$blobContainerName) {
    	Write-Verbose "Starting database export to databases '$databaseNames'" -Verbose
    	$securePassword = ConvertTo-SecureString –String $databaseAdminPassword –AsPlainText -Force 
    	$creds = New-Object –TypeName System.Management.Automation.PSCredential –ArgumentList $databaseAdminUsername, $securePassword
    
    	foreach ($databaseName in $databaseNames.Split(",").Trim()) {
    		Write-Output "Creating request to backup database '$databaseName'"
    
    		$bacpacFilename = $databaseName + (Get-Date).ToString("yyyyMMddHHmm") + ".bacpac"
    		$bacpacUri = $blobStorageEndpoint + $blobContainerName + "/" + $bacpacFilename
    		$exportRequest = New-AzureRmSqlDatabaseExport -ResourceGroupName $RESOURCEGROUPNAME –ServerName $databaseServerName `
    			–DatabaseName $databaseName –StorageKeytype "StorageAccessKey" –storageKey $storageKey -StorageUri $BacpacUri `
    			–AdministratorLogin $creds.UserName –AdministratorLoginPassword $creds.Password -ErrorAction "continue"
    		
    		# Print status of the export
    		Get-AzureRmSqlDatabaseImportExportStatus -OperationStatusLink $exportRequest.OperationStatusLink -ErrorAction "Stop"
    	}
    }
    
    function Delete-Old-Backups([int]$retentionDays, [string]$blobContainerName, $storageContext) {
    	Write-Output "Removing backups older than '$retentionDays' days from blob: '$blobContainerName'"
    	$isOldDate = [DateTime]::UtcNow.AddDays(-$retentionDays)
    	$blobs = Get-AzureStorageBlob -Container $blobContainerName -Context $storageContext
    	foreach ($blob in ($blobs | Where-Object { $_.LastModified.UtcDateTime -lt $isOldDate -and $_.BlobType -eq "BlockBlob" })) {
    		Write-Verbose ("Removing blob: " + $blob.Name) -Verbose
    		Remove-AzureStorageBlob -Blob $blob.Name -Container $blobContainerName -Context $storageContext
    	}
    }
    
    Write-Verbose "Starting database backup" -Verbose
    
    $StorageContext = New-AzureStorageContext -StorageAccountName $storageAccountName -StorageAccountKey $storageKey
    
    Login
    
    Create-Blob-Container `
    	-blobContainerName $blobContainerName `
    	-storageContext $storageContext
    	
    Export-To-Blob-Storage `
    	-resourceGroupName $RESOURCEGROUPNAME `
    	-databaseServerName $DatabaseServerName `
    	-databaseAdminUsername $DatabaseAdminUsername `
    	-databaseAdminPassword $DatabaseAdminPassword `
    	-databaseNames $DatabaseNames `
    	-storageKey $StorageKey `
    	-blobStorageEndpoint $BlobStorageEndpoint `
    	-blobContainerName $BlobContainerName
    	
    
    	
    Write-Verbose "Database backup script finished" -Verbose
    

You can get required details from azure portal as shown in below snippets:
To get the Blob container name: Go to the storage account and select the container name where you want to save the bacpac file .

v-pekapa_4-1622649277558.png

 

 

To find the storage key: Go to Access keys and copy the key as shown in below image:

v-pekapa_5-1622649352602.png

 

 

You can get the Blob Storage Endpoint from endpoint option as shown in the below image.

v-pekapa_6-1622649389938.png

 

  1. Now go to runbook and click on edit PowerShell runbook option and replace the existing script with the modified script that you have.
    v-pekapa_7-1622649423754.png

     

  2. Now to automate click on “link to schedule” and schedule the time according to your requirement in order to run the export job and click on create.
    v-pekapa_8-1622650923285.png

     

6.If you want to confirm If bacpac is completed successfully, you can go to job output and check the status of backup.

v-pekapa_9-1622651112359.png

 

You can also verify the status in SQL Server import and export history wizard as shown below:

v-pekapa_10-1622651148395.png

 

Once the backup is successful, you can find the .bacpac file in your specific storage account.

v-pekapa_11-1622651175715.png

 

Points to ponder:

  1. Make sure that you have set the option Allow all azure services to “Yes”.
  2. This functionality works only when public end point has been used and make sure deny public access should be set to “NO"
  3. Also If you encounter any issue related to module is miss then you need to go the below path to fix the issue:
    Go  the automation account-->module-->browse gallery--> Search missing module-->Import
%3CLINGO-SUB%20id%3D%22lingo-sub-2409213%22%20slang%3D%22en-US%22%3EAutomate%20exporting%20of%20azure%20sql%20database%20as%20.bacpac%20to%20blog%20storage.%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2409213%22%20slang%3D%22en-US%22%3E%3CP%3ELogin%20to%20Azure%20Portal--%26gt%3BGo%20to%20automation%20account%20--%26gt%3BRunbooks--%26gt%3Bbrowse%20gallery%20--%26gt%3Btype%20backup%20azure%20sql%20databases%20to%20blob%20storage%20and%20import%20the%20module.%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22v-pekapa_0-1622648842657.png%22%20style%3D%22width%3A%20678px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F285604i550BCCACC2CF0932%2Fimage-dimensions%2F678x187%3Fv%3Dv2%22%20width%3D%22678%22%20height%3D%22187%22%20role%3D%22button%22%20title%3D%22v-pekapa_0-1622648842657.png%22%20alt%3D%22v-pekapa_0-1622648842657.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3COL%20start%3D%222%22%3E%0A%3CLI%3EOpen%20the%20run%20book%20and%20click%20edit.%3CBR%20%2F%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22v-pekapa_1-1622649125019.png%22%20style%3D%22width%3A%20626px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F285616iABF6272F59BC8AF4%2Fimage-dimensions%2F626x183%3Fv%3Dv2%22%20width%3D%22626%22%20height%3D%22183%22%20role%3D%22button%22%20title%3D%22v-pekapa_1-1622649125019.png%22%20alt%3D%22v-pekapa_1-1622649125019.png%22%20%2F%3E%3C%2FSPAN%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22v-pekapa_2-1622649175619.png%22%20style%3D%22width%3A%20630px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F285617i553D0D36E591FDEA%2Fimage-dimensions%2F630x159%3Fv%3Dv2%22%20width%3D%22630%22%20height%3D%22159%22%20role%3D%22button%22%20title%3D%22v-pekapa_2-1622649175619.png%22%20alt%3D%22v-pekapa_2-1622649175619.png%22%20%2F%3E%3C%2FSPAN%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3C%2FLI%3E%0A%3CLI%3EDownload%20the%20code%20and%20replace%20the%20with%20your%20details%20as%20shown%20below%3A%3CBR%20%2F%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22v-pekapa_3-1622649209874.png%22%20style%3D%22width%3A%20685px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F285618iC37C86C386951BD3%2Fimage-dimensions%2F685x149%3Fv%3Dv2%22%20width%3D%22685%22%20height%3D%22149%22%20role%3D%22button%22%20title%3D%22v-pekapa_3-1622649209874.png%22%20alt%3D%22v-pekapa_3-1622649209874.png%22%20%2F%3E%3C%2FSPAN%3E%3CPRE%20class%3D%22lia-code-sample%20language-powershell%22%3E%3CCODE%3E%26lt%3B%23%0A.OUTPUTS%0A%20Human-readable%20informational%20and%20error%20messages%20produced%20during%20the%20job.%20Not%20intended%20to%20be%20consumed%20by%20another%20runbook.%0A%0A%23%26gt%3B%0A%0A%0A%20%20%20%20%24RESOURCEGROUPNAME%20%3D%20'%3CRESOURCEGROUPNAME%3E'%0A%20%20%20%20%24DatabaseServerName%20%3D%20'%3CDATABASENAME%3E'%0A%20%20%20%20%24DatabaseAdminUsername%20%3D%20'%3CADMINACCOUNTHERE%3E'%0A%20%20%20%20%24DatabaseAdminPassword%20%3D%20'%3CYOURPASSWORDHERE%3E'%0A%20%20%20%20%24DatabaseNames%20%3D%20'%3CDATABASENAEM%3E'%0A%20%20%20%20%24StorageAccountName%20%3D%20'%3CSTORAGEACCOUNTNAME%3E'%0A%20%20%20%20%24BlobStorageEndpoint%20%3D%20'https%3A%2F%2F%3CSTORAGEACCOUNTNAME%3E.blob.core.windows.net%2F'%0A%20%20%20%20%24StorageKey%20%3D%20'%3CSTORAGEACCESSKEY%3E'%0A%20%20%20%20%24BlobContainerName%20%3D%20'%3CCONTAINERNAME%3E'%0A%20%20%20%20%24RetentionDays%20%3D%20'10'%0A%0A%0A%24ErrorActionPreference%20%3D%20'stop'%0A%0Afunction%20Login()%20%7B%0A%20%24connectionName%20%3D%20%22AzureRunAsConnection%22%0A%20try%0A%20%7B%0A%20%20%24servicePrincipalConnection%20%3D%20Get-AutomationConnection%20-Name%20%24connectionName%20%20%20%20%20%20%20%20%20%0A%0A%20%20Write-Verbose%20%22Logging%20in%20to%20Azure...%22%20-Verbose%0A%0A%20%20Add-AzureRmAccount%20%60%0A%20%20%20-ServicePrincipal%20%60%0A%20%20%20-TenantId%20%24servicePrincipalConnection.TenantId%20%60%0A%20%20%20-ApplicationId%20%24servicePrincipalConnection.ApplicationId%20%60%0A%20%20%20-CertificateThumbprint%20%24servicePrincipalConnection.CertificateThumbprint%20%7C%20Out-Null%0A%20%7D%0A%20catch%20%7B%0A%20%20if%20(!%24servicePrincipalConnection)%0A%20%20%7B%0A%20%20%20%24ErrorMessage%20%3D%20%22Connection%20%24connectionName%20not%20found.%22%0A%20%20%20throw%20%24ErrorMessage%0A%20%20%7D%20else%7B%0A%20%20%20Write-Error%20-Message%20%24_.Exception%0A%20%20%20throw%20%24_.Exception%0A%20%20%7D%0A%20%7D%0A%7D%0A%0Afunction%20Create-Blob-Container(%5Bstring%5D%24blobContainerName%2C%20%24storageContext)%20%7B%0A%20Write-Verbose%20%22Checking%20if%20blob%20container%20'%24blobContainerName'%20already%20exists%22%20-Verbose%0A%20if%20(Get-AzureStorageContainer%20-ErrorAction%20%22Stop%22%20-Context%20%24storageContext%20%7C%20Where-Object%20%7B%20%24_.Name%20-eq%20%24blobContainerName%20%7D)%20%7B%0A%20%20Write-Verbose%20%22Container%20'%24blobContainerName'%20already%20exists%22%20-Verbose%0A%20%7D%20else%20%7B%0A%20%20New-AzureStorageContainer%20-ErrorAction%20%22Stop%22%20-Name%20%24blobContainerName%20-Permission%20Off%20-Context%20%24storageContext%0A%20%20Write-Verbose%20%22Container%20'%24blobContainerName'%20created%22%20-Verbose%0A%20%7D%0A%7D%0A%0Afunction%20Export-To-Blob-Storage(%5Bstring%5D%20%24RESOURCEGROUPNAME%2C%20%5Bstring%5D%24databaseServerName%2C%20%5Bstring%5D%24databaseAdminUsername%2C%20%5Bstring%5D%24databaseAdminPassword%2C%20%5Bstring%5B%5D%5D%24databaseNames%2C%20%5Bstring%5D%24storageKey%2C%20%5Bstring%5D%24blobStorageEndpoint%2C%20%5Bstring%5D%24blobContainerName)%20%7B%0A%20Write-Verbose%20%22Starting%20database%20export%20to%20databases%20'%24databaseNames'%22%20-Verbose%0A%20%24securePassword%20%3D%20ConvertTo-SecureString%20%E2%80%93String%20%24databaseAdminPassword%20%E2%80%93AsPlainText%20-Force%20%0A%20%24creds%20%3D%20New-Object%20%E2%80%93TypeName%20System.Management.Automation.PSCredential%20%E2%80%93ArgumentList%20%24databaseAdminUsername%2C%20%24securePassword%0A%0A%20foreach%20(%24databaseName%20in%20%24databaseNames.Split(%22%2C%22).Trim())%20%7B%0A%20%20Write-Output%20%22Creating%20request%20to%20backup%20database%20'%24databaseName'%22%0A%0A%20%20%24bacpacFilename%20%3D%20%24databaseName%20%2B%20(Get-Date).ToString(%22yyyyMMddHHmm%22)%20%2B%20%22.bacpac%22%0A%20%20%24bacpacUri%20%3D%20%24blobStorageEndpoint%20%2B%20%24blobContainerName%20%2B%20%22%2F%22%20%2B%20%24bacpacFilename%0A%20%20%24exportRequest%20%3D%20New-AzureRmSqlDatabaseExport%20-ResourceGroupName%20%24RESOURCEGROUPNAME%20%E2%80%93ServerName%20%24databaseServerName%20%60%0A%20%20%20%E2%80%93DatabaseName%20%24databaseName%20%E2%80%93StorageKeytype%20%22StorageAccessKey%22%20%E2%80%93storageKey%20%24storageKey%20-StorageUri%20%24BacpacUri%20%60%0A%20%20%20%E2%80%93AdministratorLogin%20%24creds.UserName%20%E2%80%93AdministratorLoginPassword%20%24creds.Password%20-ErrorAction%20%22continue%22%0A%20%20%0A%20%20%23%20Print%20status%20of%20the%20export%0A%20%20Get-AzureRmSqlDatabaseImportExportStatus%20-OperationStatusLink%20%24exportRequest.OperationStatusLink%20-ErrorAction%20%22Stop%22%0A%20%7D%0A%7D%0A%0Afunction%20Delete-Old-Backups(%5Bint%5D%24retentionDays%2C%20%5Bstring%5D%24blobContainerName%2C%20%24storageContext)%20%7B%0A%20Write-Output%20%22Removing%20backups%20older%20than%20'%24retentionDays'%20days%20from%20blob%3A%20'%24blobContainerName'%22%0A%20%24isOldDate%20%3D%20%5BDateTime%5D%3A%3AUtcNow.AddDays(-%24retentionDays)%0A%20%24blobs%20%3D%20Get-AzureStorageBlob%20-Container%20%24blobContainerName%20-Context%20%24storageContext%0A%20foreach%20(%24blob%20in%20(%24blobs%20%7C%20Where-Object%20%7B%20%24_.LastModified.UtcDateTime%20-lt%20%24isOldDate%20-and%20%24_.BlobType%20-eq%20%22BlockBlob%22%20%7D))%20%7B%0A%20%20Write-Verbose%20(%22Removing%20blob%3A%20%22%20%2B%20%24blob.Name)%20-Verbose%0A%20%20Remove-AzureStorageBlob%20-Blob%20%24blob.Name%20-Container%20%24blobContainerName%20-Context%20%24storageContext%0A%20%7D%0A%7D%0A%0AWrite-Verbose%20%22Starting%20database%20backup%22%20-Verbose%0A%0A%24StorageContext%20%3D%20New-AzureStorageContext%20-StorageAccountName%20%24storageAccountName%20-StorageAccountKey%20%24storageKey%0A%0ALogin%0A%0ACreate-Blob-Container%20%60%0A%20-blobContainerName%20%24blobContainerName%20%60%0A%20-storageContext%20%24storageContext%0A%20%0AExport-To-Blob-Storage%20%60%0A%20-resourceGroupName%20%24RESOURCEGROUPNAME%20%60%0A%20-databaseServerName%20%24DatabaseServerName%20%60%0A%20-databaseAdminUsername%20%24DatabaseAdminUsername%20%60%0A%20-databaseAdminPassword%20%24DatabaseAdminPassword%20%60%0A%20-databaseNames%20%24DatabaseNames%20%60%0A%20-storageKey%20%24StorageKey%20%60%0A%20-blobStorageEndpoint%20%24BlobStorageEndpoint%20%60%0A%20-blobContainerName%20%24BlobContainerName%0A%20%0A%0A%20%0AWrite-Verbose%20%22Database%20backup%20script%20finished%22%20-Verbose%0A%3C%2FCONTAINERNAME%3E%3C%2FSTORAGEACCESSKEY%3E%3C%2FSTORAGEACCOUNTNAME%3E%3C%2FSTORAGEACCOUNTNAME%3E%3C%2FDATABASENAEM%3E%3C%2FYOURPASSWORDHERE%3E%3C%2FADMINACCOUNTHERE%3E%3C%2FDATABASENAME%3E%3C%2FRESOURCEGROUPNAME%3E%3C%2FCODE%3E%3C%2FPRE%3E%3C%2FLI%3E%0A%3C%2FOL%3E%0A%3CP%3EYou%20can%20get%20required%20details%20from%20azure%20portal%20as%20shown%20in%20below%20snippets%3A%3CBR%20%2F%3E%3CSTRONG%3ETo%20get%20the%20Blob%20container%20name%3A%3C%2FSTRONG%3E%20Go%20to%20the%20storage%20account%20and%20select%20the%20container%20name%20where%20you%20want%20to%20save%20the%20bacpac%20file%20.%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22v-pekapa_4-1622649277558.png%22%20style%3D%22width%3A%20624px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F285619iD793E3AA42D3C91E%2Fimage-dimensions%2F624x245%3Fv%3Dv2%22%20width%3D%22624%22%20height%3D%22245%22%20role%3D%22button%22%20title%3D%22v-pekapa_4-1622649277558.png%22%20alt%3D%22v-pekapa_4-1622649277558.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSTRONG%3ETo%20find%20the%20storage%20key%3A%3C%2FSTRONG%3E%20Go%20to%20Access%20keys%20and%20copy%20the%20key%20as%20shown%20in%20below%20image%3A%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22v-pekapa_5-1622649352602.png%22%20style%3D%22width%3A%20716px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F285620iEAA10569C20DA92B%2Fimage-dimensions%2F716x163%3Fv%3Dv2%22%20width%3D%22716%22%20height%3D%22163%22%20role%3D%22button%22%20title%3D%22v-pekapa_5-1622649352602.png%22%20alt%3D%22v-pekapa_5-1622649352602.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EYou%20can%20get%20the%20Blob%20Storage%20Endpoint%20from%20endpoint%20option%20as%20shown%20in%20the%20below%20image.%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22v-pekapa_6-1622649389938.png%22%20style%3D%22width%3A%20689px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F285621i11C445C924FB8ADA%2Fimage-dimensions%2F689x210%3Fv%3Dv2%22%20width%3D%22689%22%20height%3D%22210%22%20role%3D%22button%22%20title%3D%22v-pekapa_6-1622649389938.png%22%20alt%3D%22v-pekapa_6-1622649389938.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3COL%20start%3D%224%22%3E%0A%3CLI%3ENow%20go%20to%20runbook%20and%20click%20on%20edit%20PowerShell%20runbook%20option%20and%20replace%20the%20existing%20script%20with%20the%20modified%20script%20that%20you%20have.%3CBR%20%2F%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22v-pekapa_7-1622649423754.png%22%20style%3D%22width%3A%20820px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F285623iA70C7AB77D97EC96%2Fimage-dimensions%2F820x166%3Fv%3Dv2%22%20width%3D%22820%22%20height%3D%22166%22%20role%3D%22button%22%20title%3D%22v-pekapa_7-1622649423754.png%22%20alt%3D%22v-pekapa_7-1622649423754.png%22%20%2F%3E%3C%2FSPAN%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3C%2FLI%3E%0A%3CLI%3ENow%20to%20automate%20click%20on%20%E2%80%9Clink%20to%20schedule%E2%80%9D%20and%20schedule%20the%20time%20according%20to%20your%20requirement%20in%20order%20to%20run%20the%20export%20job%20and%20click%20on%20create.%3CBR%20%2F%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22v-pekapa_8-1622650923285.png%22%20style%3D%22width%3A%20837px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F285634iA59EFB9B2F862B78%2Fimage-dimensions%2F837x425%3Fv%3Dv2%22%20width%3D%22837%22%20height%3D%22425%22%20role%3D%22button%22%20title%3D%22v-pekapa_8-1622650923285.png%22%20alt%3D%22v-pekapa_8-1622650923285.png%22%20%2F%3E%3C%2FSPAN%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3C%2FLI%3E%0A%3C%2FOL%3E%0A%3CP%3E6.If%20you%20want%20to%20confirm%20If%20bacpac%20is%20completed%20successfully%2C%20you%20can%20go%20to%20job%20output%20and%20check%20the%20status%20of%20backup.%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22v-pekapa_9-1622651112359.png%22%20style%3D%22width%3A%20837px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F285638iEDC19CC6A24E1479%2Fimage-dimensions%2F837x180%3Fv%3Dv2%22%20width%3D%22837%22%20height%3D%22180%22%20role%3D%22button%22%20title%3D%22v-pekapa_9-1622651112359.png%22%20alt%3D%22v-pekapa_9-1622651112359.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EYou%20can%20also%20verify%20the%20status%20in%20SQL%20Server%20import%20and%20export%20history%20wizard%20as%20shown%20below%3A%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22v-pekapa_10-1622651148395.png%22%20style%3D%22width%3A%20838px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F285639iD0BAB03F8276B147%2Fimage-dimensions%2F838x168%3Fv%3Dv2%22%20width%3D%22838%22%20height%3D%22168%22%20role%3D%22button%22%20title%3D%22v-pekapa_10-1622651148395.png%22%20alt%3D%22v-pekapa_10-1622651148395.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EOnce%20the%20backup%20is%20successful%2C%20you%20can%20find%20the%20.bacpac%20file%20in%20your%20specific%20storage%20account.%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22v-pekapa_11-1622651175715.png%22%20style%3D%22width%3A%20798px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F285640i45FEA837FCCDEF11%2Fimage-dimensions%2F798x174%3Fv%3Dv2%22%20width%3D%22798%22%20height%3D%22174%22%20role%3D%22button%22%20title%3D%22v-pekapa_11-1622651175715.png%22%20alt%3D%22v-pekapa_11-1622651175715.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSTRONG%3EPoints%20to%20ponder%3A%3C%2FSTRONG%3E%3C%2FP%3E%0A%3COL%3E%0A%3CLI%3EMake%20sure%20that%20you%20have%20set%20the%20option%20Allow%20all%20azure%20services%20to%20%E2%80%9CYes%E2%80%9D.%3C%2FLI%3E%0A%3CLI%3EThis%20functionality%20works%20only%20when%20public%20end%20point%20has%20been%20used%20and%20make%20sure%20deny%20public%20access%20should%20be%20set%20to%20%E2%80%9CNO%22%3C%2FLI%3E%0A%3CLI%3EAlso%20If%20you%20encounter%20any%20issue%20related%20to%20module%20is%20miss%20then%20you%20need%20to%20go%20the%20below%20path%20to%20fix%20the%20issue%3A%3CBR%20%2F%3EGo%26nbsp%3B%20the%20automation%20account--%26gt%3Bmodule--%26gt%3Bbrowse%20%3CSPAN%20style%3D%22font-family%3A%20inherit%3B%22%3Egallery--%26gt%3B%20Search%20missing%20module--%26gt%3BImport%3C%2FSPAN%3E%3C%2FLI%3E%0A%3C%2FOL%3E%3C%2FLINGO-BODY%3E%3CLINGO-TEASER%20id%3D%22lingo-teaser-2409213%22%20slang%3D%22en-US%22%3E%3CP%3EIn%20azure%20sql%20database%2C%20we%20know%20the%20sql%20server%20agent%20is%20not%20available.%20In%20order%20to%20automate%20the%20exporting%20of%20the%20database%20as%20bacpac%20files%20to%20blob%20storage%20we%20used%20on%20depend%20on%20automation%20account.%20In%20this%20article%20we%20can%20able%20to%20export%20the%20bacpac%20file%20to%20storage%20account%20using%20automation%20account.%3C%2FP%3E%3C%2FLINGO-TEASER%3E
Co-Authors
Version history
Last update:
‎Jun 22 2021 07:36 AM
Updated by: