I'm trying to set up elastic jobs to run a procedure on another database.
I set up code to run as below: EXEC jobs.sp_add_target_group 'DatabaseGroup' GO
EXEC jobs.sp_add_target_group_member
'DatabaseGroup',
@target_type = N'SqlDatabase',
@server_name='test-db01.database.windows.net',
@database_name =N'TEST'
GO
EXEC jobs.sp_add_job @job_name='Hourly Update', @description='Runs Hourly Update',
@schedule_interval_type='Hours',@schedule_interval_count=1
EXEC jobs.sp_add_jobstep @job_name='Hourly Update',
@command=N'exec [TT].[HOURLY_UPDATE]',
@credential_name='JobRun',
@target_group_name='DatabaseGroup'
EXEC jobs.sp_start_job 'Hourly Update'
So when i submit my job to run
I got the following error:
Failed to connect to the target database: Reason: An instance-specific error occurred while establishing a connection to SQL Server. Connection was denied since Deny Public Network Access is set to Yes
To connect to this server, use the Private Endpoint from inside your virtual network
(Msg 47073, Level 14, State 1, Line 65536)
So my private end point name is called db01.test.****.com <- confidential name used
So I recreate the group_member & resubmit job again
EXEC jobs.sp_add_target_group_member
'DatabaseGroup',
@target_type = N'SqlDatabase',
@server_name='db01.test.****.com',
@database_name =N'TEST'
GO
The new error below is: The server 'db01.test.****.com' cannot be used as a job target because it is not an Azure SQL Database server in the same Azure cloud as this job agent. The server's fully qualified host name must end with '.database.windows.net'.
So any ideas how i can get around this scenario & get my job to submit