Uploading images directly to Cloud Storage by using Signed URL

As cloud grows in popularity, it has become common to deploy applications in the cloud and provide them to end users. At the same time, the trend of using serverless architecture means that an unspecified number of end users can seamlessly access resources in the cloud. If you’re offering services to users and serving them content, you’ll want to use a cloud architecture that can solve traditional problems intelligently, and reduce the cost of developing and hosting servers by taking advantage of the cloud.In this blog post, you’ll see how to implement a service hosted on Google Cloud Platform (GCP) that allows users to upload images into Cloud Storage using Signed URL, then serve that static content using managed services. This is particularly helpful if you’re running a social media company with constant image uploads, or hosting and managing consumer-generated media.Without using the cloud, it can be difficult to develop and manage a server that lets users upload image files, especially at high scale. You have to queue requests to the process responsible for uploading the files to control the flow rate, and you have to prevent the system from going down due to request overload. You also need to set appropriate resource limits for finite resources (such as RAM) of each server that’s involved.Furthermore, to allow uploading very large files to the server, it can be very costly to develop and host the server. And if the upload server is to be used by millions of users, it will require a lot of work to ensure its scalability and user experience.Let’s get started building an image upload feature to use with Cloud Storage. You can access the full set of source files that we’ve used on Github, here.Getting started building an image upload featureBefore diving into the GCP components needed to implement this service, let’s define our requirements:Use managed services as much as possibleEnable only authenticated users to upload filesValidate/filter the content uploaded by usersIn order to satisfy the above requirements, we devised the following architecture with GCP services:The key characteristic of this architecture is that it uses a serverless platform from file upload to delivery. This is the general workflow you’ll be setting up. Let’s detail each step shown in the diagram.1. Once App Engine receives a request from the user, App Engine generates a Signed URL that allows PUT requests to be executed only for a specific Cloud Storage bucket and object for authenticated users, using application domain logic.2. Next, the user can upload a file for a specific bucket and object accordingly.3. Once the user uploads the file to Cloud Storage, it triggers Cloud Functions as finalize event. Then Cloud Functions validates the uploaded file.4. After confirming that the file is in image format and appropriate size at step 3, annotate the image by posting to the Cloud Vision API to filter inappropriate content.5. Once the validations in steps 3 and 4 are complete, copy the image file from the Uploadable Bucket to the Distribution Bucket.6. The copied image file is now available to the public.Next, we will devise an actual implementation for the above steps.Generate Signed URL on App Engine standard runtimeCloud Storage provides the Signed URL feature to let individual end users perform specific actions. Signed URL makes it possible to generate temporary credentials valid only for a specific end user to securely upload a file. The Google Cloud official client library makes it easy to generate a Signed URL. Using this feature, you’ll prepare an API server to generate a Signed URL dynamically for specific end users. For our purposes, we’re implementing the API using App Engine Standard.Here’s how to generate a Signed URL:1. Create a new service account or prepare the service account for signing bytes in App Engine.2. Create a string necessary for the signature to generate a Signed URL (note that Content_MD5 and Canonicalized_Extension_Headers are omitted).    a. Choose PUT for Cloud Storage API that accepts file upload.    b.The value of Content-Type depends on the MIME type of the file being uploaded. This is determined by the API request from the end user.    c. Set Unix epoch time for expiration. After accepting the API request, set the shortest possible value of the future. We will set 15 minutes here.    d. Specify a bucket and an object as Canonicalized_Resource. The object key is dynamically generated so it doesn’t duplicate an existing one.3. Sign the string generated in step 2 with the secret key of the service account prepared in step 1.Check out the official documentation for more details on procedures. If you are using Golang to implement all of the above procedures, it will look like this:As mentioned in the code, there are two ways to sign the generated bytes to create the Signed URL.One way is to sign it yourself using the private key associated with the service account. This is suitable for use in environments such as Google Compute Engine and Google Kubernetes Engine (GKE). If you choose this option, you have to manage the private key yourself.The second way is to use the serviceAccounts.signBlob API, which is one of the Cloud Identity and Access Management (IAM) Service Account APIs. This lets you sign the bytes without managing the private key on the application runtime. Here we’re using the signBlob to avoid managing the private key.In addition, within Cloud Storage, you need to grant the following permissions to generate a Signed URL.storage.buckets.getstorage.objects.createstorage.objects.deleteIf you would like to use the signBlob API, you also have to grant your service account the Service Account Token Creator role.Uploading files using Signed URLNow, a user can upload files directly to Cloud Storage using Signed URLs dispatched in the above way. Here, we’ll use PUT Object, one of the Cloud Storage XML APIs, for the Signed URL that App Engine has generated.You can run this from a mobile application or front-end code of a web application. Here’s the sample file upload code:Using Bucket Lock with Signed URLAs you can see from the architecture diagram above, we’ve set up two Cloud Storage buckets: the upload destination (Uploadable Bucket) and the delivery source (Distribution Bucket).Although all the files will be copied to the Distribution Bucket after validation, these files will still reside in the Uploadable Bucket as well. However, these files will no longer be referred by any processing module. So it’s meaningless to keep the files copied to the Distribution Bucket still lying around in the Uploadable Bucket.In addition, end users can upload files any number of times in the Uploadable Bucket until the Signed URL is expired.To solve these two problems, use Object Lifecycle Management and Retention Policy.First, define the lifecycle to make sure there are no unnecessary objects left in the Uploadable Bucket. You only need to define the lifecycle conditions for the bucket and the behaviors that align with each condition. Here, let’s define the lifecycle of one day before deleting the object, which would look like this:Next, let’s make sure users can’t upload the file over and over again within the prescribed period of time. You can do this by defining a retention policy.A retention policy lets you specify the retention period for the bucket, and makes it impossible to overwrite or delete the object during that period. Use the same expiration date in the Signed URL and the retention policy period. You need to avoid conflict with the lifecycle setting, since the object will be deleted after one day. (Note that retention policies cannot be enabled for buckets with versioning enabled.)In order to create a bucket with these settings, execute the following command:Validate and copy the uploaded fileYou’ve so far seen how to generate a Signed URL to upload files directly to Cloud Storage. However, before making this available to users, more validation is necessary. You’ll want to verify the validity of the file uploaded by the authenticated user, and Signed URL and Cloud Storage alone can’t validate the content.To do this, we’ll implement the validation/copy process using Cloud Functions. To run Cloud Functions triggered by a specific event on GCP, use Background Functions, specifically to trigger the event of Cloud Storage. We use google.storage.object.finalize as the event of object creation.Next, how should we validate the uploaded file? Here are the requirements in order.1. Make sure that an object with the same object key as the uploaded file does not exist in Distribution Bucket.    a. If the object already exists, stop further processing.    b. This is a conditional branch that may occur because the execution of Cloud Functions guarantees at-least-once execution.2. Get Content-Type and the size from the metadata of the target object in the Uploadable Bucket.   a. Check that the size does not exceed the Cloud Storage size limit. If so, stop further processing.   b. The size limit should be determined based on the specification of your runtime (in this case, the Cloud Function is the runtime for validation).3. Read the target object in the Uploadable Bucket, and validate based on the Content-Type acquired in step 2.    a. There’s no guarantee that the Content-Type specified at the time of generating the Signed URL matches the content of the actually uploaded object, so verify that next.4. Post the target object in the Uploadable Bucket to the Vision API, and verify whether it contains violent content by using Safe Search Annotation.    a. If so, it will filter what may be violent, adult, medical and racy (likelihood over POSSIBLE).5. If the object passed validation, copy the object from the Uploadable Bucket to the Distribution Bucket.To create an implementation that meets the above requirements, use the Cloud Functions Go 1.11 runtime. The source code is as follows:To deploy UploadImage in the above source code to Cloud Functions, execute the following command:Don’t forget to turn on –retry. In case there’s a temporary error case, the background function should be made with retries taken into account. In addition, since Cloud Functions guarantees at-least-once execution, it is not idempotent in that the object in Distribution Bucket may be updated more than once. However, there are no side effects.Upload a file!Let’s actually upload a file using the system we’ve built, which uses managed services from uploading images to delivery. Testing is easy; just run the source code used to post the image in Signed URL earlier.After the background function finishes running, make sure that the object in the Uploadable Bucket is copied to the Distribution Bucket. You can also introduce push notifications to let the user know when the distribution starts, since these processes are performed asynchronously. Or, you can update the database referred by the original application if necessary. You can also do such processes on Cloud Functions, or notify your application that it is loosely coupled.You can also customize this system to create another file upload feature that fits your purpose. You may decide to use Signed Policy Document instead of Signed URL, such as if you want to set more detailed conditions or use a POST Object API. Furthermore, if you’re using Firebase, our mobile and web development tool, you can use Cloud Storage for Firebase instead of this feature because similar functionality can be easily implemented on Firebase.If you’d like to connect with Google Cloud experts, get in touch and learn more here.
Quelle: Google Cloud Platform

