Fenil shah
Fenil shah

Reputation: 31

Getting error at the time of Use-AzureSqlJobConnection -CurrentAzureSubscription

I am trying to execute the script on an elastic pool using powershell. When I execute this command,

Use-AzureSqlJobConnection -CurrentAzureSubscription -ResourceGroupName {ABC}

It is giving me error for, Use-AzureSqlJobConnection : No Elastic Database Jobs control database found.

Please help me with what I am missing here, to create something in the portal ?

Thanks in advance.

Upvotes: 0

Views: 57

Answers (2)

Nathan L
Nathan L

Reputation: 31

If you are trying to execute a script on your databases using elastic jobs, you should first Create and configure the agent, the elastic database job agent (it is a service running on azure for automation on Azure SQL Databases). in this case you should look into the links about it:

some overview about the service:

https://learn.microsoft.com/en-us/azure/sql-database/elastic-jobs-overview

configure the servic jobs using Powershell:

https://learn.microsoft.com/en-us/azure/sql-database/elastic-jobs-powershell

configure the servic jobs using TSQL:

https://learn.microsoft.com/en-us/azure/sql-database/elastic-jobs-tsql

If you just want to to use Power Shell to run the same script on all of your databases (once), you may want to use another script dew to -ResourceGroupName is a property of Elastic jobs. you should try using command like Invoke-Sqlcmd, iterating on all databases in the elastic pool.

https://learn.microsoft.com/en-us/powershell/module/sqlserver/invoke-sqlcmd?view=sqlserver-ps

I recommend you to try look into the Powershell Model dbatools (https://dbatools.io/) it has a lot of useful powershell commands ready to use.

Upvotes: 0

AmanGarg-MSFT
AmanGarg-MSFT

Reputation: 1153

Please follow the below document to install Elastic Database jobs and then you would be able to run Use-AzureSqlJobConnection -CurrentAzureSubscription

https://learn.microsoft.com/en-us/azure/sql-database/sql-database-elastic-jobs-service-installation

https://learn.microsoft.com/en-us/azure/sql-database/elastic-jobs-overview

Thanks!

Upvotes: -1

Related Questions