Skip to content

Commit 62a881f

Browse files
committed
updated scripts, readme, index
1 parent d9c7bbe commit 62a881f

File tree

3 files changed

+33
-15
lines changed

3 files changed

+33
-15
lines changed

README.md

Lines changed: 27 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -146,25 +146,45 @@ This is the amazing part of using Azure Static WebApps. Deploying to Azure is co
146146
1. Fork this repository
147147
1. Get a [GitHub Token](https://help.github.com/en/articles/creating-a-personal-access-token-for-the-command-line)
148148
1. Run `./azure-deploy.sh`. Please note that if this is the first time you run it, it will create an `.env` file in the root folder. Fill the `.env` file. Run the `./azure-deploy.sh` again.
149+
1. Once the deployment is done go to the Azure portal, and open the Azure Static Web App resource just created.
150+
1. Open the "Configuration" pane and add a new environment variable named `DATABASE_URL` and assign the value of the database connection string mentioned before in the local development section.
149151
1. Done! Well, not really, read next.
150152

151153
## Fixing generated workflow file
152154

153-
The generated workflow file will not work. Even if the CI/CD pipeline will complete successfully, the Azure Static Web App will not work. This is due to how Onyx, the tool the automate the building and the deployment for Static Web Apps, doesn't now how to properly deal with the nuances of Prisma, that generates the client right away. Fixing this issue is quite easy, just add the following enviroment variable to the workflow, in the "Build and Deploy" step:
155+
The generated workflow file will not work. Even if the CI/CD pipeline will complete successfully, the Azure Static Web App will not work. This is due to how Onyx, the tool the automate the building and the deployment for Static Web Apps, doesn't now how to properly deal with the nuances of Prisma, that generates the client right away. Fixing this issue is quite easy, just add the following enviroment variable to the workflow.
156+
157+
The workflow file you have to change is in `./github/workflow` and in the name has the name retured by the deployment script. For example if the deployment script reported that:
158+
159+
```sh
160+
Static Web App created at: gentle-mud-01cd9ba1e.azurestaticapps.net
161+
```
162+
163+
your workflow file will be `./github/workflow/azure-static-web-apps-gentle-mud-01cd9ba1e.yml`.
164+
165+
You can do the requested small change right from your GitHub repository, if you don't want to clone the forked repo locally. Just after the line:
154166

155167
```yaml
156-
env: # Add environment variables here
157-
NODE_VERSION: 12
158-
PRE_BUILD_COMMAND: "npm install -g prisma@2.30.3"
159-
CUSTOM_BUILD_COMMAND: "npm install @prisma/client && npm run build"
160-
POST_BUILD_COMMAND: "npm install @prisma/client"
168+
###### End of Repository/Build Configurations ######
161169
```
162170

171+
in the "Build and Deploy" step, add this environment variables:
172+
173+
```yaml
174+
env: # Add environment variables here
175+
NODE_VERSION: 12
176+
PRE_BUILD_COMMAND: "npm install -g prisma@2.30.3"
177+
CUSTOM_BUILD_COMMAND: "npm install @prisma/client && npm run build"
178+
POST_BUILD_COMMAND: "npm install @prisma/client"
179+
```
180+
181+
Make sure you indent the lines correctly, as requested by YAML syntax, and than commit the change. (If you are using the GitHub online editor, and you don't see any red squiggly lines you should be good to go.)
182+
163183
Take a look at the sample workflow in the `./github/workflow` folder to see how your workflow file should look like.
164184

165185
## Running on Azure (yep!)
166186

167-
After you have commited the changes to the workflow file, the CI/CD pipeline will run again automatically. Once the pipeline has run, you should have a working website. Go to http://[your-swa-name].azurestaticapps.net, and enjoy!
187+
After you have commited the changes to the workflow file, the CI/CD pipeline will run again automatically (You can verify it from the "Action" section of your GitHub repo). Once the pipeline has run, you should have a working website. Go to http://[your-swa-name].azurestaticapps.net, and enjoy!
168188

169189
## Azure Static Web App
170190

azure-deploy.sh

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,8 @@ az staticwebapp create \
4242
--app-location "./client" \
4343
--token $gitToken
4444

45-
echo "Configuring Static Web App...";
46-
az staticwebapp create \
47-
-n $appName \
48-
-g $resourceGroup \
49-
--settings-names DATABASE_URL=$DATABASE_URL
45+
echo "Getting Static Web App...";
46+
dhn=`az staticwebapp show -g $resourceGroup -n $appName --query "defaultHostname"`
47+
echo "Static Web App created at: $dhn";
5048

5149
echo "Done."

client/index.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@
1313
<h1>todos</h1>
1414
</header>
1515
<section class="main">
16-
<ul class="todo-list">
17-
<li>Rest Sample</li>
18-
<li>GraphQL Sample</li>
16+
<ul>
17+
<li><a href="client-rest.html">Go to the REST Sample</a></li>
18+
<li><a href="client-graphql.html">Go to the GraphQL Sample</a></li>
1919
</ul>
2020
</section>
2121
</section>

0 commit comments

Comments
 (0)