Manage your cross cloud spend using Azure Cost Management

It’s common for enterprises to run workloads on more than one cloud provider; however, adopting a multi-cloud strategy comes with complexities like handling different cost models, varying billing cycles, and different cloud designs that can be difficult to navigate across multiple dashboards and views.

We’ve heard from many of you that you need a central cost management solution built to help you manage your spend across multiple cloud providers, prevent budget overruns, maintain control, and create accountability with your consumers.

Azure Cost Management now offers cross-cloud support. This is available in preview and can play a critical role in helping you efficiently and effectively managing your organization’s multi-cloud needs. Onboard your AWS costs via an easy-to-use cloud connector to get a single view of your expenditures, so you can analyze and budget for the future in one place.

Get started now and create your first AWS connector with the free preview to explore these capabilities and more.

For more information about managing AWS costs, see this Manage AWS costs and usage in Azure documentation.

What’s available in this preview:

Analyzing Azure and AWS spend with cost analysis

Get deep insights into your cloud spend with the rich graphic capabilities in cost analysis. Analyze your costs across 18 available dimensions like provider, service name, usage location, availability zones, meter, and tags. Cost analysis provides the flexibility to view granular charges to understand what’s driving costs and anomalies, or high-level views to analyze total and month-over-month costs for one or both of your cloud providers. Learn more about Azure Cost Management cost analysis.

 

