Open JoeWirtley opened 4 years ago
Agreed. If Azure CLI supports this platform, it could be used for local system and 3rd party pipelines (Bitbucket, etc).
We're looking at adding deploying a zip from via the Azure CLI. This will initially take a URL to a zip file. It means you'll have to zip up the contents and make it available on a publicly accessible location. This could be a SAS URI to a zip file in Azure Blob Storage. The file can be deleted after deployment.
Do you have any rough timeframe for when this might be available for testing?
We're looking at adding deploying a zip from via the Azure CLI. This will initially take a URL to a zip file. It means you'll have to zip up the contents and make it available on a publicly accessible location. This could be a SAS URI to a zip file in Azure Blob Storage. The file can be deleted after deployment.
Could you explain the reason for this approach over something like pointing at a local zip file? Or even the build output directory and perform the archiving for us as is the case with ZipDeploy?
That comment was based on how the deployment api works. Weβre also looking at other options right now to see how to best support local deployment.
Hi @anthonychu! Just checking in: would you have any updates regarding this topic?
@anthonychu - any update on this?
We have a need to deploy to SWA's from Bit Bucket. I don't mind how this is done (although Azure CLI probably makes sense), but right now we cannot deploy to this Azure resource. This is a real gap in functionality as we can deploy all our other Azure resources though the other Bit Bucket Pipes or Azure CLI.
Would be great to see this gap filled ASAP.
@anthonychu thanks for the awesome service in the first point! :)
We have also faced this issue and were forced to create a new pipeline in Azure dev ops and we had to give up our standard pipelines setup which usually is using bitbucket/gitlab.
I am completely new to Azure and have been deploying serverless services using AWS/Cloudformation/ServerlessFramework /CDK, soI am sorry me in advance if I am saying something wrong. I came across a project where I had to use Azure to deploy a static app + serverless API. I've been reading many tutorials, examples, docs, etc but I feel that it lacks a fully automated way/examples to setup CI/CD for static web apps.
Most of the examples are tightened to GitHub workflow but would be really nice to have more docs/examples and to use azure CLI/ARM templates to do that. I've found some documentation at:
https://docs.microsoft.com/en-us/azure/static-web-apps/publish-azure-resource-manager?tabs=azure-cli#feedback https://docs.microsoft.com/en-us/azure/templates/microsoft.web/staticsites?tabs=json#Capability
But it is still not 100% clear on what is the best approach to follow here - also most of the example/blog posts use VS CODE Extension and Azure portal. It seems that the way to go is to use ARM templates - which also lack demos/examples.
This tutorial is amazing: https://docs.microsoft.com/en-us/azure/static-web-apps/local-development, but is still not 100% on how to do 100% automatic.
Thanks again :)
@lucashfreitas Have you found a workflow for deploying azure static apps using the command line that could be built into a non-github workflow?
@Ramblurr not yet. Unfortunately, I ended up migrating the repo to Github :(. Also, we had a hard time setting up a 100% continuous integration flow using 100% automated scripts using ARM/Azure CLI. I did not find many examples only and have to dig deep into the docs but I managed to make it 85% automatic. The hard part is that we are deploying multiple applications using the same setup, so ideally we wanted just to plug our subscription ID + APP/Tenant Id.
There is a way to create the static app through the CLI but not deploy it.
Our first step for supporting non-GitHub based deployments might be to document how to run the Docker container that the GitHub action runs so that you can run it on your own environment. Obviously this requires Docker and might not be ideal for some scenarios. But this might be a short/medium term solution while we work on other solutions.
In one of our projects, we use something like this to deploy to Azure Static WebApps from BitBucket pipelines:
- step:
name: Deploy web app
image: mcr.microsoft.com/appsvc/staticappsclient:stable
deployment: <environment>
script:
- /bin/staticsites/StaticSitesClient upload --verbose --app ./build --skipAppBuild true --apiToken $AZURE_STATICSITE_TOKEN
where the ./build
folder contains the React based static app artifacts built in previous steps
@kepalas I'm trying to port this into a console application. What's the deployment
key here? Currently, I get the output deployment_action was not provided
.
As I mentioned before, that snippet is part of our BitBucket pipeline. The deployment
key indicates which environment variables should be added to the runtime (more info can be found here).
You can find more info on how to use the StaticSitesClient
binary by checking its help section:
Oh, I just quoted my arguments incorrectly... All good, thanks! :)
@anthonychu i assume the code for staticsitesclient is not public, so debugging this is a bit cumbersome. maybe you can give a hint what's wrong here?
Edit:
Found it, there's a bug in the conversion from UploadOptions
to ActionOptions
. It doesn't set the ApiLocation
:
@matkoch Can you explain how to fix this? Or are we just stuck? :/
@JustClueless and for those running into the api bug @matkoch found in the latest "stable" image, you can pin this version which has api publish function working as expected...
mcr.microsoft.com/appsvc/staticappsclient@sha256:57b6be4b785eccc666462f284457b72b0c09f6f5e6d067b965750233a417fd0e
Any idea when CLI compatible deployment tool will be officially supported / available for SWA?
For everyone that is still searching for a way to just upload something from the command line, I wrote for myself a little script for this:
https://github.com/codez-one/CZ.Azure.FileExchange/blob/main/build/deploy.ps1
You can look into the readme how this works. But here some warnings:
Still it would be nice to have a build-in feature.
another usecase is btw. if your dotnet build requires more tools then just dotnet. I my case this is sass
. You can define every program call in your csproj for example.
And this make it impossible to use the build container.
Having the ability to push pre-built artifacts to Static Web Apps via Azure CLI (ideally from a local folder) would be hugely beneficial and is a big gap in the product at the moment for teams like mine. In our case we use Bitbucket and CircleCI with some fairly complex build pipelines - moving away from that setup would have massively increased the scope (and politics) of adopting Azure for the hosting.
My workaround for now is:
It's obviously not ideal because it means two git repos, two separate CI workflows etc, but it is working well and I think seems like a more robust workaround than having to use the tools in an undocumented way. I can at least be confident that pushing to git from a bash script won't stop working with no notice.
Swapping that process out for a single CLI call in the future would be great.
Check if this helps. https://www.akshayhebbar.com/
Hi all, We have now officially announced the GA of Static Web Apps CLIππ This is a power-packed tool which now enables features such as login, deploy from local, automatic framework detection and much more - all from your local development system! Do have a look and let us know how you like it :) (P.S. It is Open Source, so feel free to contribute to the next set of features you'd like to see!) π
Hi all, We have now officially announced the GA of Static Web Apps CLIππ This is a power-packed tool which now enables features such as login, deploy from local, automatic framework detection and much more - all from your local development system! Do have a look and let us know how you like it :) (P.S. It is Open Source, so feel free to contribute to the next set of features you'd like to see!) π
@Reshmi-Sriram - does Microsoft support the usage of the Static Web Apps CLI inside a Github Action yet? We typically first "build", then package the build output into a "release" (ZIP file), and finally "deploy" the contents of the release. We haven't yet found a way to do this with the official GitHub Action for deploying to Azure Static Web Apps.
@drmcclelland any reason you need to manually zip and then deploy?
The new SWA CLI does that automatically for you now, all you need is to run the swa
command inside your local SWA project and follow the wizard.
Get the deployment token of your SWA project
swa deploy --print-token
From a CI/CD:
Thanks for your response @manekinekko - we trigger our build/deploy steps upon creation of a "release" in our GitHub repo. First, the final output of the "build" step is zipped up and uploaded as a release asset. Next, the "deploy" step downloads and unzips the release asset, then pushes it to be deployed to Azure.
What I'd like to confirm is if Microsoft officially supports the usage of the swa
CLI inside of a GitHub action? I only saw examples of local usage in the docs, but not inside a CI/CD pipeline.
We do support deploying from a CI/CD, using deployment tokens.
+1 to that, specifically through az cli or biceps/arm templates
I would like a way to be able to publish a static web app from my file system, not using GitHub (or DevOps).