sPath is the local path + filename from the file we want to upload.sBlobname is the name the Blob should be named after upload.sContainer will reference the name of the container from our Blob storage.The method UploadToAzureBlob() needs three string parameters. Now first we create a new public method to upload a blob. Inside our class Azure.cs, we first add a new using directive for the new reference, so that we do not to have write the whole namespaces in front of our commands. I will use the same class as in my previous post Azure.cs, which will contain our code to access the Azure File Shares and now also the Azure Blob storage. Therefore we can add the package from NuGet assembly as for file shares.Īs of today we need the Azure Storage Blobs client library for. In order to access the Azure Storage Blobs we have to use another API resp. Unstructured data is data that does not adhere to a particular data model or definition, such as text or binary data. Blob storage is optimized for storing massive amounts of unstructured data. NET – Version 12.6.0Īzure Blob storage is Microsoft’s object storage solution for the cloud. # find the path to the desktop folder: $desktop = :: GetFolderPath ( 'Desktop' ) # specify the path to the folder you want to monitor: $Path = $desktop # specify which files you want to monitor $FileFilter = '*' # specify whether you want to monitor subfolders as well: $IncludeSubfolders = $true # specify the file or folder properties you want to monitor: $AttributeFilter = :: FileName, :: LastWrite # specify the type of changes you want to monitor: $ChangeTypes = :: Created, :: Deleted # specify the maximum time (in milliseconds) you want to wait for changes: $Timeout = 1000 # define a function that gets called for every change: function Invoke-SomeAction # subscribe your event handler to all event types that are # important to you.In a previous post we went through accessing Azure File Shares with C#, today we will do the same with Azure Blob storage.Īzure Storage Blobs client library for. Whenever a change is detected, Invoke-SomeAction is called. This is straight-forward: the script below monitors your desktop and all of its subfolders for new files and for deletion of files. However, responding to events is not trivial in a single-threaded environment like PowerShell. This way, you cannot miss change events because the FileSystemWatcher is constantly monitoring. Instead, whenever a change occurs, an event is fired, and your script can respond to the events.
0 Comments
Leave a Reply. |