Budgets and alerts across your Azure & AWS spend

Budgets and alerts in Cost Management help you plan for and drive organizational accountability by allowing you to set spend amount limits and alert thresholds. You can now set budgets and receive alerts on AWS scopes, as well. You can set budgets for various scopes like subscriptions, resource groups, or for your enterprise agreement hierarchy if you are an enterprise customer. Budget notifications are integrated with Azure Action Groups, which enables email, SMS, or you can plug into your automation scripts using available Webhook and Functions integration. Learn more about Azure Cost Management budgets.

 

What’s coming next?

With Azure Cost Management, Microsoft is committed to supporting you manage your multi-cloud environment. We will continue to develop additional Cost Management features so you can benefit from a unified user experience across both Azure and AWS.
In the coming months we’ll be focusing on building features like the ability to save and schedule reports, additional capabilities in cost analysis, budgets, forecast, alerts, exports, and show-backs. And looking further into the future, we plan to continue enhancing our multi-cloud support for additional cloud products.
Follow us at @AzureCostMgmt on Twitter for more updates and information.

Quelle: Azure

Azure NetApp Files is now generally available

Today, we're excited to announce the General Availability (GA) of Azure NetApp Files, the industry’s first bare-metal cloud file storage and data management service. Azure NetApp Files is an Azure first-party service for migrating and running the most demanding enterprise file-workloads in the cloud including databases, SAP, and high-performance computing applications with no code changes. Today’s milestone is the result of deep investment by both companies to provide a great experience for our customers through a service that’s unique in the industry.

Since launching in preview mode, several Fortune 100 enterprises across the world have provided valuable feedback that helped us enrich the service.

"We wanted an on-premise like performance for our reservoir simulation and analysis software. We were thrilled to see Azure NetApp Files exceeding our expectations with an over 5x performance increase. Most importantly, the massive scale-up/down capability of Azure NetApp Files now allows for pure cloud-based consumption of both capacity AND performance,” said Juan Pedro Brett, Digital Transformation Engineer, E&P at Repsol.

Azure NetApp Files represents the culmination of a deep partnership between Microsoft and NetApp, combining NetApp’s proven and industry-leading ONTAP technology with the scale, reach, and enterprise capabilities of Azure.

“Azure NetApp Files is the most significant proof-point of NetApp’s commitment to accelerate our customer’s digital transformation, said Anthony Lye, Senior Vice President and General Manager of Cloud BU at NetApp. “We have partnered extensively with Microsoft across engineering, sales, and marketing to help customers benefit from the availability of our industry leading storage and data management technology on Azure. The general availability of Azure NetApp Files is also a fantastic moment to thank our customers for their enormous interest and feedback that has helped shaped this service.”

