You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+21-20Lines changed: 21 additions & 20 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -19,7 +19,7 @@ The definition of this GitHub Action is in [action.yml](https://github.com/Azure
19
19
20
20
If you *can* use the option [Allow Azure Services and resources to access this server](https://docs.microsoft.com/en-us/azure/azure-sql/database/firewall-configure#connections-from-inside-azure), you are all set and you don't need to to anything else to allow GitHub Action to connect to your Azure SQL database.
21
21
22
-
If you *cannot* use the aformentioned option, additional steps are needed.
22
+
If you *cannot* use the aforementioned option, additional steps are needed.
23
23
24
24
- Authenticate using [Azure Login](https://github.com/Azure/login)
25
25
@@ -35,30 +35,30 @@ Alternatively, if enough permissions are not granted on the service principal or
35
35
36
36
### Create SQL database and deploy using GitHub Actions
37
37
38
-
1. Follow the tutorial [Azure SQL Quickstart](https://docs.microsoft.com/en-in/azure/sql-database/sql-database-single-database-get-started?tabs=azure-portal)
39
-
2. Copy the [SQL-on-Azure.yml template](https://github.com/Azure/actions-workflow-samples) and paste the contents in `.github/workflows/` in your project repository as `workflow.yml`.
40
-
3. Change `server-name` to your Azure SQL Server name.
41
-
4. Commit and push your project to GitHub repository, you should see a new GitHub Action initiated in **Actions** tab.
38
+
1. Follow the tutorial [Azure SQL Quickstart](https://docs.microsoft.com/azure/sql-database/sql-database-single-database-get-started?tabs=azure-portal)
39
+
1. Copy the [SQL-on-Azure.yml template](https://github.com/Azure/actions-workflow-samples) and paste the contents in `.github/workflows/` in your project repository as `workflow.yml`.
40
+
1. Update the connection string with your values. Connection string format is: `Server=<server.database.windows.net>;User ID=<user>;Password=<password>;Initial Catalog=<database>`
41
+
1. Commit and push your project to GitHub repository, you should see a new GitHub Action initiated in **Actions** tab.
42
42
43
-
### Configure GitHub Secrets
43
+
### Configure GitHub Secrets
44
44
45
45
For using any sensitive data/secrets like Azure Service Principal or SQL Connection strings within an Action, add them as [secrets](https://help.github.com/en/github/automating-your-workflow-with-github-actions/virtual-environments-for-github-actions#creating-and-using-secrets-encrypted-variables) in the GitHub repository and then use them in the workflow.
46
46
47
47
Follow the steps to configure the secret:
48
48
49
-
* Define a new secret under your repository **Settings** > **Secrets** > **Add a new secret** menu
50
-
* Paste the contents of the Secret (Example: Connection String) as Value
49
+
- Define a new secret under your repository **Settings** > **Secrets** > **Add a new secret** menu
50
+
- Paste the contents of the Secret (Example: Connection String) as Value
51
51
52
-
If you need to configure Azure Credentials to automatically manage firewall rules, you need to create a Service Principal, and store the related credentials into a GitHub Secrect so that it can be used by the Azure Login actions to authenticate and authorize any subsequent request.
52
+
If you need to configure Azure Credentials to automatically manage firewall rules, you need to create a Service Principal, and store the related credentials into a GitHub Secret so that it can be used by the Azure Login actions to authenticate and authorize any subsequent request.
53
53
54
-
Paste the output of the below [az cli](https://docs.microsoft.com/en-us/cli/azure/?view=azure-cli-latest) command as the value of secret variable, for example `AZURE_CREDENTIALS`.
54
+
Paste the output of the below [az cli](https://docs.microsoft.com/cli/azure/?view=azure-cli-latest) command as the value of secret variable, for example `AZURE_CREDENTIALS`.
55
55
56
56
```bash
57
57
az ad sp create-for-rbac --name "mySQLServer" --role contributor \
The above means you have to create secrets in GitHub which can be found within your repository within **Settings** and then **Secrets** and also be careful to check the connection string which you copy from Azure SQL as the connection string has this **Password={your_password}** and you will need to supply the correct password for your connection string.
96
98
97
-
The above means you have to create secrets in GitHub which can be found within your repository within **Settings** and then **Secrets** and also
98
-
be careful to check the connection string which you copy from Azure SQL as the connection string has this **Password={your_password}** and you will need to supply
99
-
the correct password for your connection string.
99
+
The `server-name` is optional and is there only to provide backward compatibility. It is strongly recommended to put the server name in the connection string. The connection string uses this template: `Server=<servername>; User ID=<user_id>; Password=<password>; Initial Catalog=<database>`. In case the server name is put both in the `server-name` and in the `connection-string`, the server name used will be the one specified in the `server-name` YAML key.
100
+
101
+
### How to create a .dacpac file from your existing SQL Server Database
100
102
101
-
### How to create a dacpac file from your existing SQL Server Database
102
-
103
103
For the above action to work, you will need to create a file called `Database.dacpac` and place it into the root of your
104
104
GitHub repository. The following link will show you how to go about creating a dacpac file but make sure the file is called `Database.dacpac`.
105
105
106
-
[Export a Data-tier application](https://docs.microsoft.com/en-us/sql/relational-databases/data-tier-applications/export-a-data-tier-application?view=sql-server-ver15)
106
+
[Export a Data-tier application](https://docs.microsoft.com/sql/relational-databases/data-tier-applications/export-a-data-tier-application?view=sql-server-ver15)
107
107
108
108
Azure SQL Action for GitHub is supported for the Azure public cloud as well as Azure government clouds ('AzureUSGovernment' or 'AzureChinaCloud'). Before running this action, login to the respective Azure Cloud using [Azure Login](https://github.com/Azure/login) by setting appropriate value for the `environment` parameter.
109
+
109
110
## Contributing
110
111
111
112
This project welcomes contributions and suggestions. Most contributions require you to agree to a
[`User Id=user;Password="ab'=abcdf''c;123";Initial catalog=testdb`,'validates values enclosed with double quotes ',`ab'=abcdf''c;123`],
11
-
[`User Id=user;Password='abc;1""2"adf=33';Initial catalog=testdb`,'validates values enclosed with single quotes ',`abc;1""2"adf=33`],
12
-
[`User Id=user;Password="abc;1""2""adf(012j^72''asj;')'=33";Initial catalog=testdb`,'validates values beginning with double quotes and also contains escaped double quotes',`abc;1"2"adf(012j^72''asj;')'=33`],
13
-
[`User Id=user;Password='ab""c;1''2''"''adf("0""12j^72''asj;'')''=33';Initial catalog=testdb`,'validates values beginning with single quotes and also contains escaped single quotes',`ab""c;1'2'"'adf("0""12j^72'asj;')'=33`],
14
-
[`User Id=user;Password=JustANormal123@#$password;Initial catalog=testdb`,'validates values not beginning quotes and not containing quotes or semi-colon',`JustANormal123@#$password`]
10
+
[`Server=test1.database.windows.net;User Id=user;Password="ab'=abcdf''c;123";Initial catalog=testdb`,'validates values enclosed with double quotes ',`ab'=abcdf''c;123`],
11
+
[`Server=test1.database.windows.net;User Id=user;Password='abc;1""2"adf=33';Initial catalog=testdb`,'validates values enclosed with single quotes ',`abc;1""2"adf=33`],
12
+
[`Server=test1.database.windows.net;User Id=user;Password="abc;1""2""adf(012j^72''asj;')'=33";Initial catalog=testdb`,'validates values beginning with double quotes and also contains escaped double quotes',`abc;1"2"adf(012j^72''asj;')'=33`],
13
+
[`Server=test1.database.windows.net;User Id=user;Password='ab""c;1''2''"''adf("0""12j^72''asj;'')''=33';Initial catalog=testdb`,'validates values beginning with single quotes and also contains escaped single quotes',`ab""c;1'2'"'adf("0""12j^72'asj;')'=33`],
14
+
[`Server=test1.database.windows.net;User Id=user;Password=JustANormal123@#$password;Initial catalog=testdb`,'validates values not beginning quotes and not containing quotes or semi-colon',`JustANormal123@#$password`],
15
+
[`User Id=user;Password=JustANormal123@#$password;Server=test1.database.windows.net;Initial catalog=testdb`,'validates connection string without server',`JustANormal123@#$password`]
describe('throw for invalid connection strings',()=>{
28
30
letinvalidConnectionStrings=[
29
-
[`User Id=user;Password="ab'=abcdf''c;123;Initial catalog=testdb`,'validates values beginning with double quotes but not ending with double quotes'],
30
-
[`User Id=user;Password='abc;1""2"adf=33;Initial catalog=testdb`,'validates values beginning with single quote but not ending with single quote'],
31
-
[`User Id=user;Password="abc;1""2"adf(012j^72''asj;')'=33";Initial catalog=testdb`,'validates values enclosed in double quotes but does not escape double quotes in between'],
32
-
[`User Id=user;Password='ab""c;1'2''"''adf("0""12j^72''asj;'')''=33';Initial catalog=testdb`,'validates values enclosed in single quotes but does not escape single quotes in between'],
33
-
[`User Id=user;Password=NotANormal123@;#$password;Initial catalog=testdb`,'validates values not enclosed in quotes and containing semi-colon']
31
+
[`Server=test1.database.windows.net;User Id=user;Password="ab'=abcdf''c;123;Initial catalog=testdb`,'validates values beginning with double quotes but not ending with double quotes'],
32
+
[`Server=test1.database.windows.net;User Id=user;Password='abc;1""2"adf=33;Initial catalog=testdb`,'validates values beginning with single quote but not ending with single quote'],
33
+
[`Server=test1.database.windows.net;User Id=user;Password="abc;1""2"adf(012j^72''asj;')'=33";Initial catalog=testdb`,'validates values enclosed in double quotes but does not escape double quotes in between'],
34
+
[`Server=test1.database.windows.net;User Id=user;Password='ab""c;1'2''"''adf("0""12j^72''asj;'')''=33';Initial catalog=testdb`,'validates values enclosed in single quotes but does not escape single quotes in between'],
35
+
[`Server=test1.database.windows.net;User Id=user;Password=NotANormal123@;#$password;Initial catalog=testdb`,'validates values not enclosed in quotes and containing semi-colon'],
36
+
[`Server=test1.database.windows.net;Password=password;Initial catalog=testdb`,'missing user id'],
Copy file name to clipboardExpand all lines: action.yml
+4-1Lines changed: 4 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -3,16 +3,19 @@ description: 'Deploy a DACPAC or a SQL script to Azure SQL d
3
3
inputs:
4
4
server-name:
5
5
description: 'Name of the Azure SQL Server name, like Fabrikam.database.windows.net.'
6
-
required: true
6
+
required: false
7
7
connection-string:
8
8
description: 'The connection string, including authentication information, for the Azure SQL Server database.'
9
9
required: true
10
10
dacpac-package:
11
11
description: 'Path to DACPAC file to deploy'
12
+
required: false
12
13
sql-file:
13
14
description: 'Path to SQL script file to deploy'
15
+
required: false
14
16
arguments:
15
17
description: 'In case DACPAC option is selected, additional SqlPackage arguments that will be applied. When SQL query option is selected, additional sqlcmd arguments will be applied.'
thrownewError('Invalid connection string. A valid connection string is a series of keyword/value pairs separated by semi-colons. If there are any special characters like quotes, semi-colons in the keyword value, enclose the value within quotes. Refer this link for more info on conneciton string https://aka.ms/sqlconnectionstring');
0 commit comments