2

I'm actually working on the Continuous Delivery pipeline for the UI project made in ReactJs with the use of the Azure Static Web App. I want to create and deploy the static web app to Azure based on the git repo located in Azure DevOps. The reason behind this is I see a huge opportunity to create a Pull Request Environment pipeline for the system I work on every day with the usage of static web apps which seem to be a super cheap and fast solution! Then the pipeline would allow testing the Pull Request changes in isolation before releasing to DEV, QA,... Prod environments.

Anyway, straight to the point. The official Microsoft documentation provides only an example of how to do this for GitHub repo but I cannot find any info on how this can be achieved when using Azure DevOps git repo:

az staticwebapp create \
    -n my-first-static-web-app \
    -g <RESOURCE_GROUP_NAME> \
    -s https://github.com/<YOUR_GITHUB_ACCOUNT_NAME>/my-first-static-web-app \
    -l <LOCATION> \
    -b main \
    --app-artifact-location "build" \
    --token <YOUR_GITHUB_PERSONAL_ACCESS_TOKEN>

I thought that the way the az staticwebapp create works in the provided example should be analogical with the Azure DevOps. I thought that equivalent of YOUR_GITHUB_PERSONAL_ACCESS_TOKEN in Azure DevOps would be an access token that can be generated: enter image description here

When I try to run the following code:

az staticwebapp create -l westus2 -n appNameTest1 -g TestPrEnvResourceGroup -s "https://dev.azure.com/myOrganisationName/myProjectName/_git/myRepoName -b "main" --token "generatedTokenValuefwfsdgsgsd"

I'm getting the following exception;

Command group 'staticwebapp' is in preview and under development. Reference and support levels: https://aka.ms/CLI_refstatus Operation returned an invalid status 'Bad Request'

enter image description here

Also, I don't think it can matter but the TestPrEnvResourceGroup is created under the UK West location. It doesn't tell me much, like if the token or some other parameter is wrong...

Any ideas? Cheers

GoldenAge
  • 2,918
  • 5
  • 25
  • 63

1 Answers1

0

Have you tried this way?

You need to generate a deployment token from the Azure Static Web App and have it in the YAML

I tried the same for Angular app and it worked pretty well

 azure_static_web_apps_api_token: $(deployment_token)

UPDATE : As per the Github issue , currently this is not supported.

We currently don’t support automatically creating Azure DevOps pipelines. This is the supported path for using Azure DevOps: https://learn.microsoft.com/en-us/azure/static-web-apps/publish-devops

You can vote for the feature here

Sajeetharan
  • 216,225
  • 63
  • 350
  • 396
  • This one I tried yes and it worked however I don't like this approach as it does all the stuff to do with Build, running tests, and deployment in a single pipeline. It can be used for small projects like for students etc. but I don't believe it's a good approach for big types of apps. I prefer to have a separate Build pipeline which is always triggered when the PR is created or some changes are pushed to the PR. This one would run the tests, linting stuff, etc. and as a result, creates an artifact. Then an artifact could be used by different deployment pipelines. – GoldenAge May 26 '21 at 21:07
  • As for now, I want to introduce the azure static websites to my team by implementing the PR environment concept. This would give huge flexibility as you can deploy the artifact to the static web app or just to an app service. I also prefer Powershell as you can test it locally, and in the case of yml stuff it can be only tested via pipeline which is a huge disadvantage IMO. Sry mate, I cannot accept your answer as I asked for an Azure CLI solution. – GoldenAge May 26 '21 at 21:07
  • Straight answer is "It is not supported" – Sajeetharan May 28 '21 at 03:02