Read more about NetApp’s perspective on this announcement on the NetApp blog.

Deep integration of NetApp’s industry leading ONTAP storage and data management technology into Azure provides unique value to our customers in several ways:

Seamless Azure experience

Azure NetApp Files is a fully managed cloud service with full Azure portal integration and access via REST API and Azure SDKs, and soon via Azure CLI and PowerShell. It’s sold and supported exclusively by Microsoft. Customers can seamlessly migrate and run applications in the cloud without worrying about procuring or managing storage infrastructure. Additionally, customers can purchase Azure NetApp Files and get support through existing Azure agreements, with no up-front or separate term agreement.

Power of NetApp ONTAP

NetApp’s ONTAP systems serve hundreds of thousands of customers and has earned the trust of enterprise organizations over decades. The technology provides proven protocol support, including support for NFSv3 and SMB 3.1. It enables powerful data management with snapshots of datasets, high availability, and can achieve sub-millisecond latency.

Advanced security for business-critical data

Azure NetApp Files is built and operated with Azure’s industry-leading standards and processes for security, and benefits from the multi-layered security provided by Microsoft across its physical datacenters, infrastructure, and operations. Azure NetApp Files provides FIPS-140-2-compliant data encryption at rest, role-based access control (RBAC), Active Directory authentication (enabled for SMB), and export policies for network-based access control.

Support for hybrid scenarios

Azure NetApp Files enables easy migration of data across on-premises and cloud infrastructures using Cloud Sync, a NetApp service for rapid, security-enhanced data synchronization. This simplifies lift and shift and DevOps scenarios with capabilities like instantaneous snapshot, restore, and Active Directory integration (for SMB) that work the same way in the cloud and on premises. Integrated data replication and backup will be available in the near future. Learn more about Cloud Sync.

Get started with Azure NetApp Files

You can request onboarding to Azure NetApp Files by submitting an online request or by reaching out to your Microsoft representative.

We will continue to strongly partner with NetApp and look forward to hearing your feedback on Azure NetApp Files. You can email us at ANFFeedback@microsoft.com or share your ideas and suggestions for Azure Storage on our feedback forum.
Quelle: Azure

Azure.Source – Volume 84

Now available

All U.S. Azure regions now approved for FedRAMP High impact level

We’re now sharing our ability to provide Azure public services that meet U.S. Federal Risk and Authorization Management Program (FedRAMP) High impact level and extend FedRAMP High Provisional Authorization to Operate (P-ATO) to all of our Azure public regions in the United States. Achieving FedRAMP High means that both Azure public and Azure Government data centers and services meet the demanding requirements of FedRAMP High, making it easier for more federal agencies to benefit from the cost savings and rigorous security of the Microsoft Commercial Cloud.

Now in preview

Drive higher utilization of Azure HDInsight clusters with autoscale

We are excited to share the preview of the Autoscale feature for Azure HDInsight. This feature enables enterprises to become more productive and cost-efficient by automatically scaling clusters up or down based on the load or a customized schedule.

Announcing the preview of Windows Server containers support in Azure Kubernetes Service

Kubernetes is taking the app development world by storm. Earlier this month, we shared that the Azure Kubernetes Service (AKS) was the fastest growing compute service in Azure’s history. Today, we’re excited to announce the preview of Windows Server containers in Azure Kubernetes Service (AKS) for the latest versions, 1.13.5 and 1.14.0.  With this, Windows Server containers can now be deployed and orchestrated in AKS enabling new paths to migrate and modernize Windows Server applications in Azure.

Optimize price-performance with compute auto-scaling in Azure SQL Database serverless

Optimizing compute resource allocation to achieve performance goals while controlling costs can be a challenging balance to strike – especially for database workloads with complex usage patterns. To help address these challenges, we are pleased to announce the preview of Azure SQL Database serverless. SQL Database serverless (preview) is a new compute tier that optimizes price-performance and simplifies performance management for databases with intermittent and unpredictable usage. Line-of-business applications, dev/test databases, content management, and e-commerce systems are just some examples across a range of applications that often fit the usage pattern ideal for SQL Database serverless.

