Azure File Storage is an easy and active service. We can access it programmatically and through UI. This article is focused on Azure DevOps Release pipeline and Release deployment to Azure File Storage. We can use Azure Storage Explorer (UI) to move builds around different environment or locations.
I am assuming that you already have crated a project and build pipeline.
Azure DevOps already offers a task to release the code to Azure storage. This task is Azure file copy.
The difference between Azure Blob is [https] storage and Azure File [smb] storage. We don’t have any default task to release the code to Azure File Share.
What should we do then? Azure CLI can be used to copy files to Azure File storage. Here is the task that can be used;
To keep things simpler, I am not using YAML. I will be using simple UI.
Build a Release Pipeline
Click on “Release -> New Pipeline -> Empty” as show below;
Rename pipeline to a meaningful name “Release to File share”.
Map incoming build output as input to release pipeline. Click on “Add an Artifact” option in Artifacts box and select the source type as Build. It will list the latest build automatically. Select this option as show below;
Save your changes. Under the stages in the second box ,you should see text like “1 job, 0 task”.
Click on it. Click on “+” sign against Agent job tile. Select Azure CLI from the task and click on Add. Here is how it looks;
This is the PowerShell inline script;
$buildNumber = $Env:BUILD_BUILDNUMBER
az storage file upload-batch --destination https://[share name].file.core.windows.net/deployments --source . --account-key [share first key] --destination-path LatestPublish/$buildNumber
Create a release. Open Azure Storage Explorer, Navigate to your share and LatestPublish folder. Here is the build output;
The build is deployed with the last build number. Inside build number we can see build alias at drop location that we have defined in build pipeline. If you run the release pipeline again, it will overwrite the contents of file share.
This is the first attempt. We can optimize this process by introducing variables for builds, builds number etc.
declare @DB sysname = 'MyDB';
select * from msdb.dbo.restorehistory where destination_database_name = @DB;
To view all databases;
WITH LastRestores AS
(
SELECT
DatabaseName = [d].[name] ,
[d].[create_date] ,
[d].[compatibility_level] ,
[d].[collation_name] ,
r.*,
RowNum = ROW_NUMBER() OVER (PARTITION BY d.Name ORDER BY r.[restore_date] DESC)
FROM master.sys.databases d
LEFT OUTER JOIN msdb.dbo.[restorehistory] r ON r.[destination_database_name] = d.Name
)
SELECT *
FROM [LastRestores]
WHERE [RowNum] = 1
There a few reasons you may be seeing this error, the two most common ones are:
You are behind a “transparent proxy”, which means someone (such as your IT department) is intercepting HTTPS traffic, decrypting it, and then encrypting it using a self-signed certificate
You are running software, such as anti-virus software, which is injecting a self-signed SSL certificates into the HTTPS messages you receive
When Storage Explorer encounters one of these “self-signed certificates”, it can no longer know if the HTTPS message it is receiving has been tampered with. If you have a copy of the self-signed certificate though, then you can tell Storage Explorer to trust it. If you are unsure of who is injecting the certificate, then you can try to find it yourself by doing the following:
Install Open SSL
Windows (any of the light versions should suffice)
Mac and Linux: Should be included with your operating system
Run Open SSL
Windows: Go to the install directory, then /bin/, then double click on openssl.exe
Look for self-signed certificates. If you’re unsure which are self-signed, then look for any where the subject (“s:”) and issuer (“i:”) are the same.
Once you have found any self-signed certificates, then for each one, copy and paste everything from and including -----BEGIN CERTIFICATE----- to -----END CERTIFICATE----- to a new .cer file.
Open NotePad. Make sure, you are copying everything between —BEGIN CERTIFICATE— and —END CERTIFICATE— block. For example, if there are two certificates, then the file would be;
—BEGIN CERTIFICATE—
—END CERTIFICATE—
—BEGIN CERTIFICATE—
—END CERTIFICATE—
Save File as .cer on your computer.
Open Storage Explorer and then go to Edit -> SSL Certificates -> Import Certificates. Using the file picker, find, select, and open the .cer files you created.
Project deployment file is a self-contained unit of deployment that includes the essential information about the package and parameters in the project.
How to create .ispac file?
The project deployment model is introduced in SQL Server 2012. This is something similar to create SSISDeploymentManifest in previous SQL Server SSIS versions. They were also called package deployment model.
When we build/run a package, Visual Studio will build .ispac file in bin\Development folder of the project. Using this file, we can deploy the project without Data Tool or Visual Studio.
How to deploy SSIS packages using .ispac?
Here are different ways to deploy .ispac file;
Using SSMS
We can use SSMS for this. Create a sub-folder under SSISDB database. Right-Click on the folder and select deploy project. Follow the wizard.
Using Visual Studio
We can import ispac file into visual studio
Open Visual Studio
File -> New -> Project (Business Intelligence -> Integrations Serices)