mirror of
https://github.com/HackTricks-wiki/hacktricks-cloud.git
synced 2026-01-07 19:00:49 -08:00
az functions
This commit is contained in:
@@ -143,20 +143,29 @@ az rest --method GET \
|
||||
|
||||
# Access
|
||||
curl "<script-href>?code=<master-key>"
|
||||
## Python example:
|
||||
# Python function app example
|
||||
curl "https://newfuncttest123.azurewebsites.net/admin/vfs/home/site/wwwroot/function_app.py?code=RByfLxj0P-4Y7308dhay6rtuonL36Ohft9GRdzS77xWBAzFu75Ol5g==" -v
|
||||
# JavaScript function app example
|
||||
curl "https://consumptionexample.azurewebsites.net/admin/vfs/site/wwwroot/HttpExample/index.js?code=tKln7u4DtLgmG55XEvMjN0Lv9a3rKZK4dLbOHmWgD2v1AzFu3w9y_A==" -v
|
||||
```
|
||||
|
||||
And to **change the code that is being executed** in the function with:
|
||||
|
||||
```bash
|
||||
# Set the code to set in the function in /tmp/function_app.py
|
||||
## The following continues using the python example
|
||||
## Python function app example
|
||||
curl -X PUT "https://newfuncttest123.azurewebsites.net/admin/vfs/home/site/wwwroot/function_app.py?code=RByfLxj0P-4Y7308dhay6rtuonL36Ohft9GRdzS77xWBAzFu75Ol5g==" \
|
||||
--data-binary @/tmp/function_app.py \
|
||||
-H "Content-Type: application/json" \
|
||||
-H "If-Match: *" \
|
||||
-v
|
||||
|
||||
# NodeJS function app example
|
||||
curl -X PUT "https://consumptionexample.azurewebsites.net/admin/vfs/site/wwwroot/HttpExample/index.js?code=tKln7u4DtLgmG55XEvMjN0Lv9a3rKZK4dLbOHmWgD2v1AzFu3w9y_A==" \
|
||||
--data-binary @/tmp/index.js \
|
||||
-H "Content-Type: application/json" \
|
||||
-H "If-Match: *" \
|
||||
-v
|
||||
```
|
||||
|
||||
### `Microsoft.Web/sites/functions/listKeys/action`
|
||||
@@ -258,6 +267,25 @@ az rest --method PUT \
|
||||
--uri "https://management.azure.com/subscriptions/<subcription-id>/resourceGroups/<res-group>/providers/Microsoft.Web/sites/<app-name>/hostruntime/admin/vfs/function_app.py?relativePath=1&api-version=2022-03-01" \
|
||||
--headers '{"Content-Type": "application/json", "If-Match": "*"}' \
|
||||
--body @/tmp/body
|
||||
|
||||
# Through the SCM URL (using Azure permissions or SCM creds)
|
||||
az rest --method PUT \
|
||||
--url "https://consumptionexample.scm.azurewebsites.net/api/vfs/site/wwwroot/HttpExample/index.js" \
|
||||
--resource "https://management.azure.com/" \
|
||||
--headers "If-Match=*" \
|
||||
--body 'module.exports = async function (context, req) {
|
||||
context.log("JavaScript HTTP trigger function processed a request. Training Demo 2");
|
||||
|
||||
const name = (req.query.name || (req.body && req.body.name));
|
||||
const responseMessage = name
|
||||
? "Hello, " + name + ". This HTTP triggered function executed successfully. Training Demo 2"
|
||||
: "This HTTP triggered function executed successfully. Pass a name in the query string or in the request body for a personalized response. Training Demo 2";
|
||||
|
||||
context.res = {
|
||||
// status: 200, /* Defaults to 200 */
|
||||
body: responseMessage
|
||||
};
|
||||
}'
|
||||
```
|
||||
|
||||
### `Microsoft.Web/sites/publishxml/action`, (`Microsoft.Web/sites/basicPublishingCredentialsPolicies/write`)
|
||||
|
||||
@@ -151,6 +151,9 @@ az rest --method POST \
|
||||
|
||||
Then, in order to **update an app using the token** you could run the following command. Note that this command was extracted checking **how to Github Action [https://github.com/Azure/static-web-apps-deploy](https://github.com/Azure/static-web-apps-deploy) works**, as it's the one Azure set by default ot use. So the image and paarements could change in the future.
|
||||
|
||||
> [!TIP]
|
||||
> To deploy the app you could use the **`swa`** tool from [https://azure.github.io/static-web-apps-cli/docs/cli/swa-deploy#deployment-token](https://azure.github.io/static-web-apps-cli/docs/cli/swa-deploy#deployment-token) of follow the following raw steps:
|
||||
|
||||
1. Download the repo [https://github.com/staticwebdev/react-basic](https://github.com/staticwebdev/react-basic) (or any other repo you want to deploy) and run `cd react-basic`.
|
||||
2. Change the code you want to deploy
|
||||
3. Deploy it running (Remember to change the `<api-token>`):
|
||||
|
||||
Reference in New Issue
Block a user