Close

Using AzureCLI in DevOps

To create a table and perform a set of inserts, you can use the Azure CLI action in a DevOps Release pipeline. Reference the script and pass your arguments, like so:

StorageTableCreate.cmd:

call az storage table create –name %1 –account-name %2

call az storage entity insert –table-name %1 –account-name %2 –entity PartitionKey=[systema] RowKey=system Active=true Active@odata.type=Edm.Boolean LastRevision=1000000 LastRevision@odata.type=Edm.Int32 –if-exists fail

call az storage entity insert –table-name %1 –account-name %2 –entity PartitionKey=[systemb] RowKey=system Active=true Active@odata.type=Edm.Boolean LastRevision=1000000 LastRevision@odata.type=Edm.Int32 –if-exists fail & exit 0

Note that the first statement doesn’t end with ‘exit 0’. This means that the next insert statement will be processed, regardless of the result of the first insert. This means: a record will be added if a record for that system doesn’t exist yet.