|
4 | 4 |
|
5 | 5 | ## Azure static web apps
|
6 | 6 |
|
7 |
| -**Preset:** `azure` |
| 7 | +**Preset:** `azure-swa` |
8 | 8 |
|
9 | 9 | :read-more{title="Azure Static Web Apps" to="https://azure.microsoft.com/en-us/products/app-service/static"}
|
10 | 10 |
|
@@ -70,99 +70,3 @@ That's it! Now Azure Static Web Apps will automatically deploy your Nitro-powere
|
70 | 70 |
|
71 | 71 | If you are using runtimeConfig, you will likely want to configure the corresponding [environment variables on Azure](https://docs.microsoft.com/en-us/azure/static-web-apps/application-settings).
|
72 | 72 |
|
73 |
| -## Azure functions |
74 |
| - |
75 |
| -**Preset:** `azure_functions` |
76 |
| - |
77 |
| -::important |
78 |
| -If you encounter any issues, please ensure you're using a Node.js 16+ runtime. You can find more information about [how to set the Node version in the Azure docs](https://docs.microsoft.com/en-us/azure/azure-functions/functions-reference-node?tabs=v2#setting-the-node-version). |
79 |
| -Please see [nitrojs/nitro#2114](https://github.com/nitrojs/nitro/issues/2114) for some common issues. |
80 |
| -:: |
81 |
| - |
82 |
| -### Local preview |
83 |
| - |
84 |
| -Install [Azure Functions Core Tools](https://docs.microsoft.com/en-us/azure/azure-functions/functions-run-local) if you want to test locally. |
85 |
| - |
86 |
| -You can invoke a development environment from the serverless directory. |
87 |
| - |
88 |
| -```bash |
89 |
| -NITRO_PRESET=azure_functions npx nypm@latest build |
90 |
| -cd .output |
91 |
| -func start |
92 |
| -``` |
93 |
| - |
94 |
| -You can now visit `http://localhost:7071/` in your browser and browse your site running locally on Azure Functions. |
95 |
| - |
96 |
| -### Deploy from your local machine |
97 |
| - |
98 |
| -To deploy, just run the following command: |
99 |
| - |
100 |
| -```bash |
101 |
| -# To publish the bundled zip file |
102 |
| -az functionapp deployment source config-zip -g <resource-group> -n <app-name> --src dist/deploy.zip |
103 |
| -# Alternatively you can publish from source |
104 |
| -cd dist && func azure functionapp publish --javascript <app-name> |
105 |
| -``` |
106 |
| - |
107 |
| -### Deploy from CI/CD via GitHub actions |
108 |
| - |
109 |
| -First, obtain your Azure Functions Publish Profile and add it as a secret to your GitHub repository settings following [these instructions](https://github.com/Azure/functions-action#using-publish-profile-as-deployment-credential-recommended). |
110 |
| - |
111 |
| -Then create the following file as a workflow: |
112 |
| - |
113 |
| -```yaml [.github/workflows/azure.yml] |
114 |
| -name: azure |
115 |
| -on: |
116 |
| - push: |
117 |
| - branches: |
118 |
| - - main |
119 |
| - pull_request: |
120 |
| - branches: |
121 |
| - - main |
122 |
| -jobs: |
123 |
| - deploy: |
124 |
| - runs-on: ${{ matrix.os }} |
125 |
| - strategy: |
126 |
| - matrix: |
127 |
| - os: [ ubuntu-latest ] |
128 |
| - node: [ 14 ] |
129 |
| - steps: |
130 |
| - - uses: actions/setup-node@v2 |
131 |
| - with: |
132 |
| - node-version: ${{ matrix.node }} |
133 |
| - |
134 |
| - - name: Checkout |
135 |
| - uses: actions/checkout@master |
136 |
| - |
137 |
| - - name: Get yarn cache directory path |
138 |
| - id: yarn-cache-dir-path |
139 |
| - run: echo "::set-output name=dir::$(yarn cache dir)" |
140 |
| - |
141 |
| - - uses: actions/cache@v2 |
142 |
| - id: yarn-cache |
143 |
| - with: |
144 |
| - path: ${{ steps.yarn-cache-dir-path.outputs.dir }} |
145 |
| - key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }} |
146 |
| - restore-keys: | |
147 |
| - ${{ runner.os }}-yarn-azure |
148 |
| -
|
149 |
| - - name: Install Dependencies |
150 |
| - if: steps.cache.outputs.cache-hit != 'true' |
151 |
| - run: yarn |
152 |
| - |
153 |
| - - name: Build |
154 |
| - run: npm run build |
155 |
| - env: |
156 |
| - NITRO_PRESET: azure_functions |
157 |
| - |
158 |
| - - name: 'Deploy to Azure Functions' |
159 |
| - uses: Azure/functions-action@v1 |
160 |
| - with: |
161 |
| - app-name: <your-app-name> |
162 |
| - package: .output/deploy.zip |
163 |
| - publish-profile: ${{ secrets.AZURE_FUNCTIONAPP_PUBLISH_PROFILE }} |
164 |
| -``` |
165 |
| -
|
166 |
| -### Optimizing Azure functions |
167 |
| -
|
168 |
| -Consider [turning on immutable packages](https://docs.microsoft.com/en-us/azure/app-service/deploy-run-package) to support running your app from the zip file. This can speed up cold starts. |
0 commit comments