'Passing databaseimport value to Azure DevOps job
I am currently writing a YAML script which calls some powershell scripts to export a database from one subscription to bacpac, then import to another. Because of the tier the databases are running on, this often now fails due to the 60 minute limit on free microsoft hosted agents.
To get round this issue, I have set another task to run in event of the import failure, which picks up the the import/export database status and continues once it is marked as complete.
To do this, I have created an output variable for the new-azsqldatabaseimport object, which is then passed as a parameter to the fail script to use.
However, the problem I see is that when this runs, I get an error "The input object cannot be bound to any parameters for the command either because the command does not take pipeline input or the input and its properties do not match any of the parameters that take pipeline input"
To clarify, on the first pass where the $importdb variable is initially defined, the getstatus function works fine.
I can see the value is being brought in (although it doesn't show me the actual value, but the details of the object, i.e Microsoft.Azure.Commands.Sql.ImportExport.Model.AzureSqlDatabaseImportModel), I have also not defined the type of variable for the parameter in the powershell script. But it still does not work. These are the steps I am using:
[In main import task]
$importdb = New-AzSqlDatabaseImport [database parameters]
write-host "##vso[task.setvariable variable=Importdbname;IsOutput=true]$importdb"
[in failure catch task]
Importdbstring: $[ dependencies.ImportDB.outputs['Importdb1.Importdbname'] ]
-variable passed as parameter to powershell script, used as below
[parameter(Mandatory=$false)] $importingdb=''
$importdb=$importingdb
while (($importdb | Get-AzSqlDatabaseImportExportStatus).Status -eq 'InProgress){....}
Can anyone offer any advice how to make this work? (apart from using premium DBs or paid agents)
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
