Use this function to connect to an Azure database from R. This is a wrapper function for the DBI::dbConnect
function.
Usage
azure_connect(creds_file,
creds_position = 1,
pwd = rstudioapi::askForPassword("Microsoft password"))
Arguments
- creds_file
This is the path to the .yml file with the Azure information. The .yml must include: server, driver, authenticator, database, uid_suffix and port
- creds_position
This is a number that identifies which set of credentials in the .yml file to use. It defaults to 1, which is the first set of credentials. If you have more than one set of credentials in your config file and want to use the second set, you should set
creds_position = 2
- pwd
by default, this allows you to enter your Windows password. You can override this by entering a password in this argument.
Examples
if (FALSE) { # \dontrun{
# example .yml file format:
default:
db:
server: 'server-name'
driver: 'ODBC Driver 18 for SQL Server'
authenticator: 'ActivedirectoryPassword'
database: 'database-name'
uid_suffix: '@organization.org'
port: port-number
# connecting with default credentials + windows password:
con <- azure_connect(creds_file = "credentials.yml")
# connecting with the second set of credentials and a custom password
con <- azure_connect(creds_file = "credentials.yml", creds_position = 2, pwd = "password")
} # }