Visual interface for Azure Machine Learning service

During Microsoft Build we announced the preview of the visual interface for Azure Machine Learning service. This new drag-and-drop workflow capability in Azure Machine Learning service simplifies the process of building, testing, and deploying machine learning models for customers who prefer a visual experience to a coding experience. This capability brings the familiarity of what we already provide in our popular Azure Machine Learning Studio with significant improvements to ease the user experience.

Technical content

Kubernetes - from the beginning, Part I, Basics, Deployment and Minikube

Kubernetes is a BIG topic. In this blog series, Chris Noring tackles the basics. Part 1 covers: Why Kubernetes and orchestration in general; talking through Minikube, simple deploy example; cluster and basic commands; deploying an app; and concepts and troubleshooting of pods and nodes.

Introduction to AzureKusto

This post is to announce the availability of AzureKusto, the R interface to Azure Data Explorer (internally codenamed “Kusto”), a fast, fully managed data analytics service from Microsoft. It is available from CRAN, or you can install the development version from GitHub.

Microsoft Azure for spoiled people

In this article, the author walks you through the easiest possible way to set up a Vue.js CLI-built web app on Azure with continuous integration via GitHub.

Azure IoT Central and MXChip Hands-on Lab

This hands-on lab covers creating an Azure IoT Central application, connecting an MXChip IoT DevKit device to your Azure IoT Central application, and setting up a device template.

Azure shows

A new way to try .NET

Learning a programming language is becoming a fundamental aspect of education across the world. We're always looking for new and interesting ways to teach programming to learners at all levels. From Microsoft Build 2019,  we had Maria Naggaga come on to show us the Try .NET project. She shows us how this simple tool will allow us to create interactive documentation, workshops, and other interesting learning experiences.

Xamarin.Forms 101: Dynamic resources

Let's take a step back in a new mini-series that I like to call Xamarin.Forms 101. In each episode we will walk through a basic building block of Xamarin.Forms to help you build awesome cross-platform iOS, Android, and Windows applications in .NET. This week we will look at how to use dynamic resources to change the value of a resource while the application is running.

Cosmos DB data in a smart contract with Logic Apps

We show an IoT use case that highlights how to leverage the power of Cosmos DB to manipulate IoT data within a Cosmos DB and use that data in smart contracts via the Ethereum Logic App connector.

ARM templates and Azure policy

Cynthia talks with Satya Vel on the latest ARM template updates including an enhanced template export experience, best practices for ARM clients, and new capabilities that are now available on ARM templates.

Industries and partners

Securing the pharmaceutical supply chain with Azure IoT

You’re responsible for overseeing the transportation of a pallet of medicine halfway around the world. Drugs will travel from your pharmaceutical company’s manufacturing outbound warehouse in central New Jersey to third-party logistics firms, distributors, pharmacies, and ultimately, patients. Each box in that pallet – no bigger than the box that holds the business cards on your desk – contains very costly medicine, the product of 10 years of research and R&D spending. But there are several big catches. Read on to see what they are and how Azure IoT helps overcome them.

How you can use IoT to power Industry 4.0 innovation

IoT is ushering in an exciting—and sometimes exasperating—time of innovation. Adoption isn’t easy, so it’s important to hold a vision of the promise of Industry 4.0 in mind as you get ready for this next wave of business. This post is the fourth in a four-part series designed to help companies maximize their ROI on IoT.
Quelle: Azure

Medienplayer: Apple präsentiert neuen iPod Touch

Nach fast vier Jahren bringt Apple einen neuen iPod Touch auf den Markt: Der Medienplayer kommt mit einem schnelleren, aber mittlerweile auch schon drei Jahre alten SoC und bis zu 256 GByte Speicher in den Handel, die Preise starten bei 230 Euro. (iPod Touch, Apple)
Quelle: Golem

Indiegames: Aufbau gaaanz anders als in Anno 1800

Die Weltwunder in Anno 1800 sind errichtet, alle Produktionsketten freigeschaltet? Hier kommt neues, vor allem aber ganz anderes Material für Aufbauspieler: Golem.de stellt minimalistische, größenwahnsinnige und spätkapitalistische Genrevertreter vor – alle stammen von unabhängigen Entwicklern. Von Rainer Sigl (Aufbauspiel, Steam)
Quelle: Golem