Yes, you can publish Storybook files to an Azure DevOps run without hosting a live preview. The trick is to build Storybook as a static site, upload the generated files as a pipeline artifact, and then use the artifact’s download URL (or a linked artifact in a release) to let reviewers access the stories—no separate web server or preview environment required. This article explains the exact steps, the trade-offs, and how to make the experience as close to a real preview as possible.
Why You’d Want This
Storybook is a frontend workshop where you develop and test UI components in isolation. Normally, you’d run npm run build-storybook to produce a static folder (usually storybook-static) and then host that folder on a web server, a CDN, or a service like Netlify or Vercel. But in a corporate Azure DevOps environment, you might not have permission to spin up a public hosting service, or you might want to keep everything inside your own pipeline for security and compliance reasons. Publishing the build as an Azure DevOps artifact gives you a private, versioned copy of the Storybook files that anyone with access to the pipeline can download and open locally.
How Azure DevOps Artifacts Work
Azure DevOps pipelines have a built-in concept called artifacts. When a build finishes, you can publish files as an artifact, and those files become available on the run summary page. Anyone with permission to view the run can download the artifact as a zip file. The artifact is stored in Azure DevOps itself, so you don’t need to configure any external hosting. The key limitation is that Azure DevOps does not serve artifacts as live web pages—it only offers them as downloads. So when someone downloads the artifact, they get a folder full of HTML, JS, and CSS files. Opening the index.html directly from the file system usually works because Storybook is a single-page app that references relative paths, but some features (like lazy-loaded chunks) may behave differently when opened via file:// instead of http://.
Step-by-Step: Publish Storybook as an Artifact
- Add a build step in your pipeline that runs
npm ci(ornpm install) and thennpm run build-storybook. This creates thestorybook-staticfolder. - Use the Publish Pipeline Artifact task (or the
publishkeyword in YAML) to upload that folder. In YAML, it looks like this:steps: - task: PublishPipelineArtifact@1 inputs: targetPath: 'storybook-static' artifactName: 'storybook' publishLocation: 'pipeline' - Run the pipeline. After completion, go to the run summary page, find the Artifacts section, and click the storybook artifact to download it as a zip.
- Share the download link with your team. They can download the zip, unzip it, and open
index.htmlin a browser.
This approach works for any project that can produce a static build. You don’t need a separate hosting service, and the artifact is tied to the specific pipeline run, so you always know which commit it came from.
Making the Downloaded Storybook Usable
The biggest issue with opening Storybook from a local file is that browsers treat file:// URLs differently. Most Storybook builds work fine because they use relative paths, but if you use features like dynamic imports (code splitting), the browser may block loading those chunks due to CORS restrictions on file://. To work around this, you have two options:
- Run a local server: After unzipping, run a simple static server like
npx serve storybook-staticorpython -m http.serverin that folder. This gives you a properhttp://localhostURL and eliminates most issues. - Configure Storybook to use absolute paths: In your
main.jsorpreview.js, setstaticDirsand ensure the build usesrelativepaths. By default, Storybook builds with relative paths, so this is usually not needed.
If you want to avoid the download step entirely, you can use the Azure DevOps Artifacts browser preview feature. In the run summary, click on the artifact name, and Azure DevOps will show a file explorer. You can click on index.html and it will open in a new tab—but note that Azure DevOps serves the file with a text/html content type, so it actually renders as a web page. This is a hidden gem: the artifact’s file preview is a real HTTP server, so Storybook works as if it were hosted. The URL looks like https://dev.azure.com/.../_apis/build/builds/123/artifacts?artifactName=storybook&fileId=...&fileName=index.html. This URL is not a permanent link, but it works for the duration of the run’s retention period.
Comparing Artifacts vs. a Real Preview Host
Hosting a preview (e.g., on a static web app or a VM) gives you a stable, shareable URL that anyone can open without downloading anything. It also allows Storybook to load all assets over HTTP, which is the most reliable. The downsides are cost, maintenance, and security—you need to manage the host, and you must ensure the preview is not publicly accessible if your code is private. Artifacts, on the other hand, are free (they’re part of your Azure DevOps storage), private by default, and automatically tied to the build. The trade-off is the lack of a direct URL for non-technical stakeholders. If you need to share with a product manager who isn’t comfortable downloading a zip, you might want to use the file preview trick or set up a proper preview environment.
Common Pitfalls and How to Avoid Them
- Missing
storybook-staticfolder: Ensure your build script actually outputs to that folder. If you use a custom output directory, adjust thetargetPathaccordingly. - Artifact size: Storybook builds can be tens of megabytes. Azure DevOps has a default artifact size limit of 2 GB per artifact, so you’re fine, but large builds may slow down the pipeline. Consider using
--quietor compression if needed. - Retention policies: Artifacts are deleted after the retention period (default 30 days for pipelines). If you need long-term access, set a longer retention policy on the pipeline or download the artifact to a storage location.
- Opening
index.htmldirectly: If you just double-click the file, it may work, but if you see a blank page, use a local server. This is the most common issue.
Alternatives to Artifacts
If artifacts don’t meet your needs, consider these options:
- Azure Static Web Apps: You can deploy Storybook to a Static Web App directly from the pipeline. This gives you a public or private URL, but it requires an Azure subscription and a separate resource.
- Azure Blob Storage with static website hosting: Upload the
storybook-staticfolder to a blob container with static website enabled. This is cost-effective and gives you an HTTP endpoint, but you need to manage access (e.g., using SAS tokens or public access). - Storybook’s own
--previewflag: Not a hosting solution, but you can runstorybook dev --previewto get a local preview during development. That doesn’t help with sharing.
Frequently Asked Questions
Can I get a direct link to the Storybook without downloading?
Yes, use the artifact’s file preview. In the run summary, click on the artifact name, navigate to index.html, and click it. Azure DevOps will render it in a new tab. The URL is temporary and tied to the build, but it works for sharing during the review period.
Does the artifact approach work for private repos?
Yes, artifacts are only accessible to users with permissions to the Azure DevOps project. If your repo is private, the artifact is private by default. You can also restrict access further using pipeline permissions.
Why does my downloaded Storybook show a blank page?
This is usually because you opened index.html directly from the file system, and the browser blocked loading additional scripts due to CORS. Run a local HTTP server in the unzipped folder (e.g., npx serve) and open http://localhost:5000 instead.
Can I automate the download for team members?
You can create a release pipeline that downloads the artifact and then sends an email with the link to the artifact preview, or you can use a script to fetch the artifact via the Azure DevOps REST API and distribute it. But for most teams, the manual download is sufficient.
Is there a size limit for Storybook artifacts?
Azure DevOps allows up to 2 GB per artifact, which is more than enough for typical Storybook builds. If your build exceeds that, you may need to split it or use a different hosting method.
Can I use this for PR validation?
Yes, you can trigger a build on pull requests and publish the Storybook artifact. Reviewers can then download and inspect the component changes. This is a common pattern for component libraries.
Related
Method: the standard formula for this calculation, rounded as each result states. See how the calculators work or report an error.
More cards in this drawer
- Mac Start Up Automatically After Power Failure?
- Expose Self-Hosted Service Securely Without Cloudflare Tunnel
- Nano Delivery for Functional Foods: What It Can and Can’t Do4.00
- Disable Apple Watch Turn-by-Turn Vibration While Driving
- Convert Play FLAC in iTunes: Full Guide
- Soda Foundation Charter: What It Means