Skip to main content

Deploy SPFx production solution files in specific folder with in container on Azure CDN

Hi,

When we creates SPFx solution and deploying the build files on Azure CDN, it deploys all the files in a container which you mentioned in "deploy-azure-storage.json" file. This is bit messy to see. Because you can deploy multiple solution on the same container. But what if you want to manage solutions by Solutions or By versions.
Here is the way.

I will show you how to deploy SPFx production deployment files in a specific folder in the Container on Azure CDN.

First you have to deploy some gulp task packages in dev-dependencies
	npm install gulp-util gulp-deploy-azure-cdn --save-dev
Now you need to make following changes in the "gulpfile.js" file :
	const deployCdn = require('gulp-deploy-azure-cdn');
	const gutil = require('gulp-util');
	
gulp.task('deploy-azure-storage-folder', function () {
  return gulp.src('temp/deploy/**/*', {}).pipe(deployCdn({
      containerName: '<<Your Container Name>>', // Container created in StorageAccount
      serviceOptions: ['<<blobstoragename>>', '<<MyLongSecretStringFromAzureConfigPanel>>'], // custom arguments to azure BlobService
      folder: '<<Folder Name To Store>>', // path within container
      deleteExistingBlobs: false, // true means recursively deleting anything under folder
      concurrentUploadThreads: 20, // number of concurrent uploads, choose best for your network condition
      metadata: {
          cacheControl: 'public, max-age=1', // cache in browser
          cacheControlHeader: 'public, max-age=1' // cache in azure CDN.
      },
      testRun: false // test run - means no blobs will be actually deleted or uploaded, see log messages for details
  })).on('error', gutil.log);
});


At last just call the gulp task "deploy-azure-storage-folder" with command gulp deploy-azure-storage-folder.

So gulp command sequence should be like :

	gulp clean
gulp bundle --ship
gulp deploy-azure-storage-folder
gulp package-solution --ship

Comments

Popular posts from this blog

Export / Import from Excel file in SharePoint

SharePoint Web Part - Export or Import from Excel Here is the tool which will help you to import excel file into a list. This tool will not create any kind of list or column. It will help users to import their excel file in specific list. This tool also allows users to update existing records directly from excel file. I have develop the tool in SharePoint Framework. Currently this tool is for SharePoint Online version only. We are supporting following columns : Single line of text Multiple lines of text Number Yes/No Person or Group (Person + Group) Person or Group (Person + Group) (Allow multiple selections) Date and Time Choice Choice (Allow multiple selections) Hyperlink or Picture Currency Managed Metadata Managed Metadata (Allow multiple values) Lookup Lookup (Allow multiple values) Installation of App :- 1. Click here to download the sps-import-from-excel.sppkg . 2. Visit the Microsoft 365 SharePoint Admin Center 3. Go to Apps -> App Catalog. If you don't have ap

"@microsoft/sp-http" that is not declared in the manifest

 Hi, I was trying to use SPFx PnP Property Pane Controls . Specially  PropertyFieldSitePicker control. When I have given reference & used it in Property configuration pane, It has given an error : Something went wrong If the problem persists, contact the site administrator and give them the information in Technical Details. TECHNICAL DETAILS [SPLoaderError.loadComponentError]: Failed to load component "b023546a-e83e-48d9-b3d9-eeaa5575b5a2" (MyWebPart). Original error: The entry point for component "b023546a-e83e-48d9-b3d9-eeaa5575b5a2" (MyWebPart) has a dependency on "@microsoft/sp-http" that is not declared in the manifest. INNERERROR: The entry point for component "b023546a-e83e-48d9-b3d9-eeaa5575b5a2" (MyWebPart) has a dependency on "@microsoft/sp-http" that is not declared in the manifest. CALLSTACK: Error at t [as constructor] (https://modern.akamai.odsp.cdn.office.net/files/sp-client/sp-webpart-workbench-assembly_en-us_bb